[dpdk-dev,1/7] net/mlx5: rename confusing object in probe code
Checks
Commit Message
There are several attribute objects in this function:
- IB device attributes (struct ibv_device_attr_ex device_attr).
- Direct Verbs attributes (struct mlx5dv_context attrs_out).
- Port attributes (struct ibv_port_attr).
- IB device attributes again (struct ibv_device_attr_ex device_attr_ex).
"attrs_out" is both odd and initialized using a nonstandard syntax. Rename
it "dv_attr" for consistency.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
drivers/net/mlx5/mlx5.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
Comments
Ack except one minor question below.
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> Sent: Saturday, May 26, 2018 12:35 AM
> To: Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/7] net/mlx5: rename confusing object in probe code
>
> There are several attribute objects in this function:
>
> - IB device attributes (struct ibv_device_attr_ex device_attr).
> - Direct Verbs attributes (struct mlx5dv_context attrs_out).
> - Port attributes (struct ibv_port_attr).
> - IB device attributes again (struct ibv_device_attr_ex device_attr_ex).
>
> "attrs_out" is both odd and initialized using a nonstandard syntax. Rename it "dv_attr" for
> consistency.
>
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
> drivers/net/mlx5/mlx5.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 9b78f9879..602f952ca 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -652,6 +652,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, {
> struct ibv_device **list = NULL;
> struct ibv_device *ibv_dev;
> + struct mlx5dv_context dv_attr = { .comp_mask = 0 };
> int err = 0;
> struct ibv_context *attr_ctx = NULL;
> struct ibv_device_attr_ex device_attr; @@ -668,7 +669,6 @@ mlx5_pci_probe(struct rte_pci_driver
> *pci_drv __rte_unused,
> unsigned int mprq_min_stride_num_n = 0;
> unsigned int mprq_max_stride_num_n = 0;
> int i;
> - struct mlx5dv_context attrs_out = {0};
> #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
> struct ibv_counter_set_description cs_desc; #endif @@ -734,21 +734,21 @@ mlx5_pci_probe(struct
> rte_pci_driver *pci_drv __rte_unused,
> ibv_dev = list[i];
> DRV_LOG(DEBUG, "device opened");
> #ifdef HAVE_IBV_MLX5_MOD_SWP
> - attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
> + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
> #endif
> /*
> * Multi-packet send is supported by ConnectX-4 Lx PF as well
> * as all ConnectX-5 devices.
> */
> #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
> - attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
> + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
> #endif
> #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
> - attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
> + dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
> #endif
> - mlx5_glue->dv_query_device(attr_ctx, &attrs_out);
> - if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
> - if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
> + mlx5_glue->dv_query_device(ctx, &dv_attr);
Should ctx be attr_ctx?.
> + if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
> + if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
> DRV_LOG(DEBUG, "enhanced MPW is supported");
> mps = MLX5_MPW_ENHANCED;
> } else {
> @@ -760,14 +760,14 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
> mps = MLX5_MPW_DISABLED;
> }
> #ifdef HAVE_IBV_MLX5_MOD_SWP
> - if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
> - swp = attrs_out.sw_parsing_caps.sw_parsing_offloads;
> + if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
> + swp = dv_attr.sw_parsing_caps.sw_parsing_offloads;
> DRV_LOG(DEBUG, "SWP support: %u", swp); #endif #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
> - if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
> + if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
> struct mlx5dv_striding_rq_caps mprq_caps =
> - attrs_out.striding_rq_caps;
> + dv_attr.striding_rq_caps;
>
> DRV_LOG(DEBUG, "\tmin_single_stride_log_num_of_bytes: %d",
> mprq_caps.min_single_stride_log_num_of_bytes);
> @@ -792,15 +792,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
> }
> #endif
> if (RTE_CACHE_LINE_SIZE == 128 &&
> - !(attrs_out.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
> + !(dv_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
> cqe_comp = 0;
> else
> cqe_comp = 1;
> #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
> - if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
> - tunnel_en = ((attrs_out.tunnel_offloads_caps &
> + if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
> + tunnel_en = ((dv_attr.tunnel_offloads_caps &
> MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_VXLAN) &&
> - (attrs_out.tunnel_offloads_caps &
> + (dv_attr.tunnel_offloads_caps &
> MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GRE));
> }
> DRV_LOG(DEBUG, "tunnel offloading is %ssupported", @@ -810,9 +810,9 @@ mlx5_pci_probe(struct
> rte_pci_driver *pci_drv __rte_unused,
> "tunnel offloading disabled due to old OFED/rdma-core version"); #endif #ifdef
> HAVE_IBV_DEVICE_MPLS_SUPPORT
> - mpls_en = ((attrs_out.tunnel_offloads_caps &
> + mpls_en = ((dv_attr.tunnel_offloads_caps &
> MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE) &&
> - (attrs_out.tunnel_offloads_caps &
> + (dv_attr.tunnel_offloads_caps &
> MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_UDP));
> DRV_LOG(DEBUG, "MPLS over GRE/UDP tunnel offloading is %ssupported",
> mpls_en ? "" : "not ");
> --
> 2.11.0
On Sun, Jun 10, 2018 at 11:00:57AM +0000, Xueming(Steven) Li wrote:
> Ack except one minor question below.
<snip>
> > - mlx5_glue->dv_query_device(attr_ctx, &attrs_out);
> > - if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
> > - if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
> > + mlx5_glue->dv_query_device(ctx, &dv_attr);
>
> Should ctx be attr_ctx?.
Indeed, seems like I didn't validate this patch on its own after splitting
it from another. Will fix in v2, thanks.
@@ -652,6 +652,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
{
struct ibv_device **list = NULL;
struct ibv_device *ibv_dev;
+ struct mlx5dv_context dv_attr = { .comp_mask = 0 };
int err = 0;
struct ibv_context *attr_ctx = NULL;
struct ibv_device_attr_ex device_attr;
@@ -668,7 +669,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
unsigned int mprq_min_stride_num_n = 0;
unsigned int mprq_max_stride_num_n = 0;
int i;
- struct mlx5dv_context attrs_out = {0};
#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
struct ibv_counter_set_description cs_desc;
#endif
@@ -734,21 +734,21 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
ibv_dev = list[i];
DRV_LOG(DEBUG, "device opened");
#ifdef HAVE_IBV_MLX5_MOD_SWP
- attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
+ dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
#endif
/*
* Multi-packet send is supported by ConnectX-4 Lx PF as well
* as all ConnectX-5 devices.
*/
#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
- attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
+ dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
#endif
#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
- attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
+ dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
#endif
- mlx5_glue->dv_query_device(attr_ctx, &attrs_out);
- if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
- if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
+ mlx5_glue->dv_query_device(ctx, &dv_attr);
+ if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
+ if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
DRV_LOG(DEBUG, "enhanced MPW is supported");
mps = MLX5_MPW_ENHANCED;
} else {
@@ -760,14 +760,14 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
mps = MLX5_MPW_DISABLED;
}
#ifdef HAVE_IBV_MLX5_MOD_SWP
- if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
- swp = attrs_out.sw_parsing_caps.sw_parsing_offloads;
+ if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
+ swp = dv_attr.sw_parsing_caps.sw_parsing_offloads;
DRV_LOG(DEBUG, "SWP support: %u", swp);
#endif
#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
- if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
+ if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
struct mlx5dv_striding_rq_caps mprq_caps =
- attrs_out.striding_rq_caps;
+ dv_attr.striding_rq_caps;
DRV_LOG(DEBUG, "\tmin_single_stride_log_num_of_bytes: %d",
mprq_caps.min_single_stride_log_num_of_bytes);
@@ -792,15 +792,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
#endif
if (RTE_CACHE_LINE_SIZE == 128 &&
- !(attrs_out.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
+ !(dv_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
cqe_comp = 0;
else
cqe_comp = 1;
#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
- if (attrs_out.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
- tunnel_en = ((attrs_out.tunnel_offloads_caps &
+ if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
+ tunnel_en = ((dv_attr.tunnel_offloads_caps &
MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_VXLAN) &&
- (attrs_out.tunnel_offloads_caps &
+ (dv_attr.tunnel_offloads_caps &
MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GRE));
}
DRV_LOG(DEBUG, "tunnel offloading is %ssupported",
@@ -810,9 +810,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
"tunnel offloading disabled due to old OFED/rdma-core version");
#endif
#ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
- mpls_en = ((attrs_out.tunnel_offloads_caps &
+ mpls_en = ((dv_attr.tunnel_offloads_caps &
MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE) &&
- (attrs_out.tunnel_offloads_caps &
+ (dv_attr.tunnel_offloads_caps &
MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_UDP));
DRV_LOG(DEBUG, "MPLS over GRE/UDP tunnel offloading is %ssupported",
mpls_en ? "" : "not ");