From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730051.outbound.protection.outlook.com [40.107.73.51]) by dpdk.org (Postfix) with ESMTP id 662B01BE49 for ; Sun, 1 Jul 2018 18:47:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wZpxO6M+KNLcSmTM3TaxVIxYpdVexWXNfuU1dmo7S6M=; b=XKh2q1K2NMsxINQcgPCeXvcieg2I5L/H9wTZf/i650+6eTY0Z0rc3WuFLlqsKAdGrOEHbaHkfXRXd21u8fdxUa59Md2ygNrwFDeDZ9mNdp/Lstp56NuxwjWfz2nNLU3AqOEr+MeWhi2m7gKdyXdSGWjQkcok/rugrpN2HHLksYQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3465.namprd07.prod.outlook.com (2603:10b6:4:67::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Sun, 1 Jul 2018 16:47:10 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, rkudurumalla@caviumnetworks.com, ferruh.yigit@intel.com Cc: dev@dpdk.org, "Kudurumalla, Rakesh" , Pavan Nikhilesh Date: Sun, 1 Jul 2018 22:16:37 +0530 Message-Id: <20180701164637.978-1-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::27) To DM5PR07MB3465.namprd07.prod.outlook.com (2603:10b6:4:67::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b0ca0f4-741a-493d-dfb7-08d5df724bae X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:DM5PR07MB3465; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 3:Il36lvDy+Ekb3IiyjVJSpQq1xJBLjlxKnsNhrt+FTskXt1mPKP+cJkZy25YMnDrTLpYxJ1JV2MD66FgftfjbW/7yfvcNbJa36OpoiBxnjzpaMkK3tgJK4Knc0L01ka1XpOOf7qOoX99OH/0Eco3q996AdxkNtkUQY050twb2prBGyOzl6orjrACRHhy15S3rPvEC24MJudKtH1a2PFYSp7XOCrdaOEZxlIxgSfbnMkrmohepacerinLsRJ+FpiPV; 25:u1OHzt0sxkLjfkQqkRVjhTjJDRINLafh0yeGt68XJIvnoUlwtEVUZtFnxqeFtUgAUj5GlEmF5ZaB8dyqX7gQQxgJD+iIL/3VsGqKabmviKiCtCPO07HtBukgcuLK+8SIDpnx/H/kXIhEQKJ3rtrmreJfi/MGc7aXWs/RhAvYMaYNQ8k/amy6H2sH9FR7qoggwvipL9xlfd06aNrI9k5L0fGPH+L79o4yPxNC41rlf8c2Rdc1EGKgru/amYYqxCgxvpY4Azy/r82vmOvAN8HUScCTsl5KqCGPuiO2KWdi0EsEVWZ3aqZTyAtrhB3tISMLVwDoQ8m8Tfy3NdgcWA0sxg==; 31:LsyaEbHvGSVrsO3R2t5HJpBDXxalk029sHuxcpKLMGt1K4lWdRB4PARtnBqFojFl3roZKJgVzjGpNlSLJVqP046u29dKgSfuW9oMrfJjH4OMeB/aB15bPgsLydMpl+X39fcxgdPw3pl7uq7fnQBxGVUMgOMOkIQwti+ORdtePu9DNa1POtCjXILHtIlR4MHDNQVBeQS16XkHUNgxxJ+HnrlpkEFClCorLd9Vl512vLI= X-MS-TrafficTypeDiagnostic: DM5PR07MB3465: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 20:rHk0KYdJ4DFZ3YR1GLTdk0bhQlYLtOHiasSxBXkAh6SAlq3MPYzxolqTgcDJY12AKO/MSiN1tVwUCP71AMG27ghM4U/5U9RxDKa0QjeE102c/tV3ryQZ4bEx5R5T6NisafispVLXsdcP+qrUnrjKu5SCfb85FRZG+g3NgKiW8CpCFYjL8bEW9A4QWJ8wpqvv+/ylrI76cmLCdd/z+lCQ71ScVMbG9OsN0Dq7VKG0CddeUalsGGA2adiEx2kauqhJ0iEPhpRU37rRD7ThHNL1/Zo6m+4Rp9LaqCTKC5M8rIwecfG5Lj1079qMx+/q57cHEwQ5RUINvR8SHZzto21ffNfk8UVug33WcQF7Oo+NccD6m7ltjW0zVU+1fnmLD1jUn8JCA3Xgewzfluhk3/2k+DpuI4ewrFT/FwSjBPMCIdYfRHGDsv2v9UkJBy7Pvr1WBB1rLp1WyMG6AxbUeekLvPX3P9FKyFY/QvZ9barrj7j+JaMsDyhIXzVJeTLHw3vcwM7Gm3XkvHzN7STbakP2NBnPVopkKiYjfX7H5HzSnVouG/Xdl3xmXWaZUBdotkCpJTp7WXk8fWaMrF4W6rKNyblF8+qBqfUino2MTwsDAVc=; 4:rTOZQafxmOdUmpXMjgGYjMJmLzvZAf4jopeXmtWEAlSvsHUsz24ke+Kz9kU4u6TL2lZJzq/XCHC4vu25hNivJ1cHzXup+dXoSfbYfRqOafM4j/ApZEefsP7+EumCcYS/IDFmmNbntgEJClzn2sb3+rG09n84N7eySAQNGGRVPjNdMgylH694dF2vwqHe0Q1xlpHzumfYVBJaB/8BxuVYlnhlyk0j9bau64DPSICBfq57JM/cDOrtQXviXrBLM13YQRUEbWIJtbKi1scl0MOuHw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR07MB3465; BCL:0; PCL:0; RULEID:; SRVR:DM5PR07MB3465; X-Forefront-PRVS: 07200C0526 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(376002)(346002)(396003)(366004)(39850400004)(136003)(189003)(199004)(50226002)(6116002)(4326008)(16586007)(6666003)(2906002)(3846002)(316002)(54906003)(8936002)(72206003)(478600001)(1076002)(107886003)(97736004)(53936002)(66066001)(14444005)(68736007)(25786009)(6512007)(5009440100003)(8676002)(81156014)(5660300001)(50466002)(6506007)(7736002)(386003)(51416003)(2616005)(48376002)(956004)(476003)(81166006)(36756003)(1857600001)(105586002)(106356001)(16526019)(42882007)(6486002)(47776003)(305945005)(26005)(52116002)(486006)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3465; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3465; 23:W8JJqysAJLuwCBM8VAHwT6H3QcX+aayklZ9wTFNHR?= =?us-ascii?Q?JbdYg/Zg7k/4IMufYGxGEyfS9linDv03cVHNM66kSV0Clp/j334665BCM5Xs?= =?us-ascii?Q?UNo4PX/C9yYnn7adAu1DBYKFpqSTeHG7R+VmODB5AJlQurRtSd7n2m4eicoS?= =?us-ascii?Q?qe6nAqgh4zKSKfYgNvnMIkji8Kk/F+2wlwDILC916Us+k/YILCeE1aPn3A2g?= =?us-ascii?Q?+cvCTPVrYu8bXS7BiY8TsXyOHTr2RcxcL+vc0I6ust0yeiMFwoKEYiI4Uzpf?= =?us-ascii?Q?M4MViKMsip8yKeQPzxh32n2FaP29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l2S2OScFrd5apFj8UIHPc5nT9ZAnO6LDyJdDDGWgdWRafp3K99wDfpIrtxTTJxLSgeAfLs/ev291tDReiFr08X+rdASc=; 24:0+lWoOQ8dBCvEKfwTVYjcC6ersXcfdIrgu+5sCyJYvnCek7d6nsdEXttcejh56vpHxZdegixW4BJldZqwg6qFYlrR2LD59rzwM3IwcHKC9I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 7:ETAblPGoqOGK2QAoLoxSYlNZOOlnEFurkfUwr+A85MzU5wFj4d3EXbCHKAFPXQKKMDmMyycne3AMXvh/4Pr7rvpM2eNwKpzveWSW0ycCrdtoxyzxZg9PUaIvaZ8kLiM8cLCZnHrVzsCTROw/LLluChRxxs1ouHQltci4YlMO5pkBfpqgpONyc7+DLkVeMJ8AKaUnO5S2jwifsloDFbwv9pwRB7s9IxoiWjvWL8ZJ42PDcOZF1t6hZItNL7nCrNvv X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2018 16:47:10.6497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b0ca0f4-741a-493d-dfb7-08d5df724bae X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3465 Subject: [dpdk-dev] [PATCH] net/thunderx: add support for Rx VLAN offload X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jul 2018 16:47:16 -0000 From: "Kudurumalla, Rakesh" This feature is used to offload stripping of vlan header from recevied packets and update vlan_tci field in mbuf when DEV_RX_OFFLOAD_VLAN_STRIP & ETH_VLAN_STRIP_MASK flag is set. Signed-off-by: Rakesh Kudurumalla Signed-off-by: Pavan Nikhilesh --- drivers/net/thunderx/base/nicvf_hw.c | 1 + drivers/net/thunderx/nicvf_ethdev.c | 59 +++++++++++++++++------ drivers/net/thunderx/nicvf_rxtx.c | 70 ++++++++++++++++++++++++---- drivers/net/thunderx/nicvf_rxtx.h | 15 ++++-- drivers/net/thunderx/nicvf_struct.h | 1 + 5 files changed, 119 insertions(+), 27 deletions(-) diff --git a/drivers/net/thunderx/base/nicvf_hw.c b/drivers/net/thunderx/base/nicvf_hw.c index b07a2937d..5b1abe201 100644 --- a/drivers/net/thunderx/base/nicvf_hw.c +++ b/drivers/net/thunderx/base/nicvf_hw.c @@ -699,6 +699,7 @@ nicvf_vlan_hw_strip(struct nicvf *nic, bool enable) else val &= ~((STRIP_SECOND_VLAN | STRIP_FIRST_VLAN) << 25); + nic->vlan_strip = enable; nicvf_reg_write(nic, NIC_VNIC_RQ_GEN_CFG, val); } diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 76fed9f99..4f58b2e33 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -52,6 +52,8 @@ static void nicvf_dev_stop(struct rte_eth_dev *dev); static void nicvf_dev_stop_cleanup(struct rte_eth_dev *dev, bool cleanup); static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, bool cleanup); +static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask); +static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask); RTE_INIT(nicvf_init_log); static void @@ -357,11 +359,9 @@ nicvf_dev_supported_ptypes_get(struct rte_eth_dev *dev) } memcpy((char *)ptypes + copied, &ptypes_end, sizeof(ptypes_end)); - if (dev->rx_pkt_burst == nicvf_recv_pkts || - dev->rx_pkt_burst == nicvf_recv_pkts_multiseg) - return ptypes; - return NULL; + /* All Ptypes are supported in all Rx functions. */ + return ptypes; } static void @@ -918,13 +918,18 @@ nicvf_set_tx_function(struct rte_eth_dev *dev) static void nicvf_set_rx_function(struct rte_eth_dev *dev) { - if (dev->data->scattered_rx) { - PMD_DRV_LOG(DEBUG, "Using multi-segment rx callback"); - dev->rx_pkt_burst = nicvf_recv_pkts_multiseg; - } else { - PMD_DRV_LOG(DEBUG, "Using single-segment rx callback"); - dev->rx_pkt_burst = nicvf_recv_pkts; - } + struct nicvf *nic = nicvf_pmd_priv(dev); + + const eth_rx_burst_t rx_burst_func[2][2] = { + /* [NORMAL/SCATTER] [VLAN_STRIP/NO_VLAN_STRIP] */ + [0][0] = nicvf_recv_pkts_no_offload, + [0][1] = nicvf_recv_pkts_vlan_strip, + [1][0] = nicvf_recv_pkts_multiseg_no_offload, + [1][1] = nicvf_recv_pkts_multiseg_vlan_strip, + }; + + dev->rx_pkt_burst = + rx_burst_func[dev->data->scattered_rx][nic->vlan_strip]; } static int @@ -1469,7 +1474,7 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz) struct rte_mbuf *mbuf; uint16_t rx_start, rx_end; uint16_t tx_start, tx_end; - bool vlan_strip; + int mask; PMD_INIT_FUNC_TRACE(); @@ -1590,9 +1595,9 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz) nic->rbdr->tail, nb_rbdr_desc, nic->vf_id); /* Configure VLAN Strip */ - vlan_strip = !!(dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_VLAN_STRIP); - nicvf_vlan_hw_strip(nic, vlan_strip); + mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | + ETH_VLAN_EXTEND_MASK; + ret = nicvf_vlan_offload_config(dev, mask); /* Based on the packet type(IPv4 or IPv6), the nicvf HW aligns L3 data * to the 64bit memory address. @@ -1983,6 +1988,7 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_infos_get = nicvf_dev_info_get, .dev_supported_ptypes_get = nicvf_dev_supported_ptypes_get, .mtu_set = nicvf_dev_set_mtu, + .vlan_offload_set = nicvf_vlan_offload_set, .reta_update = nicvf_dev_reta_update, .reta_query = nicvf_dev_reta_query, .rss_hash_update = nicvf_dev_rss_hash_update, @@ -1999,6 +2005,29 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .get_reg = nicvf_dev_get_regs, }; +static int +nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask) +{ + struct rte_eth_rxmode *rxmode; + struct nicvf *nic = nicvf_pmd_priv(dev); + rxmode = &dev->data->dev_conf.rxmode; + if (mask & ETH_VLAN_STRIP_MASK) { + if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) + nicvf_vlan_hw_strip(nic, true); + else + nicvf_vlan_hw_strip(nic, false); + } + return 0; +} + +static int +nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask) +{ + nicvf_vlan_offload_config(dev, mask); + + return 0; +} + static inline int nicvf_set_first_skip(struct rte_eth_dev *dev) { diff --git a/drivers/net/thunderx/nicvf_rxtx.c b/drivers/net/thunderx/nicvf_rxtx.c index 72305d9d2..9454e6455 100644 --- a/drivers/net/thunderx/nicvf_rxtx.c +++ b/drivers/net/thunderx/nicvf_rxtx.c @@ -388,8 +388,9 @@ nicvf_rx_offload(cqe_rx_word0_t cqe_rx_w0, cqe_rx_word2_t cqe_rx_w2, } } -uint16_t __hot -nicvf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) +static __rte_always_inline uint16_t +nicvf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, + const uint16_t flag) { uint32_t i, to_process; struct cqe_rx_t *cqe_rx; @@ -420,7 +421,18 @@ nicvf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rb0_ptr = *((uint64_t *)cqe_rx + rbptr_offset); pkt = (struct rte_mbuf *)nicvf_mbuff_phy2virt (rb0_ptr - cqe_rx_w1.align_pad, mbuf_phys_off); - pkt->ol_flags = 0; + + if (flag & NICVF_RX_OFFLOAD_NONE) + pkt->ol_flags = 0; + if (flag & NICVF_RX_OFFLOAD_VLAN_STRIP) { + if (unlikely(cqe_rx_w0.vlan_stripped)) { + pkt->ol_flags |= PKT_RX_VLAN + | PKT_RX_VLAN_STRIPPED; + pkt->vlan_tci = + rte_cpu_to_be_16(cqe_rx_w2.vlan_tci); + } + } + pkt->data_len = cqe_rx_w3.rb0_sz; pkt->pkt_len = cqe_rx_w3.rb0_sz; pkt->packet_type = nicvf_rx_classify_pkt(cqe_rx_w0); @@ -445,11 +457,27 @@ nicvf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) return to_process; } -static inline uint16_t __hot +uint16_t __hot +nicvf_recv_pkts_no_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return nicvf_recv_pkts(rx_queue, rx_pkts, nb_pkts, + NICVF_RX_OFFLOAD_NONE); +} + +uint16_t __hot +nicvf_recv_pkts_vlan_strip(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return nicvf_recv_pkts(rx_queue, rx_pkts, nb_pkts, + NICVF_RX_OFFLOAD_NONE | NICVF_RX_OFFLOAD_VLAN_STRIP); +} + +static __rte_always_inline uint16_t nicvf_process_cq_mseg_entry(struct cqe_rx_t *cqe_rx, uint64_t mbuf_phys_off, struct rte_mbuf **rx_pkt, uint8_t rbptr_offset, - uint64_t mbuf_init) + uint64_t mbuf_init, const uint16_t flag) { struct rte_mbuf *pkt, *seg, *prev; cqe_rx_word0_t cqe_rx_w0; @@ -467,12 +495,20 @@ nicvf_process_cq_mseg_entry(struct cqe_rx_t *cqe_rx, pkt = (struct rte_mbuf *)nicvf_mbuff_phy2virt (rb_ptr[0] - cqe_rx_w1.align_pad, mbuf_phys_off); - pkt->ol_flags = 0; pkt->pkt_len = cqe_rx_w1.pkt_len; pkt->data_len = rb_sz[nicvf_frag_num(0)]; nicvf_mbuff_init_mseg_update( pkt, mbuf_init, cqe_rx_w1.align_pad, nb_segs); pkt->packet_type = nicvf_rx_classify_pkt(cqe_rx_w0); + if (flag & NICVF_RX_OFFLOAD_NONE) + pkt->ol_flags = 0; + if (flag & NICVF_RX_OFFLOAD_VLAN_STRIP) { + if (unlikely(cqe_rx_w0.vlan_stripped)) { + pkt->ol_flags |= PKT_RX_VLAN + | PKT_RX_VLAN_STRIPPED; + pkt->vlan_tci = rte_cpu_to_be_16(cqe_rx_w2.vlan_tci); + } + } nicvf_rx_offload(cqe_rx_w0, cqe_rx_w2, pkt); *rx_pkt = pkt; @@ -491,9 +527,9 @@ nicvf_process_cq_mseg_entry(struct cqe_rx_t *cqe_rx, return nb_segs; } -uint16_t __hot +static __rte_always_inline uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) + uint16_t nb_pkts, const uint16_t flag) { union cq_entry_t *cq_entry; struct cqe_rx_t *cqe_rx; @@ -515,7 +551,7 @@ nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, cq_entry = &desc[cqe_head]; cqe_rx = (struct cqe_rx_t *)cq_entry; nb_segs = nicvf_process_cq_mseg_entry(cqe_rx, mbuf_phys_off, - rx_pkts + i, rbptr_offset, mbuf_init); + rx_pkts + i, rbptr_offset, mbuf_init, flag); buffers_consumed += nb_segs; cqe_head = (cqe_head + 1) & cqe_mask; nicvf_prefetch_store_keep(rx_pkts[i]); @@ -535,6 +571,22 @@ nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, return to_process; } +uint16_t __hot +nicvf_recv_pkts_multiseg_no_offload(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return nicvf_recv_pkts_multiseg(rx_queue, rx_pkts, nb_pkts, + NICVF_RX_OFFLOAD_NONE); +} + +uint16_t __hot +nicvf_recv_pkts_multiseg_vlan_strip(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts) +{ + return nicvf_recv_pkts_multiseg(rx_queue, rx_pkts, nb_pkts, + NICVF_RX_OFFLOAD_NONE | NICVF_RX_OFFLOAD_VLAN_STRIP); +} + uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx) { diff --git a/drivers/net/thunderx/nicvf_rxtx.h b/drivers/net/thunderx/nicvf_rxtx.h index 8bdd582ed..cb309782e 100644 --- a/drivers/net/thunderx/nicvf_rxtx.h +++ b/drivers/net/thunderx/nicvf_rxtx.h @@ -8,6 +8,9 @@ #include #include +#define NICVF_RX_OFFLOAD_NONE 0x1 +#define NICVF_RX_OFFLOAD_VLAN_STRIP 0x2 + #define NICVF_TX_OFFLOAD_MASK (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK) #ifndef __hot @@ -86,9 +89,15 @@ nicvf_mbuff_init_mseg_update(struct rte_mbuf *pkt, const uint64_t mbuf_init, uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx); uint32_t nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx); -uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts); -uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts); +uint16_t nicvf_recv_pkts_no_offload(void *rxq, struct rte_mbuf **rx_pkts, + uint16_t pkts); +uint16_t nicvf_recv_pkts_vlan_strip(void *rx_queue, struct rte_mbuf **rx_pkts, + uint16_t nb_pkts); + +uint16_t nicvf_recv_pkts_multiseg_no_offload(void *rx_queue, + struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t nicvf_recv_pkts_multiseg_vlan_strip(void *rx_queue, + struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t nicvf_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts, uint16_t pkts); uint16_t nicvf_xmit_pkts_multiseg(void *txq, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/thunderx/nicvf_struct.h b/drivers/net/thunderx/nicvf_struct.h index cf98f7c1a..6dfbeb8ee 100644 --- a/drivers/net/thunderx/nicvf_struct.h +++ b/drivers/net/thunderx/nicvf_struct.h @@ -85,6 +85,7 @@ struct nicvf { bool loopback_supported; bool pf_acked:1; bool pf_nacked:1; + bool vlan_strip:1; uint64_t hwcap; uint8_t link_up; uint8_t duplex; -- 2.18.0