From patchwork Fri Jun 5 23:15:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 5232 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 963A0C3EC; Sat, 6 Jun 2015 01:16:20 +0200 (CEST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 6FF4BC3EC for ; Sat, 6 Jun 2015 01:16:19 +0200 (CEST) Received: by wgbgq6 with SMTP id gq6so66781030wgb.3 for ; Fri, 05 Jun 2015 16:16:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gGZ2DXmC3MDBaM5QmlSLwS0p2+bvzUB18iy6W4wHLXk=; b=VfzJE5Un7+jMIT0YR9KenSSBbTkNE6OAJ+xUCq2SdyhkIebLYNx51HaRG0GbdeqUj7 Bg484IRfo3m/Jpp71NHLYF1ahnNrJir0yYo50GusCeG5sh9LGS/Fqd4w4SMPqTq1jlL7 eXbI/FN6WUBDcszG9XHlh3yDYULONyil+4LF9Cb65OVtI92XTNsQLE2gJ1Oqm6Lqjims m4cr3SHr1dqt1jzrmaAjE6wAHMSZlZseoFh0pjzAzJfmTNYKBgJ3t6votcW8eTS4LTlI reect8f59+HvF6Jv4w5uS+eGPHhQ+/mWHdm2TYg+pxGeW5rNiA9d/s4204HJ8XxjG9Ji B3BA== X-Gm-Message-State: ALoCoQmdnPCC1Otpyi0d36fBT0QOWMeXJi3B8NB75k+8k4l0n8zvswSoG/1cQExBFWe+U3ABI3iW X-Received: by 10.180.73.176 with SMTP id m16mr1011662wiv.68.1433546179356; Fri, 05 Jun 2015 16:16:19 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id i14sm8915364wjr.7.2015.06.05.16.16.17 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 05 Jun 2015 16:16:18 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Sat, 6 Jun 2015 01:15:16 +0200 Message-Id: <1433546120-2254-13-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433546120-2254-1-git-send-email-adrien.mazarguil@6wind.com> References: <1433546120-2254-1-git-send-email-adrien.mazarguil@6wind.com> Cc: Alex Rosenbaum Subject: [dpdk-dev] [PATCH 12/16] mlx4: add support for upstream flow steering API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Alex Rosenbaum This commit makes librte_pmd_mlx4 support both the extended Verbs API from upstream and the original experimental Verbs API. Signed-off-by: Olga Shern Signed-off-by: Alex Rosenbaum Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/Makefile | 4 +++ drivers/net/mlx4/mlx4.c | 82 +++++++++++++++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile index ce1f2b0..2b3a1b6 100644 --- a/drivers/net/mlx4/Makefile +++ b/drivers/net/mlx4/Makefile @@ -116,6 +116,10 @@ mlx4_autoconf.h: $(RTE_SDK)/scripts/auto-config-h.sh HAVE_EXP_QUERY_DEVICE \ infiniband/verbs.h \ type 'struct ibv_exp_device_attr' $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_STRUCT_IBV_FLOW \ + infiniband/verbs.h \ + type 'struct ibv_flow' $(AUTOCONF_OUTPUT) mlx4.o: mlx4_autoconf.h diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index f9faeb0..73663d2 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -97,6 +97,34 @@ /* PMD header. */ #include "mlx4.h" +#ifdef HAVE_STRUCT_IBV_FLOW + +/* Use extended flow steering Verbs API from upstream. */ +#define MLX_FLOW_ATTR_NORMAL IBV_FLOW_ATTR_NORMAL +#define MLX_FLOW_SPEC_ETH IBV_FLOW_SPEC_ETH +#define MLX_FLOW_ATTR_MC_DEFAULT IBV_FLOW_ATTR_MC_DEFAULT +#define MLX_FLOW_ATTR_ALL_DEFAULT IBV_FLOW_ATTR_ALL_DEFAULT +#define mlx_flow ibv_flow +#define mlx_flow_attr ibv_flow_attr +#define mlx_flow_spec_eth ibv_flow_spec_eth +#define mlx_create_flow ibv_create_flow +#define mlx_destroy_flow ibv_destroy_flow + +#else /* HAVE_STRUCT_IBV_FLOW */ + +/* Use experimental flow steering Verbs API. */ +#define MLX_FLOW_ATTR_NORMAL IBV_EXP_FLOW_ATTR_NORMAL +#define MLX_FLOW_SPEC_ETH IBV_EXP_FLOW_SPEC_ETH +#define MLX_FLOW_ATTR_MC_DEFAULT IBV_EXP_FLOW_ATTR_MC_DEFAULT +#define MLX_FLOW_ATTR_ALL_DEFAULT IBV_EXP_FLOW_ATTR_ALL_DEFAULT +#define mlx_flow ibv_exp_flow +#define mlx_flow_attr ibv_exp_flow_attr +#define mlx_flow_spec_eth ibv_exp_flow_spec_eth +#define mlx_create_flow ibv_exp_create_flow +#define mlx_destroy_flow ibv_exp_destroy_flow + +#endif /* HAVE_STRUCT_IBV_FLOW */ + /* Runtime logging through RTE_LOG() is enabled when not in debugging mode. * Intermediate LOG_*() macros add the required end-of-line characters. */ #ifndef NDEBUG @@ -203,9 +231,9 @@ struct rxq { * may contain several specifications, one per configured VLAN ID. */ BITFIELD_DECLARE(mac_configured, uint32_t, MLX4_MAX_MAC_ADDRESSES); - struct ibv_exp_flow *mac_flow[MLX4_MAX_MAC_ADDRESSES]; - struct ibv_exp_flow *promisc_flow; /* Promiscuous flow. */ - struct ibv_exp_flow *allmulti_flow; /* Multicast flow. */ + struct mlx_flow *mac_flow[MLX4_MAX_MAC_ADDRESSES]; + struct mlx_flow *promisc_flow; /* Promiscuous flow. */ + struct mlx_flow *allmulti_flow; /* Multicast flow. */ unsigned int port_id; /* Port ID for incoming packets. */ unsigned int elts_n; /* (*elts)[] length. */ unsigned int elts_head; /* Current index in (*elts)[]. */ @@ -1881,7 +1909,7 @@ rxq_mac_addr_del(struct rxq *rxq, unsigned int mac_index) (*mac)[0], (*mac)[1], (*mac)[2], (*mac)[3], (*mac)[4], (*mac)[5], mac_index); assert(rxq->mac_flow[mac_index] != NULL); - claim_zero(ibv_exp_destroy_flow(rxq->mac_flow[mac_index])); + claim_zero(mlx_destroy_flow(rxq->mac_flow[mac_index])); rxq->mac_flow[mac_index] = NULL; BITFIELD_RESET(rxq->mac_configured, mac_index); } @@ -1926,7 +1954,7 @@ rxq_mac_addr_add(struct rxq *rxq, unsigned int mac_index) unsigned int vlans = 0; unsigned int specs = 0; unsigned int i, j; - struct ibv_exp_flow *flow; + struct mlx_flow *flow; assert(mac_index < elemof(priv->mac)); if (BITFIELD_ISSET(rxq->mac_configured, mac_index)) @@ -1938,28 +1966,28 @@ rxq_mac_addr_add(struct rxq *rxq, unsigned int mac_index) specs = (vlans ? vlans : 1); /* Allocate flow specification on the stack. */ - struct ibv_exp_flow_attr data + struct mlx_flow_attr data [1 + - (sizeof(struct ibv_exp_flow_spec_eth[specs]) / - sizeof(struct ibv_exp_flow_attr)) + - !!(sizeof(struct ibv_exp_flow_spec_eth[specs]) % - sizeof(struct ibv_exp_flow_attr))]; - struct ibv_exp_flow_attr *attr = (void *)&data[0]; - struct ibv_exp_flow_spec_eth *spec = (void *)&data[1]; + (sizeof(struct mlx_flow_spec_eth[specs]) / + sizeof(struct mlx_flow_attr)) + + !!(sizeof(struct mlx_flow_spec_eth[specs]) % + sizeof(struct mlx_flow_attr))]; + struct mlx_flow_attr *attr = (void *)&data[0]; + struct mlx_flow_spec_eth *spec = (void *)&data[1]; /* * No padding must be inserted by the compiler between attr and spec. * This layout is expected by libibverbs. */ assert(((uint8_t *)attr + sizeof(*attr)) == (uint8_t *)spec); - *attr = (struct ibv_exp_flow_attr){ - .type = IBV_EXP_FLOW_ATTR_NORMAL, + *attr = (struct mlx_flow_attr) { + .type = MLX_FLOW_ATTR_NORMAL, .num_of_specs = specs, .port = priv->port, .flags = 0 }; - *spec = (struct ibv_exp_flow_spec_eth){ - .type = IBV_EXP_FLOW_SPEC_ETH, + *spec = (struct mlx_flow_spec_eth) { + .type = MLX_FLOW_SPEC_ETH, .size = sizeof(*spec), .val = { .dst_mac = { @@ -1990,7 +2018,7 @@ rxq_mac_addr_add(struct rxq *rxq, unsigned int mac_index) vlans); /* Create related flow. */ errno = 0; - flow = ibv_exp_create_flow(rxq->qp, attr); + flow = mlx_create_flow(rxq->qp, attr); if (flow == NULL) { int err = errno; @@ -2177,9 +2205,9 @@ end: static int rxq_allmulticast_enable(struct rxq *rxq) { - struct ibv_exp_flow *flow; - struct ibv_exp_flow_attr attr = { - .type = IBV_EXP_FLOW_ATTR_MC_DEFAULT, + struct mlx_flow *flow; + struct mlx_flow_attr attr = { + .type = MLX_FLOW_ATTR_MC_DEFAULT, .num_of_specs = 0, .port = rxq->priv->port, .flags = 0 @@ -2189,7 +2217,7 @@ rxq_allmulticast_enable(struct rxq *rxq) if (rxq->allmulti_flow != NULL) return EBUSY; errno = 0; - flow = ibv_exp_create_flow(rxq->qp, &attr); + flow = mlx_create_flow(rxq->qp, &attr); if (flow == NULL) { /* It's not clear whether errno is always set in this case. */ ERROR("%p: flow configuration failed, errno=%d: %s", @@ -2216,7 +2244,7 @@ rxq_allmulticast_disable(struct rxq *rxq) DEBUG("%p: disabling allmulticast mode", (void *)rxq); if (rxq->allmulti_flow == NULL) return; - claim_zero(ibv_exp_destroy_flow(rxq->allmulti_flow)); + claim_zero(mlx_destroy_flow(rxq->allmulti_flow)); rxq->allmulti_flow = NULL; DEBUG("%p: allmulticast mode disabled", (void *)rxq); } @@ -2233,9 +2261,9 @@ rxq_allmulticast_disable(struct rxq *rxq) static int rxq_promiscuous_enable(struct rxq *rxq) { - struct ibv_exp_flow *flow; - struct ibv_exp_flow_attr attr = { - .type = IBV_EXP_FLOW_ATTR_ALL_DEFAULT, + struct mlx_flow *flow; + struct mlx_flow_attr attr = { + .type = MLX_FLOW_ATTR_ALL_DEFAULT, .num_of_specs = 0, .port = rxq->priv->port, .flags = 0 @@ -2247,7 +2275,7 @@ rxq_promiscuous_enable(struct rxq *rxq) if (rxq->promisc_flow != NULL) return EBUSY; errno = 0; - flow = ibv_exp_create_flow(rxq->qp, &attr); + flow = mlx_create_flow(rxq->qp, &attr); if (flow == NULL) { /* It's not clear whether errno is always set in this case. */ ERROR("%p: flow configuration failed, errno=%d: %s", @@ -2276,7 +2304,7 @@ rxq_promiscuous_disable(struct rxq *rxq) DEBUG("%p: disabling promiscuous mode", (void *)rxq); if (rxq->promisc_flow == NULL) return; - claim_zero(ibv_exp_destroy_flow(rxq->promisc_flow)); + claim_zero(mlx_destroy_flow(rxq->promisc_flow)); rxq->promisc_flow = NULL; DEBUG("%p: promiscuous mode disabled", (void *)rxq); }