From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id E94172C2A for ; Tue, 27 Sep 2016 16:53:30 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id g62so25567572lfe.3 for ; Tue, 27 Sep 2016 07:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YecHGZFA9hE65l5c0x5InK4ZIRxxx/VtBlPdxwR9r+U=; b=Od8bmSKS3YAGAU1t76WsSlE4E52toaDS24Ca3tLF/yNqAyJP0GnppY6oZfgA5VUKWE QdLkT8PtlA3GEKFTykQWhvgS8k7lM2PQ/AsdGuCfP4yfAERkIOk8++sv4+c6WXNLOCbz k4KtIXetMQX5oSE4vcnx9sRCr+eo38hQjjZsiVCDv/y7puwKijYhhKi7R5LfIf1faOz5 pWmrk/nBJ+zknS3Py/7x/emJOGF855o97PcMV53dwFgS19UrxLp4DU31X5ZYmgwIMIGu OpHhgPHk49qry0yi6pQnicNg/0TEZwsGfZM2WTXFJxGRWDXsGEM3lS3aW89wMhLKAKmZ GAJQ== 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=YecHGZFA9hE65l5c0x5InK4ZIRxxx/VtBlPdxwR9r+U=; b=meMttlucBPUForvjJvMdHAOdoxeEGawhHuOhcufJIxq8C3pZslPCG3Ew1KMpOI1Lu+ EmUu6ZlPqQ9GHHpMKIMn9f/XvWOPRPv827R39gEBzMQVwLvCJSoiiDOzi3pBx5rNS+Q5 28y0HMxa5FSLwJxIC/lr1Hh+ZokHiaf6yytXka8eKNE932UWCkuuJeI38OpZAeNDS+2h iDfqZ/wkEZuckoFmlcY2CC3HQM+rDGl0IYFqNEwj28RFjsHV/52yK7j3tZVuVTL1g6+0 Avyjv92KE4/dTjoQUpKGkksNkGfZj7hd14NfkECeZaDMcRkggY82WxYQfD3hOa5q/XV9 HInw== X-Gm-Message-State: AE9vXwMMOYHzQSDyCXtrx5yHh8+xpKEE8KqJ8I1ERnBbA0iizdcKMPNn/0KSDzChz0T4LSTO X-Received: by 10.194.17.6 with SMTP id k6mr26558312wjd.65.1474988009512; Tue, 27 Sep 2016 07:53:29 -0700 (PDT) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id t65sm3542521wmt.15.2016.09.27.07.53.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 07:53:28 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Bruce Richardson , Adrien Mazarguil Date: Tue, 27 Sep 2016 16:53:12 +0200 Message-Id: <30739c1ee245c3e3ee9a1122ca08285d718eb9b8.1474987853.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2] net/mlx5: return RSS hash result in mbuf 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: , X-List-Received-Date: Tue, 27 Sep 2016 14:53:31 -0000 Signed-off-by: Nelio Laranjeiro --- doc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5_rxq.c | 1 + drivers/net/mlx5/mlx5_rxtx.c | 21 ++++++++++++++++----- drivers/net/mlx5/mlx5_rxtx.h | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 8923173..0d1fabb 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -88,6 +88,7 @@ Features RTE_ETH_FDIR_REJECT). - Secondary process TX is supported. - KVM and VMware ESX SR-IOV modes are supported. +- RSS hash result is supported. Limitations ----------- diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index f6f4315..d32ad68 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -926,6 +926,7 @@ rxq_ctrl_setup(struct rte_eth_dev *dev, struct rxq_ctrl *rxq_ctrl, .rxq = { .elts_n = log2above(desc), .mp = mp, + .rss_hash = priv->rxqs_n > 1, }, }; struct ibv_exp_wq_attr mod; diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index e0ff47f..d3a427c 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1128,6 +1128,8 @@ rxq_cq_to_pkt_type(volatile struct mlx5_cqe64 *cqe) * Pointer to RX queue. * @param cqe * CQE to process. + * @param[out] rss_hash + * Packet RSS Hash result. * * @return * Packet size in bytes (0 if there is none), -1 in case of completion @@ -1135,7 +1137,7 @@ rxq_cq_to_pkt_type(volatile struct mlx5_cqe64 *cqe) */ static inline int mlx5_rx_poll_len(struct rxq *rxq, volatile struct mlx5_cqe64 *cqe, - uint16_t cqe_cnt) + uint16_t cqe_cnt, uint32_t *rss_hash) { struct rxq_zip *zip = &rxq->zip; uint16_t cqe_n = cqe_cnt + 1; @@ -1148,6 +1150,7 @@ mlx5_rx_poll_len(struct rxq *rxq, volatile struct mlx5_cqe64 *cqe, (uintptr_t)(&(*rxq->cqes)[zip->ca & cqe_cnt].cqe64); len = ntohl((*mc)[zip->ai & 7].byte_cnt); + *rss_hash = ntohl((*mc)[zip->ai & 7].rx_hash_result); if ((++zip->ai & 7) == 0) { /* * Increment consumer index to skip the number of @@ -1202,9 +1205,11 @@ mlx5_rx_poll_len(struct rxq *rxq, volatile struct mlx5_cqe64 *cqe, zip->cq_ci = rxq->cq_ci + zip->cqe_cnt; /* Get packet size to return. */ len = ntohl((*mc)[0].byte_cnt); + *rss_hash = ntohl((*mc)[0].rx_hash_result); zip->ai = 1; } else { len = ntohl(cqe->byte_cnt); + *rss_hash = ntohl(cqe->rx_hash_res); } /* Error while receiving packet. */ if (unlikely(MLX5_CQE_OPCODE(op_own) == MLX5_CQE_RESP_ERR)) @@ -1286,12 +1291,13 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) &(*rxq->cqes)[rxq->cq_ci & cqe_cnt].cqe64; unsigned int i = 0; unsigned int rq_ci = rxq->rq_ci << sges_n; - int len; while (pkts_n) { unsigned int idx = rq_ci & wqe_cnt; volatile struct mlx5_wqe_data_seg *wqe = &(*rxq->wqes)[idx]; struct rte_mbuf *rep = (*rxq->elts)[idx]; + int len; + uint32_t rss_hash_res = 0; if (pkt) NEXT(seg) = rep; @@ -1320,8 +1326,9 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) } if (!pkt) { cqe = &(*rxq->cqes)[rxq->cq_ci & cqe_cnt].cqe64; - len = mlx5_rx_poll_len(rxq, cqe, cqe_cnt); - if (len == 0) { + len = mlx5_rx_poll_len(rxq, cqe, cqe_cnt, + &rss_hash_res); + if (!len) { rte_mbuf_refcnt_set(rep, 0); __rte_mbuf_raw_free(rep); break; @@ -1338,12 +1345,16 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) /* Update packet information. */ pkt->packet_type = 0; pkt->ol_flags = 0; + if (rxq->rss_hash) { + pkt->hash.rss = rss_hash_res; + pkt->ol_flags = PKT_RX_RSS_HASH; + } if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip | rxq->crc_present) { if (rxq->csum) { pkt->packet_type = rxq_cq_to_pkt_type(cqe); - pkt->ol_flags = + pkt->ol_flags |= rxq_cq_to_ol_flags(rxq, cqe); } if (cqe->l4_hdr_type_etc & diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 9828aef..e813f38 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -113,6 +113,8 @@ struct rxq { unsigned int cqe_n:4; /* Log 2 of CQ elements. */ unsigned int elts_n:4; /* Log 2 of Mbufs. */ unsigned int port_id:8; + unsigned int rss_hash:1; /* RSS hash result is enabled. */ + unsigned int :9; /* Remaining bits. */ volatile uint32_t *rq_db; volatile uint32_t *cq_db; uint16_t rq_ci; -- 2.1.4