MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ena_com_fill_hash_function

Function ena_com_fill_hash_function

dpdk/drivers/net/ena/base/ena_com.c:2709–2757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2707}
2708
2709int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
2710 enum ena_admin_hash_functions func,
2711 const u8 *key, u16 key_len, u32 init_val)
2712{
2713 struct ena_admin_feature_rss_flow_hash_control *hash_key;
2714 struct ena_admin_get_feat_resp get_resp;
2715 enum ena_admin_hash_functions old_func;
2716 struct ena_rss *rss = &ena_dev->rss;
2717 int rc;
2718
2719 hash_key = rss->hash_key;
2720
2721 /* Make sure size is a mult of DWs */
2722 if (unlikely(key_len & 0x3))
2723 return ENA_COM_INVAL;
2724
2725 rc = ena_com_get_feature_ex(ena_dev, &get_resp,
2726 ENA_ADMIN_RSS_HASH_FUNCTION,
2727 rss->hash_key_dma_addr,
2728 sizeof(*rss->hash_key), 0);
2729 if (unlikely(rc))
2730 return rc;
2731
2732 if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
2733 ena_trc_err(ena_dev, "Flow hash function %d isn't supported\n", func);
2734 return ENA_COM_UNSUPPORTED;
2735 }
2736
2737 if (func == ENA_ADMIN_TOEPLITZ && key) {
2738 if (key_len != sizeof(hash_key->key)) {
2739 ena_trc_err(ena_dev, "key len (%u) doesn't equal the supported size (%zu)\n",
2740 key_len, sizeof(hash_key->key));
2741 return ENA_COM_INVAL;
2742 }
2743 memcpy(hash_key->key, key, key_len);
2744 hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
2745 }
2746
2747 rss->hash_init_val = init_val;
2748 old_func = rss->hash_func;
2749 rss->hash_func = func;
2750 rc = ena_com_set_hash_function(ena_dev);
2751
2752 /* Restore the old function */
2753 if (unlikely(rc))
2754 rss->hash_func = old_func;
2755
2756 return rc;
2757}
2758
2759int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
2760 enum ena_admin_hash_functions *func)

Callers 1

ena_rss_hash_setFunction · 0.50

Calls 3

ena_com_get_feature_exFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected