From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B9B4423C1; Fri, 13 Jan 2023 13:50:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B80D42D53; Fri, 13 Jan 2023 13:50:54 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by mails.dpdk.org (Postfix) with ESMTP id 4DFA740E03 for ; Fri, 13 Jan 2023 13:50:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZThLKridWA16BhTB4MEMS0inkxNRBbBlWQYAqD/iytMdm1SGl6ufB7qiL2eDBLsqZQDwg3ZDsIExt+sJvimLTIwxaIkCkWTsojsMZAI2xbNAMJRZd67C/DYkPK1lx6Xl6hNxGculueVT32+v4+F80YjXBg2pxTKaDFB0doQC1UiUTFYB1K4qUkjFOWP26f97lZOS18IB6cJoom2A/u/VZw/7HW/UDmKIIYE8Bbw2ZiPFlB+zrtS4eBGZEcetqGfXJ6LsEmC1BP9D8xQnw0cueOGVY1nIZ4vM0AU8AiJR4+/QNcmHWUQdOJlkkChtZ3XIvV5Nnj30jk4MhVZYUcULsw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=np5jWcK1EtRzjQISYcO8wxPT6oHg/RurvF6ntltgD9w=; b=odnSGsNX/nQm0RohCM9xzhhZ+WCE2E/j2kGx1JmNFRhevcPs+a4ADAZwLka/yN8AFKaLPgqC8PcTzSzj/0UoTyRh8MGqnUpLEoTSE/NaiWVcnuVJdpP0El0tgyXxOp2j7uTHa7Yt4Qzq/voc2HanamriWBkRBhbnMYfDJi678dYBn1+3AwIL3o8W+MilhZuX/nZuvJGHAWPnI9AaHGWZQ5KnCN6xJcfkI9DUEEGn1wYwaEt8zm9ZaO3FL46YCdQX9r5CXFIU9PiOZh/6MgfyVNp2hZ3BogvzAcWtbop6oLjuxYE9KL8PyUVOkY58y40NCF8Tg0oYzSUvROmakn0VdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=np5jWcK1EtRzjQISYcO8wxPT6oHg/RurvF6ntltgD9w=; b=OTAJXzKYf6Aj3e3/6g+dstrH/AJ3ezazL/v2F1QrkFwp95N5cDjcyRcSn9VU5syAcjzlT2SiiTLu4X7pW5tg0pU3kBAmLQivoHmba9CzphpQiKzmJnpsrFoYO0PBi5ZdKW9vLnoqUgxcZ2qGI++Fhu6Ui1Y2m/ZlTDz1CdhVrXs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by DM6PR12MB4546.namprd12.prod.outlook.com (2603:10b6:5:2ae::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Fri, 13 Jan 2023 12:50:48 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%9]) with mapi id 15.20.5986.019; Fri, 13 Jan 2023 12:50:48 +0000 Message-ID: Date: Fri, 13 Jan 2023 12:50:42 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: Ke Zhang , dev@dpdk.org, mb@smartsharesystems.com, thomas@monjalon.net, olivier.matz@6wind.com, Yuying.Zhang@intel.com, beilei.xing@intel.com References: <20211020012831.8480-1-alvinx.zhang@intel.com> <20230109022027.190627-1-ke1x.zhang@intel.com> Cc: Jerin Jacob Kollanukkaran , Ajit Khaparde , Hemant Agrawal , Qi Z Zhang , Raslan Darawsheh , Helin Zhang , Thomas Monjalon , Aman Singh From: Ferruh Yigit Subject: Re: [PATCH] net/i40e: disable source pruning In-Reply-To: <20230109022027.190627-1-ke1x.zhang@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:311::6) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|DM6PR12MB4546:EE_ X-MS-Office365-Filtering-Correlation-Id: 99dcfc04-50e2-4bd8-c917-08daf564cb15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6VLPZ9XVM+iy27aoeU5N82fV5dj8LplmXqDkEQFZIfmyisumeHX0nZ+UriMlZeZDIe7zMquc0F7ILAn/JfPevx/orvZjunDnLFlAVkKNmaF/q+sBnW9ZqPuSCA437u88NqGgAIlnqduz7mzPhOxgpFFLoWhp9SeQva3BrUy55V23gPhY5INuN7xDUmsFJ49vH9jEqt+gIHffqSSlR8w8iyT0Tdlgczi3tTJ90kyVWe3+IsFKtdX/cy/43xwrOIkpU89hebsnJusewSvMAXZYJGzmBZnDzIg2i4XTvE9AinKW47kksD5U5zjS2ylqBQ5+i6gMakcclF0euxl99LyLllF3NapnlZRVQ/aVEORhVYOesLydZ5mwRgKrouvcxFyWaNhKAp/jzzih1nzlOCss99M0EFKG72YFdBPI3f9cw/2+mg3LJyxphyZ6qBqQg+iAyYvY6zFp9t4AwoWgaDwaSm0mxK3XZHXVbJpQDA/HQ/FeB+vrgS8qYq5DRMhNJ+vY6oC+8l2cn7K9Nz74V1hHgnoZQXHAu2DcsbFJwM5XoVn7vGYcmenp5iSAHAC6NiIXRZEFPn8feiM24p61m3oBu+w2I5iAlguaagLP6ysfQgA91o1ObLrDeZ8hhQ16Jzpw6NLytr2wHerUzpKoD+3kWsEQKWWBQPHMccv4g8oUQqmUnpr5Tdn1u8/o1+17PbX9PHFxKuNY7iRCLjrxLS5bA8TqfLJ1XFZA9QFSkHVABh/GR1g/gBG5Z+lYGMg+VcHe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(451199015)(4326008)(478600001)(6486002)(66574015)(38100700002)(41300700001)(86362001)(54906003)(31696002)(2616005)(316002)(26005)(186003)(66556008)(66946007)(36756003)(53546011)(8676002)(7416002)(6666004)(6506007)(5660300002)(2906002)(44832011)(30864003)(66476007)(6512007)(8936002)(31686004)(83380400001)(21314003)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TWh4eVpEbmpSYXR5bnFQcFhmLzFkejYrVmlBOVFiT05HZVhJZDdiSU9NS0hF?= =?utf-8?B?TmduQllYUXRQN0RpcFlFcWZzV0Y4di9GZ2JDWWZmSWJ3ejZNeGtzR0hHUEl3?= =?utf-8?B?TnJRS3h6S1A5dHZ4c1Y0Qk1DYTF5WG5iR0o3VDNUSHF1WnU3MHpIdzAvSElY?= =?utf-8?B?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c1emhKaGRiYnhsTWk1?= =?utf-8?B?RDVJT0xqZ1dtMWlCNGVVZTljc2x1VnZCS3lObW5pN0ZSa2RWS0RyTldUSEt5?= =?utf-8?B?SW9zUDEremV0K3ZncW5EM2xFMlAwcHdnSmwwR2cxa3YxZy9qK3dYMW5CbnFw?= =?utf-8?Q?p/dXSvgmX8tNXHJjTj1cAbNxu?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99dcfc04-50e2-4bd8-c917-08daf564cb15 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 12:50:48.2989 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GYLHNZetLXJ9hj40TgLxFYOeCZv4Fs+YqF5/lnhope3PANrVX9yPVV3YHjPTNmii X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4546 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 1/9/2023 2:20 AM, Ke Zhang wrote: > VRRP advertisement packets are dropped on i40e PF devices because > when a MAC address is added to a device, packets originating from > that MAC address are dropped. > > This patch adds a interface in lib/ethdev to support disabling > source pruning to work around above issue. > Hi Ke, We have a dilemma between enabling as much HW config/feature as possible and having common/portable APIs. If we add a new API for each specific HW config/feature, it will be confusing for users and DPDK APIs won't be portable. We may end up slightly specific version of an API specific to a NIC. For this we used PMD specific APIs time to time (like drivers/net/i40e/rte_pmd_i40e.h), although is not also a good solution. If this is a common config/feature for more than one NIC, I am OK to procced with the patch as it is, for this I have cc'ed a few more folks, but first can you please describe the config/feature a little more detailed please. What I understand is if packet target MAC address is same as device MAC address, packet is dropped, which is called 'source pruning' feature. What is the use case for this, is the expectation send a packet to router/switch and expect to receive it back? Is all egress packets dropped as described? Becase feture referred as "local loopback" in the code, is this only applied to packets switched locally in NIC? Can it be solution to always disable source pruning by default? If this is specific to i40e, I suggest adding it as PMD specific API. I put some comments below but first need to clarify how to procced with the patch. > Bugzilla ID: 648 > > Signed-off-by: Ke Zhang > --- > app/test-pmd/cmdline.c | 77 ++++++++++++++++++++++++++++++++++ > drivers/net/i40e/i40e_ethdev.c | 53 +++++++++++++++++++++++ > lib/ethdev/ethdev_driver.h | 6 +++ > lib/ethdev/rte_ethdev.c | 16 +++++++ > lib/ethdev/rte_ethdev.h | 15 +++++++ > 5 files changed, 167 insertions(+) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index cb8c174020..a9602a2ed0 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -482,6 +482,9 @@ static void cmd_help_long_parsed(void *parsed_result, > "set promisc (port_id|all) (on|off)\n" > " Set the promiscuous mode on port_id, or all.\n\n" > > + "set llb (port_id|all) (on|off)\n" > + " Set vsi local loopback on port_id, or all.\n\n" > + Please don't use abreviations, specially for not commonly knows features, 'llb' won't make sense to many people, and as number of this unkown commonds increase it has a risk to make testpmd unusable, please prefer 'local_loopback'. And please don't refer to 'vsi' here. And personally I don't prefer using 'set xxx' commands to configure device, what I prefer: "set xxx" --> set testpmd specific configuration "port config xxx" --> configure device Although I am aware this separation is not clear and there is a mixuture of usage, some of them historical. > "set allmulti (port_id|all) (on|off)\n" > " Set the allmulti mode on port_id, or all.\n\n" > > @@ -5775,6 +5778,78 @@ static cmdline_parse_inst_t cmd_set_promisc_mode_one = { > }, > }; > > +/* *** SET VSI LOCAL LOOPBACK *** *> +struct cmd_set_vsi_local_lb_result { > + cmdline_fixed_string_t set; > + cmdline_fixed_string_t llb; > + cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ > + uint16_t port_num; /* valid if "allports" argument == 0 */ > + cmdline_fixed_string_t enable; > +}; > + > +static void cmd_set_vsi_llb_parsed(void *parsed_result, > + __rte_unused struct cmdline *cl, > + void *allports) > +{ > + struct cmd_set_vsi_local_lb_result *res = parsed_result; > + int enable; > + portid_t i; > + > + if (!strcmp(res->enable, "on")) > + enable = 1; > + else > + enable = 0; > + > + /* all ports */ > + if (allports) { > + RTE_ETH_FOREACH_DEV(i) > + rte_eth_dev_enable_local_lb(i, enable); > + } else { > + rte_eth_dev_enable_local_lb(res->port_num, enable); > + } > +} > + > +static cmdline_parse_token_string_t cmd_setllb_set = > + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, set, "set"); > +static cmdline_parse_token_string_t cmd_setllb_llb = > + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, llb, > + "llb"); > +static cmdline_parse_token_string_t cmd_setllb_portall = > + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, port_all, > + "all"); > +static cmdline_parse_token_num_t cmd_setllb_portnum = > + TOKEN_NUM_INITIALIZER(struct cmd_set_vsi_local_lb_result, port_num, > + RTE_UINT16); > +static cmdline_parse_token_string_t cmd_setllb_enalbe = > + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, enable, > + "on#off"); > + > +static cmdline_parse_inst_t cmd_set_vsi_enable_all = { > + .f = cmd_set_vsi_llb_parsed, > + .data = (void *)1, > + .help_str = "set llb all on|off: Set vsi local loopback for all ports", > + .tokens = { > + (void *)&cmd_setllb_set, > + (void *)&cmd_setllb_llb, > + (void *)&cmd_setllb_portall, > + (void *)&cmd_setllb_enalbe, > + NULL, > + }, > +}; > + > +static cmdline_parse_inst_t cmd_set_vsi_enable_one = { > + .f = cmd_set_vsi_llb_parsed, > + .data = (void *)0, > + .help_str = "set llb on|off: Set vsi local loopback on port id", > + .tokens = { > + (void *)&cmd_setllb_set, > + (void *)&cmd_setllb_llb, > + (void *)&cmd_setllb_portnum, > + (void *)&cmd_setllb_enalbe, > + NULL, > + }, > +}; please dont use 'vsi' in the scope of testpmd commands. > + > /* *** SET ALLMULTI MODE *** */ > struct cmd_set_allmulti_mode_result { > cmdline_fixed_string_t set; > @@ -12866,6 +12941,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = { > (cmdline_parse_inst_t *)&cmd_show_port_cman_capa, > (cmdline_parse_inst_t *)&cmd_show_port_cman_config, > (cmdline_parse_inst_t *)&cmd_set_port_cman_config, > + (cmdline_parse_inst_t *)&cmd_set_vsi_enable_all, > + (cmdline_parse_inst_t *)&cmd_set_vsi_enable_one, Instead of adding to end better to try it grouping with relevant commands. > NULL, > }; > > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 7726a89d99..dd07c38f0f 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -406,6 +406,7 @@ static void i40e_ethertype_filter_restore(struct i40e_pf *pf); > static void i40e_tunnel_filter_restore(struct i40e_pf *pf); > static void i40e_filter_restore(struct i40e_pf *pf); > static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev); > +static int i40e_enable_pf_local_lb(struct rte_eth_dev *dev, int on); > > static const char *const valid_keys[] = { > ETH_I40E_FLOATING_VEB_ARG, > @@ -517,6 +518,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = { > .tm_ops_get = i40e_tm_ops_get, > .tx_done_cleanup = i40e_tx_done_cleanup, > .get_monitor_addr = i40e_get_monitor_addr, > + .enable_local_lb = i40e_enable_pf_local_lb, > }; > > /* store statistics names and its offset in stats structure */ > @@ -5634,6 +5636,57 @@ i40e_enable_pf_lb(struct i40e_pf *pf) > hw->aq.asq_last_status); > } > > +/* i40e_enable_pf_local_lb > + * @pf: pointer to the pf structure > + * > + * allow local loopback on pf > + */ > +static int > +i40e_enable_pf_local_lb(struct rte_eth_dev *dev, int on) > +{ > + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); > + struct i40e_hw *hw = I40E_PF_TO_HW(pf); > + struct i40e_vsi_context ctxt; > + int ret; > + > + /* Use the FW API if FW >= v5.0 */ > + if (hw->aq.fw_maj_ver < 5 && hw->mac.type != I40E_MAC_X722) { > +#ifdef TREX_PATCH > + /* Most of our customers do not have latest FW */ > + PMD_INIT_LOG(INFO, "FW < v5.0, cannot enable local loopback"); > +#else > + PMD_INIT_LOG(ERR, "FW < v5.0, cannot enable local loopback"); > +#endif > + return I40E_NOT_SUPPORTED; > + } > + > + memset(&ctxt, 0, sizeof(ctxt)); > + ctxt.seid = pf->main_vsi_seid; > + ctxt.pf_num = hw->pf_id; > + ret = i40e_aq_get_vsi_params(hw, &ctxt, NULL); > + if (ret) { > + PMD_DRV_LOG(ERR, "cannot get pf vsi config, err %d, aq_err %d", > + ret, hw->aq.asq_last_status); > + return ret; > + } > + ctxt.flags = I40E_AQ_VSI_TYPE_PF; > + ctxt.info.valid_sections = > + rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SWITCH_VALID); > + if (on) > + ctxt.info.switch_id |= > + rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_LOCAL_LB); > + else > + ctxt.info.switch_id &= > + ~rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_LOCAL_LB); > + > + ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); > + if (ret) > + PMD_DRV_LOG(ERR, "update vsi switch failed, aq_err=%d", > + hw->aq.asq_last_status); > + > + return ret; > +} > + > /* Setup a VSI */ > struct i40e_vsi * > i40e_vsi_setup(struct i40e_pf *pf, > diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h > index 6a550cfc83..3a11a7fab4 100644 > --- a/lib/ethdev/ethdev_driver.h > +++ b/lib/ethdev/ethdev_driver.h > @@ -668,6 +668,10 @@ typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev, > typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev, > struct rte_dev_eeprom_info *info); > > +/** @internal Function used to enable/disable the vsi loop back of an Ethernet device. */ > +typedef int (*eth_enable_local_lb_t)(struct rte_eth_dev *dev, > + int on); > + What is 'VSI'? Is it common dpdk or ethdev concept? If not please don't refer it in ethdev. > struct rte_flow_ops; > /** > * @internal > @@ -1403,6 +1407,8 @@ struct eth_dev_ops { > eth_cman_config_set_t cman_config_set; > /** Retrieve congestion management configuration */ > eth_cman_config_get_t cman_config_get; > + /** Enable/disable the vsi loop back of an Ethernet device */ > + eth_enable_local_lb_t enable_local_lb; The name 'enable_local_lb' needs to refined. Why it is called as 'local_lb'? And again please use loopback instead of 'lb'. > }; > > /** > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 5d5e18db1e..3991688e2b 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -6318,6 +6318,22 @@ rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes > return j; > } > > +int > +rte_eth_dev_enable_local_lb(uint16_t port_id, int on) > +{ > + struct rte_eth_dev *dev; > + int ret; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev = &rte_eth_devices[port_id]; > + > + if (*dev->dev_ops->enable_local_lb == NULL) > + return -ENOTSUP; > + > + ret = (*dev->dev_ops->enable_local_lb)(dev, on); > + return eth_err(port_id, ret); > +} > + > RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); > > RTE_INIT(ethdev_init_telemetry) > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > index c129ca1eaf..c4888ebd62 100644 > --- a/lib/ethdev/rte_ethdev.h > +++ b/lib/ethdev/rte_ethdev.h > @@ -3437,6 +3437,21 @@ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu); > */ > int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on); > > +/** > + * Enable/Disable local Loopback for VSIs that are used as uplink of a software > + * (cascaded) VEB, VEPA or Port Virtualizer. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param on > + * If > 0, enable local Loopback. > + * Otherwise, disable local Loopback. > + * @return > + * - (0) if successful. > + * - negative if failed. > + */ > +int rte_eth_dev_enable_local_lb(uint16_t port_id, int on); > + API enable/disable the feature but API name has 'enable', so it will be calling enable_X API to disable X, if API is to enable/disable, perhaps it can be names as 'set_X'?