From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3406CA0577; Mon, 6 Apr 2020 12:09:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 08C231BEE3; Mon, 6 Apr 2020 12:09:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 2001C1BED9 for ; Mon, 6 Apr 2020 12:09:17 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 036A5kKP012517; Mon, 6 Apr 2020 03:09:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=pfpt0818; bh=t3y4fgjhTixbfzSmGCroDMBGnAPV9TEAtpCIhmRyWEk=; b=Ose2R9qeNuPm9s7RpHKArfZT6yBqnUWSyyhHKf/eLtfajSPqounmLdnkapNvHHyc6i0t Ngk5GMDIPMA6TLaxXa28C4G3GDLuBftdgiVOagc89cKJM52Tx43O9XfbLBujtHEdORD0 jS7dFo5oiZRNhvNwgAai/AiTfqOjyt381NCMvOvJIzN6pQTlO5ky9wz0qjauKeiALIei zodOx9r2qy/26Ya+zz+PqM0/JVfWCSP67SSoIr9SgJuNGowLs9wBCzN6dCm90K7248os um6zL8+8/TiysWk5PjbQ+/bHjLfw0IHuLidhamb4lVAzDN1Sy9S0mFkqVIoj+A98XYDQ 1A== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 306srm53qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2020 03:09:16 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Apr 2020 03:09:14 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Mon, 6 Apr 2020 03:09:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mYIbScfd/GItEd5A/u8WVMAAcbcJzLgLz7sDkQ9rDHlxDZj71uA1+QgkUgik+5JAKgKpQybmYptKL5cWaMpr0OCiRajLuHJBNNyb36kYn6Fk4kjBtqgfMkrnAZWwFRc82sGlgd19p/Mw3ynmA8syREsg5WorTOHPESyUIQS4eZPDEMMHBgvP4GZgpt/wtCiHuX20A8ImDMa/1zZK6Qf6q3VFwD0Gd9zLxKcQ+lMMRlCvYGYbo6Syr0wg4GgYPDaqhy5iezxBTb9GidI3M13J8yTjUJ+5FvxV8izbIXr0BS0aDhUn7K2+tT11ECIKp9lX/pvOMWzl6K5bnB4/yQdXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t3y4fgjhTixbfzSmGCroDMBGnAPV9TEAtpCIhmRyWEk=; b=OrVjP8o4HPEWqHQNeyLLWLBhiQLd6YGta7w1qD9qRZ0NnY4jYY3ixNMjs1v2Vok6pRp8hYhG87qhVM1DNsmXh47hCzCQ85CynB/qvnpXWSovn+zMlOHglsbx8mBauXlghzqNhGuAEdvFnAs5c+2CgydmSl/97tUtOPboKIZrF/M6rQW12LvUXepKBEHPj3s7eAwX3yiqC/QBLMp57B42m5+r0vx8Sj3GSyaPK1Xv+VVc4bZddI6F1BYu4BJr5vzS6g8Cv7i9CHPvBV7k1/5/phK69rkClJAZUavqnUfw1mDZGymn3tqIuAiah02tnxKiwiy92Yw5SgOUtyFBXksyIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t3y4fgjhTixbfzSmGCroDMBGnAPV9TEAtpCIhmRyWEk=; b=TXc4m7PYeJkzdvjf78QrsTj3V8dJQDZJOfiGm/bRhja4leJaQFEWn9CGX+eg4Bs8OCype5ilTyDPQ4OPg1ot7xaapjuybWFtmY5iByVY0jjgzq2QxsfmufASNyJTYuqv6Uj3pfrEUJx2vFCXWtxCZvTXv5RFYM3khMiPGBt0THU= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) by MN2PR18MB3261.namprd18.prod.outlook.com (2603:10b6:208:16c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Mon, 6 Apr 2020 10:09:12 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8b1:45c4:b84:9c02]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8b1:45c4:b84:9c02%7]) with mapi id 15.20.2878.021; Mon, 6 Apr 2020 10:09:12 +0000 Date: Mon, 6 Apr 2020 15:39:02 +0530 From: Harman Kalra To: , , CC: , Message-ID: <20200406100901.GB177055@outlook.office365.com> References: <1584351224-23500-1-git-send-email-hkalra@marvell.com> <1584351224-23500-6-git-send-email-hkalra@marvell.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1584351224-23500-6-git-send-email-hkalra@marvell.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-ClientProxiedBy: PN1PR0101CA0037.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::23) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from outlook.office365.com (115.113.156.2) by PN1PR0101CA0037.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15 via Frontend Transport; Mon, 6 Apr 2020 10:09:10 +0000 X-Originating-IP: [115.113.156.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bcf21d5-510a-4349-0cb8-08d7da128e0c X-MS-TrafficTypeDiagnostic: MN2PR18MB3261: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:161; X-Forefront-PRVS: 0365C0E14B X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR18MB2848.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(396003)(39860400002)(366004)(346002)(136003)(316002)(107886003)(66556008)(6506007)(26005)(55236004)(186003)(66946007)(86362001)(5660300002)(4326008)(66476007)(478600001)(6666004)(8936002)(81156014)(30864003)(16526019)(1076003)(956004)(81166006)(55016002)(33656002)(9686003)(8676002)(7696005)(2906002)(52116002); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LDLWSGQ0E+B+EUAcD+HxQgBtYSN6esjQg8awly51uxZFmAow0xjuw0fINNaoseeTJLODrpkbCBa13HtRULByhQpD+rhTVA5+5D8MqY971OKGZBtVP6tFd+NSraoleSYChttZYmvFSnXOdyIuhUeNAZWDa14HkkA90IYpzJUse05zmKbUWzUcNqD0yIQbqnlhnm27/3Sfah/uXPPgO6yzlDiVlMCXvOL0g8td8gMXqjcVY7A5dmU7hqUsAe8E2/JnEJHhXzWn4VuGLq3a/isW3FOEa4kIwvqj7V7AN7+njTMcoxlZeXclDPLQF0mujHYObPpplfg+0T7X94C8UNc0PVmM8TFwH6QNk5mwZjfpcwRcmWligo0dahp4el3pKVFEcIJ51dZJ9aGRSJidj8fjmAkmq6uD04N9b9psjB+7poJIovrqbnXbtvcCGIoSyOO4 X-MS-Exchange-AntiSpam-MessageData: hwJ05e0wIet/nQhrVR7UIzQVNfq2hRSMF+a8fX2k7V5HVHtE4u+byuRG4K17jAK+TfG1i7aVV6MAE2L+1jRwouOuEXQH6wzaNhRqKOI6HG43n2MbMusIlKPQe+Ms8G88VW2bT2pvsDbuvWFjB9O0og== X-MS-Exchange-CrossTenant-Network-Message-Id: 1bcf21d5-510a-4349-0cb8-08d7da128e0c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2020 10:09:12.6833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EGdyZt13zZEjZMwYLcEuByKl0adEvOrGjP/TrT1HydTyVN7lsXLHMrKBr1MM37M+mDMZuj516fC8nPj+0V2zBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3261 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-06_05:2020-04-06, 2020-04-06 signatures=0 Subject: Re: [dpdk-dev] [PATCH 5/8] net/octeontx: add VLAN filter offload support 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Mar 16, 2020 at 03:03:41PM +0530, Harman Kalra wrote: > From: Vamsi Attunuru > > Patch adds support for vlan filter offload support. > MBOX messages for vlan filter on/off and vlan filter > entry add/rm are added to configure PCAM entries to > filter out the vlan traffic on a given port. > > Patch also defines rx_offload_flag for vlan filtering. > > Signed-off-by: Vamsi Attunuru Acked-by: Harman Kalra > --- > doc/guides/nics/features/octeontx.ini | 2 + > doc/guides/nics/octeontx.rst | 1 + > drivers/net/octeontx/Makefile | 1 + > drivers/net/octeontx/base/octeontx_pkivf.c | 40 +++++ > drivers/net/octeontx/base/octeontx_pkivf.h | 20 +++ > drivers/net/octeontx/meson.build | 3 +- > drivers/net/octeontx/octeontx_ethdev.c | 10 ++ > drivers/net/octeontx/octeontx_ethdev.h | 24 ++- > drivers/net/octeontx/octeontx_ethdev_ops.c | 184 +++++++++++++++++++++ > drivers/net/octeontx/octeontx_rxtx.h | 1 + > 10 files changed, 284 insertions(+), 2 deletions(-) > create mode 100644 drivers/net/octeontx/octeontx_ethdev_ops.c > > diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini > index e3ee79f0f..53c541f4b 100644 > --- a/doc/guides/nics/features/octeontx.ini > +++ b/doc/guides/nics/features/octeontx.ini > @@ -13,6 +13,8 @@ Jumbo frame = Y > Scattered Rx = Y > Promiscuous mode = Y > Unicast MAC filter = Y > +VLAN filter = Y > +VLAN offload = P > CRC offload = Y > Packet type parsing = Y > Basic stats = Y > diff --git a/doc/guides/nics/octeontx.rst b/doc/guides/nics/octeontx.rst > index ddb626bc3..c8655bf37 100644 > --- a/doc/guides/nics/octeontx.rst > +++ b/doc/guides/nics/octeontx.rst > @@ -22,6 +22,7 @@ Features of the OCTEON TX Ethdev PMD are: > - Jumbo frames > - Scatter-Gather IO support > - Link state information > +- MAC/VLAN filtering > - MTU update > - SR-IOV VF > - Multiple queues for TX > diff --git a/drivers/net/octeontx/Makefile b/drivers/net/octeontx/Makefile > index 8ddfc3089..694f403f1 100644 > --- a/drivers/net/octeontx/Makefile > +++ b/drivers/net/octeontx/Makefile > @@ -28,6 +28,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkovf.c > SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkivf.c > SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_bgx.c > SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_ethdev.c > +SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_ethdev_ops.c > > ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) > CFLAGS_octeontx_rxtx.o += -fno-prefetch-loop-arrays > diff --git a/drivers/net/octeontx/base/octeontx_pkivf.c b/drivers/net/octeontx/base/octeontx_pkivf.c > index 8ce041955..0ddff5488 100644 > --- a/drivers/net/octeontx/base/octeontx_pkivf.c > +++ b/drivers/net/octeontx/base/octeontx_pkivf.c > @@ -136,6 +136,46 @@ octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg) > return res; > } > > +int > +octeontx_pki_port_vlan_fltr_config(int port, > + pki_port_vlan_filter_config_t *fltr_cfg) > +{ > + struct octeontx_mbox_hdr hdr; > + int res; > + > + pki_port_vlan_filter_config_t cfg = *fltr_cfg; > + int len = sizeof(pki_port_vlan_filter_config_t); > + > + hdr.coproc = OCTEONTX_PKI_COPROC; > + hdr.msg = MBOX_PKI_PORT_VLAN_FILTER_CONFIG; > + hdr.vfid = port; > + > + res = octeontx_mbox_send(&hdr, &cfg, len, NULL, 0); > + if (res < 0) > + return -EACCES; > + return res; > +} > + > +int > +octeontx_pki_port_vlan_fltr_entry_config(int port, > + pki_port_vlan_filter_entry_config_t *e_cfg) > +{ > + struct octeontx_mbox_hdr hdr; > + int res; > + > + pki_port_vlan_filter_entry_config_t cfg = *e_cfg; > + int len = sizeof(pki_port_vlan_filter_entry_config_t); > + > + hdr.coproc = OCTEONTX_PKI_COPROC; > + hdr.msg = MBOX_PKI_PORT_VLAN_FILTER_ENTRY_CONFIG; > + hdr.vfid = port; > + > + res = octeontx_mbox_send(&hdr, &cfg, len, NULL, 0); > + if (res < 0) > + return -EACCES; > + return res; > +} > + > #define PCI_VENDOR_ID_CAVIUM 0x177D > #define PCI_DEVICE_ID_OCTEONTX_PKI_VF 0xA0DD > > diff --git a/drivers/net/octeontx/base/octeontx_pkivf.h b/drivers/net/octeontx/base/octeontx_pkivf.h > index d541dc3bd..d41eaa57e 100644 > --- a/drivers/net/octeontx/base/octeontx_pkivf.h > +++ b/drivers/net/octeontx/base/octeontx_pkivf.h > @@ -36,6 +36,8 @@ > #define MBOX_PKI_PORT_ALLOC_QPG 21 > #define MBOX_PKI_PORT_FREE_QPG 22 > #define MBOX_PKI_SET_PORT_CONFIG 23 > +#define MBOX_PKI_PORT_VLAN_FILTER_CONFIG 24 > +#define MBOX_PKI_PORT_VLAN_FILTER_ENTRY_CONFIG 25 > > #define MBOX_PKI_MAX_QOS_ENTRY 64 > > @@ -236,6 +238,20 @@ typedef struct pki_port_modify_qos_entry { > struct pki_qos_entry qos_entry; > } pki_mod_qos_t; > > +/* pki port VLAN filter config */ > +typedef struct pki_port_vlan_filter_config { > + uint8_t port_type; /* OCTTX_PORT_TYPE_[NET/INT/PCI] */ > + uint8_t fltr_conf; /* '1' to enable & '0' to disable */ > +} pki_port_vlan_filter_config_t; > + > +/* pki port VLAN filter entry config */ > +typedef struct pki_port_vlan_filter_entry_config { > + uint8_t port_type; /* OCTTX_PORT_TYPE_[NET/INT/PCI] */ > + uint8_t entry_conf; /* '1' to add & '0' to remove */ > + uint16_t vlan_tpid; /* in host byte-order */ > + uint16_t vlan_id; /* in host byte-order */ > +} pki_port_vlan_filter_entry_config_t; > + > static inline int > octeontx_pki_port_modify_qos(int port, pki_mod_qos_t *qos_cfg) > { > @@ -348,5 +364,9 @@ int octeontx_pki_port_pktbuf_config(int port, pki_pktbuf_cfg_t *buf_cfg); > int octeontx_pki_port_create_qos(int port, pki_qos_cfg_t *qos_cfg); > int octeontx_pki_port_close(int port); > int octeontx_pki_port_errchk_config(int port, pki_errchk_cfg_t *cfg); > +int octeontx_pki_port_vlan_fltr_config(int port, > + pki_port_vlan_filter_config_t *fltr_cfg); > +int octeontx_pki_port_vlan_fltr_entry_config(int port, > + pki_port_vlan_filter_entry_config_t *entry_cfg); > > #endif /* __OCTEONTX_PKI_H__ */ > diff --git a/drivers/net/octeontx/meson.build b/drivers/net/octeontx/meson.build > index 0e249eb98..f7ba6e68b 100644 > --- a/drivers/net/octeontx/meson.build > +++ b/drivers/net/octeontx/meson.build > @@ -5,7 +5,8 @@ subdir('base') > objs = [base_objs] > > sources = files('octeontx_rxtx.c', > - 'octeontx_ethdev.c' > + 'octeontx_ethdev.c', > + 'octeontx_ethdev_ops.c' > ) > > allow_experimental_apis = true > diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c > index 91b9ea645..5dd40bc04 100644 > --- a/drivers/net/octeontx/octeontx_ethdev.c > +++ b/drivers/net/octeontx/octeontx_ethdev.c > @@ -360,6 +360,12 @@ octeontx_dev_configure(struct rte_eth_dev *dev) > return -EFAULT; > } > > + ret = octeontx_dev_vlan_offload_init(dev); > + if (ret) { > + octeontx_log_err("failed to initialize vlan offload"); > + return -EFAULT; > + } > + > nic->pki.classifier_enable = false; > nic->pki.hash_enable = true; > nic->pki.initialized = false; > @@ -384,6 +390,8 @@ octeontx_dev_close(struct rte_eth_dev *dev) > > rte_event_dev_close(nic->evdev); > > + octeontx_dev_vlan_offload_fini(dev); > + > ret = octeontx_pko_channel_close(nic->base_ochan); > if (ret < 0) { > octeontx_log_err("failed to close channel %d VF%d %d %d", > @@ -1185,6 +1193,8 @@ static const struct eth_dev_ops octeontx_dev_ops = { > .mac_addr_remove = octeontx_dev_mac_addr_del, > .mac_addr_add = octeontx_dev_mac_addr_add, > .mac_addr_set = octeontx_dev_default_mac_addr_set, > + .vlan_offload_set = octeontx_dev_vlan_offload_set, > + .vlan_filter_set = octeontx_dev_vlan_filter_set, > .tx_queue_start = octeontx_dev_tx_queue_start, > .tx_queue_stop = octeontx_dev_tx_queue_stop, > .tx_queue_setup = octeontx_dev_tx_queue_setup, > diff --git a/drivers/net/octeontx/octeontx_ethdev.h b/drivers/net/octeontx/octeontx_ethdev.h > index 27f6556dd..e7e0d40c7 100644 > --- a/drivers/net/octeontx/octeontx_ethdev.h > +++ b/drivers/net/octeontx/octeontx_ethdev.h > @@ -55,7 +55,8 @@ > > #define OCTEONTX_RX_OFFLOADS (DEV_RX_OFFLOAD_CHECKSUM | \ > DEV_RX_OFFLOAD_SCATTER | \ > - DEV_RX_OFFLOAD_JUMBO_FRAME) > + DEV_RX_OFFLOAD_JUMBO_FRAME | \ > + DEV_RX_OFFLOAD_VLAN_FILTER) > > #define OCTEONTX_TX_OFFLOADS (DEV_TX_OFFLOAD_MT_LOCKFREE | \ > DEV_TX_OFFLOAD_MBUF_FAST_FREE | \ > @@ -70,6 +71,18 @@ octeontx_pmd_priv(struct rte_eth_dev *dev) > extern uint16_t > rte_octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX]; > > +struct vlan_entry { > + TAILQ_ENTRY(vlan_entry) next; > + uint16_t vlan_id; > +}; > + > +TAILQ_HEAD(octeontx_vlan_filter_tbl, vlan_entry); > + > +struct octeontx_vlan_info { > + struct octeontx_vlan_filter_tbl fltr_tbl; > + uint8_t filter_on; > +}; > + > /* Octeontx ethdev nic */ > struct octeontx_nic { > struct rte_eth_dev *dev; > @@ -107,6 +120,7 @@ struct octeontx_nic { > uint16_t rx_offload_flags; > uint64_t tx_offloads; > uint16_t tx_offload_flags; > + struct octeontx_vlan_info vlan_info; > } __rte_cache_aligned; > > struct octeontx_txq { > @@ -127,4 +141,12 @@ struct octeontx_rxq { > > void > octeontx_set_tx_function(struct rte_eth_dev *dev); > + > +/* VLAN */ > +int octeontx_dev_vlan_offload_init(struct rte_eth_dev *dev); > +int octeontx_dev_vlan_offload_fini(struct rte_eth_dev *eth_dev); > +int octeontx_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask); > +int octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, > + uint16_t vlan_id, int on); > + > #endif /* __OCTEONTX_ETHDEV_H__ */ > diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c > new file mode 100644 > index 000000000..8c3065542 > --- /dev/null > +++ b/drivers/net/octeontx/octeontx_ethdev_ops.c > @@ -0,0 +1,184 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(C) 2020 Marvell International Ltd. > + */ > + > +#include > + > +#include "octeontx_ethdev.h" > +#include "octeontx_logs.h" > +#include "octeontx_rxtx.h" > + > +static int > +octeontx_vlan_hw_filter(struct octeontx_nic *nic, uint8_t flag) > +{ > + struct octeontx_vlan_info *vlan = &nic->vlan_info; > + pki_port_vlan_filter_config_t fltr_conf; > + int rc = 0; > + > + if (vlan->filter_on == flag) > + return rc; > + > + fltr_conf.port_type = OCTTX_PORT_TYPE_NET; > + fltr_conf.fltr_conf = flag; > + > + rc = octeontx_pki_port_vlan_fltr_config(nic->port_id, &fltr_conf); > + if (rc != 0) { > + octeontx_log_err("Fail to configure vlan hw filter for port %d", > + nic->port_id); > + goto done; > + } > + > + vlan->filter_on = flag; > + > +done: > + return rc; > +} > + > +int > +octeontx_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask) > +{ > + struct octeontx_nic *nic = octeontx_pmd_priv(dev); > + struct rte_eth_rxmode *rxmode; > + int rc = 0; > + > + rxmode = &dev->data->dev_conf.rxmode; > + > + if (mask & ETH_VLAN_EXTEND_MASK) { > + octeontx_log_err("Extend offload not supported"); > + return -ENOTSUP; > + } > + > + if (mask & ETH_VLAN_STRIP_MASK) { > + octeontx_log_err("VLAN strip offload not supported"); > + return -ENOTSUP; > + } > + > + if (mask & ETH_VLAN_FILTER_MASK) { > + if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER) { > + rc = octeontx_vlan_hw_filter(nic, true); > + if (rc) > + goto done; > + > + nic->rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; > + nic->rx_offload_flags |= OCCTX_RX_VLAN_FLTR_F; > + } else { > + rc = octeontx_vlan_hw_filter(nic, false); > + if (rc) > + goto done; > + > + nic->rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; > + nic->rx_offload_flags &= ~OCCTX_RX_VLAN_FLTR_F; > + } > + } > + > +done: > + return rc; > +} > + > +int > +octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) > +{ > + struct octeontx_nic *nic = octeontx_pmd_priv(dev); > + struct octeontx_vlan_info *vlan = &nic->vlan_info; > + pki_port_vlan_filter_entry_config_t fltr_entry; > + struct vlan_entry *entry = NULL; > + int entry_count = 0; > + int rc = -EINVAL; > + > + if (on) { > + TAILQ_FOREACH(entry, &vlan->fltr_tbl, next) > + if (entry->vlan_id == vlan_id) { > + octeontx_log_dbg("Vlan Id is already set"); > + return 0; > + } > + } else { > + TAILQ_FOREACH(entry, &vlan->fltr_tbl, next) > + entry_count++; > + > + if (!entry_count) > + return 0; > + } > + > + fltr_entry.port_type = OCTTX_PORT_TYPE_NET; > + fltr_entry.vlan_tpid = RTE_ETHER_TYPE_VLAN; > + fltr_entry.vlan_id = vlan_id; > + fltr_entry.entry_conf = on; > + > + if (on) { > + entry = rte_zmalloc("octeontx_nic_vlan_entry", > + sizeof(struct vlan_entry), 0); > + if (!entry) { > + octeontx_log_err("Failed to allocate memory"); > + return -ENOMEM; > + } > + } > + > + rc = octeontx_pki_port_vlan_fltr_entry_config(nic->port_id, > + &fltr_entry); > + if (rc != 0) { > + octeontx_log_err("Fail to configure vlan filter entry " > + "for port %d", nic->port_id); > + if (entry) > + rte_free(entry); > + > + goto done; > + } > + > + if (on) { > + entry->vlan_id = vlan_id; > + TAILQ_INSERT_HEAD(&vlan->fltr_tbl, entry, next); > + } else { > + TAILQ_FOREACH(entry, &vlan->fltr_tbl, next) { > + if (entry->vlan_id == vlan_id) { > + TAILQ_REMOVE(&vlan->fltr_tbl, entry, next); > + rte_free(entry); > + break; > + } > + } > + } > + > +done: > + return rc; > +} > + > +int > +octeontx_dev_vlan_offload_init(struct rte_eth_dev *dev) > +{ > + struct octeontx_nic *nic = octeontx_pmd_priv(dev); > + int rc; > + > + TAILQ_INIT(&nic->vlan_info.fltr_tbl); > + > + rc = octeontx_dev_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK); > + if (rc) > + octeontx_log_err("Failed to set vlan offload rc=%d", rc); > + > + return rc; > +} > + > +int > +octeontx_dev_vlan_offload_fini(struct rte_eth_dev *dev) > +{ > + struct octeontx_nic *nic = octeontx_pmd_priv(dev); > + struct octeontx_vlan_info *vlan = &nic->vlan_info; > + pki_port_vlan_filter_entry_config_t fltr_entry; > + struct vlan_entry *entry; > + int rc = 0; > + > + TAILQ_FOREACH(entry, &vlan->fltr_tbl, next) { > + fltr_entry.port_type = OCTTX_PORT_TYPE_NET; > + fltr_entry.vlan_tpid = RTE_ETHER_TYPE_VLAN; > + fltr_entry.vlan_id = entry->vlan_id; > + fltr_entry.entry_conf = 0; > + > + rc = octeontx_pki_port_vlan_fltr_entry_config(nic->port_id, > + &fltr_entry); > + if (rc != 0) { > + octeontx_log_err("Fail to configure vlan filter entry " > + "for port %d", nic->port_id); > + break; > + } > + } > + > + return rc; > +} > diff --git a/drivers/net/octeontx/octeontx_rxtx.h b/drivers/net/octeontx/octeontx_rxtx.h > index 2383a8eb6..cc044dd79 100644 > --- a/drivers/net/octeontx/octeontx_rxtx.h > +++ b/drivers/net/octeontx/octeontx_rxtx.h > @@ -19,6 +19,7 @@ > > #define OCCTX_RX_OFFLOAD_NONE (0) > #define OCCTX_RX_OFFLOAD_RSS_F BIT(0) > +#define OCCTX_RX_VLAN_FLTR_F BIT(1) > #define OCCTX_RX_MULTI_SEG_F BIT(15) > > #define OCCTX_TX_OFFLOAD_NONE (0) > -- > 2.18.0 >