* Obtain a RSS context with specified properties. * * Used when creating a flow rule targeting one or several Rx queues. * * If a matching RSS context already exists, it is returned with its * reference count incremented. * * @param priv * Pointer to private structure. * @param fields * Fields for RSS processing (Verbs format). * @param[in] key * Hash key to use (whose size is ex
| 86 | * Pointer to RSS context on success, NULL otherwise and rte_errno is set. |
| 87 | */ |
| 88 | struct mlx4_rss * |
| 89 | mlx4_rss_get(struct mlx4_priv *priv, uint64_t fields, |
| 90 | const uint8_t key[MLX4_RSS_HASH_KEY_SIZE], |
| 91 | uint16_t queues, const uint16_t queue_id[]) |
| 92 | { |
| 93 | struct mlx4_rss *rss; |
| 94 | size_t queue_id_size = sizeof(queue_id[0]) * queues; |
| 95 | |
| 96 | LIST_FOREACH(rss, &priv->rss, next) |
| 97 | if (fields == rss->fields && |
| 98 | queues == rss->queues && |
| 99 | !memcmp(key, rss->key, MLX4_RSS_HASH_KEY_SIZE) && |
| 100 | !memcmp(queue_id, rss->queue_id, queue_id_size)) { |
| 101 | ++rss->refcnt; |
| 102 | return rss; |
| 103 | } |
| 104 | rss = rte_malloc(__func__, offsetof(struct mlx4_rss, queue_id) + |
| 105 | queue_id_size, 0); |
| 106 | if (!rss) |
| 107 | goto error; |
| 108 | *rss = (struct mlx4_rss){ |
| 109 | .priv = priv, |
| 110 | .refcnt = 1, |
| 111 | .usecnt = 0, |
| 112 | .qp = NULL, |
| 113 | .ind = NULL, |
| 114 | .fields = fields, |
| 115 | .queues = queues, |
| 116 | }; |
| 117 | memcpy(rss->key, key, MLX4_RSS_HASH_KEY_SIZE); |
| 118 | memcpy(rss->queue_id, queue_id, queue_id_size); |
| 119 | LIST_INSERT_HEAD(&priv->rss, rss, next); |
| 120 | return rss; |
| 121 | error: |
| 122 | rte_errno = ENOMEM; |
| 123 | return NULL; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Release a RSS context instance. |
no test coverage detected