vlib_log_emerg (rm->log_class, "%s: fatal error", rd->name);
break;
default:
- rdma_log__ (VLIB_LOG_LEVEL_ERR, rd, "unhandeld RDMA async event %i",
+ rdma_log__ (VLIB_LOG_LEVEL_ERR, rd, "unhandeld RDMA async event %d",
event.event_type);
break;
}
return 0;
}
+static uint64_t
+rdma_rss42ibv (const rdma_rss4_t rss4)
+{
+ switch (rss4)
+ {
+ case RDMA_RSS4_IP:
+ return IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4;
+ case RDMA_RSS4_IP_UDP:
+ return IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4 |
+ IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP;
+ case RDMA_RSS4_AUTO: /* fallthrough */
+ case RDMA_RSS4_IP_TCP:
+ return IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4 |
+ IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP;
+ }
+ ASSERT (0);
+ return 0;
+}
+
+static uint64_t
+rdma_rss62ibv (const rdma_rss6_t rss6)
+{
+ switch (rss6)
+ {
+ case RDMA_RSS6_IP:
+ return IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6;
+ case RDMA_RSS6_IP_UDP:
+ return IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6 |
+ IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP;
+ case RDMA_RSS6_AUTO: /* fallthrough */
+ case RDMA_RSS6_IP_TCP:
+ return IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6 |
+ IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP;
+ }
+ ASSERT (0);
+ return 0;
+}
+
static clib_error_t *
-rdma_rxq_finalize (vlib_main_t * vm, rdma_device_t * rd)
+rdma_rxq_finalize (vlib_main_t *vm, rdma_device_t *rd)
{
struct ibv_rwq_ind_table_init_attr rwqia;
struct ibv_qp_init_attr_ex qpia;
struct ibv_wq **ind_tbl;
+ const u32 rxq_sz = vec_len (rd->rxqs);
+ u32 ind_tbl_sz = rxq_sz;
u32 i;
- ASSERT (is_pow2 (vec_len (rd->rxqs))
- && "rxq number should be a power of 2");
+ if (!is_pow2 (ind_tbl_sz))
+ {
+ /* in case we do not have a power-of-2 number of rxq, we try to use the
+ * maximum supported to minimize the imbalance */
+ struct ibv_device_attr_ex attr;
+ if (ibv_query_device_ex (rd->ctx, 0, &attr))
+ return clib_error_return_unix (0, "device query failed");
+ ind_tbl_sz = attr.rss_caps.max_rwq_indirection_table_size;
+ if (ind_tbl_sz < rxq_sz)
+ return clib_error_create ("too many rxqs requested (%d) compared to "
+ "max indirection table size (%d)",
+ rxq_sz, ind_tbl_sz);
+ }
- ind_tbl = vec_new (struct ibv_wq *, vec_len (rd->rxqs));
- vec_foreach_index (i, rd->rxqs)
- ind_tbl[i] = vec_elt_at_index (rd->rxqs, i)->wq;
+ ind_tbl = vec_new (struct ibv_wq *, ind_tbl_sz);
+ vec_foreach_index (i, ind_tbl)
+ vec_elt (ind_tbl, i) = vec_elt (rd->rxqs, i % rxq_sz).wq;
memset (&rwqia, 0, sizeof (rwqia));
+ ASSERT (is_pow2 (vec_len (ind_tbl)));
rwqia.log_ind_tbl_size = min_log2 (vec_len (ind_tbl));
rwqia.ind_tbl = ind_tbl;
if ((rd->rx_rwq_ind_tbl = ibv_create_rwq_ind_table (rd->ctx, &rwqia)) == 0)
qpia.rx_hash_conf.rx_hash_key = rdma_rss_hash_key;
qpia.rx_hash_conf.rx_hash_function = IBV_RX_HASH_FUNC_TOEPLITZ;
- qpia.rx_hash_conf.rx_hash_fields_mask =
- IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4 | IBV_RX_HASH_SRC_PORT_TCP |
- IBV_RX_HASH_DST_PORT_TCP;
+ qpia.rx_hash_conf.rx_hash_fields_mask = rdma_rss42ibv (rd->rss4);
if ((rd->rx_qp4 = ibv_create_qp_ex (rd->ctx, &qpia)) == 0)
return clib_error_return_unix (0, "IPv4 Queue Pair create failed");
- qpia.rx_hash_conf.rx_hash_fields_mask =
- IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6 | IBV_RX_HASH_SRC_PORT_TCP |
- IBV_RX_HASH_DST_PORT_TCP;
+ qpia.rx_hash_conf.rx_hash_fields_mask = rdma_rss62ibv (rd->rss6);
if ((rd->rx_qp6 = ibv_create_qp_ex (rd->ctx, &qpia)) == 0)
return clib_error_return_unix (0, "IPv6 Queue Pair create failed");
ethernet_mac_address_generate (rd->hwaddr.bytes);
- if ((rd->mr = ibv_reg_mr (rd->pd, (void *) bm->buffer_mem_start,
- bm->buffer_mem_size,
- IBV_ACCESS_LOCAL_WRITE)) == 0)
- return clib_error_return_unix (0, "Register MR Failed");
- rd->lkey = rd->mr->lkey; /* avoid indirection in datapath */
+ rd->rss4 = args->rss4;
+ rd->rss6 = args->rss6;
/*
* /!\ WARNING /!\ creation order is important
args->txq_size = args->txq_size ? args->txq_size : 1024;
args->rxq_num = args->rxq_num ? args->rxq_num : 2;
- if (!is_pow2 (args->rxq_num))
- {
- args->rv = VNET_API_ERROR_INVALID_VALUE;
- args->error =
- clib_error_return (0, "rx queue number must be a power of two");
- goto err0;
- }
-
if (args->rxq_size < VLIB_FRAME_SIZE || args->txq_size < VLIB_FRAME_SIZE ||
args->rxq_size > 65535 || args->txq_size > 65535 ||
!is_pow2 (args->rxq_size) || !is_pow2 (args->txq_size))
{
args->rv = VNET_API_ERROR_INVALID_VALUE;
- args->error = clib_error_return (0, "queue size must be a power of two "
- "between %i and 65535",
+ args->error = clib_error_return (0,
+ "queue size must be a power of two "
+ "between %d and 65535",
VLIB_FRAME_SIZE);
goto err0;
}