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 6795FA0350; Mon, 22 Jun 2020 04:57:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 375771C0D8; Mon, 22 Jun 2020 04:57:18 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id B65261C031 for ; Mon, 22 Jun 2020 04:57:16 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 319671F090E1C87D7108; Mon, 22 Jun 2020 10:57:14 +0800 (CST) Received: from [10.69.31.206] (10.69.31.206) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 22 Jun 2020 10:57:10 +0800 To: Andrew Rybchenko , References: <1592636016-5836-1-git-send-email-xavier.huwei@huawei.com> <1592636016-5836-3-git-send-email-xavier.huwei@huawei.com> <364d1ff5-d05d-8855-2095-14b8af60258f@solarflare.com> CC: Thomas Monjalon , From: "Wei Hu (Xavier)" Message-ID: Date: Mon, 22 Jun 2020 10:57:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <364d1ff5-d05d-8855-2095-14b8af60258f@solarflare.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.31.206] X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v2 2/2] ethdev: fix VLAN offloads set if no relative capabilities 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" Hi, Andrew Rybchenko On 2020/6/21 21:44, Andrew Rybchenko wrote: > On 6/20/20 9:53 AM, Wei Hu (Xavier) wrote: >> Currently, there is a potential problem that calling the API function >> rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the >> driver does not support. If the PMD driver does not support certain VLAN >> hardware offloads and does not check for it, the hardware setting will >> not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads >> will be turned on. >> >> It is supposed to check the hardware capabilities to decide whether the >> relative callback needs to be called just like the behavior in the API >> function named rte_eth_dev_configure. And it is also needed to cleanup >> duplicated checks which are done in some PMDs. >> >> Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") >> Cc: stable@dpdk.org >> >> Signed-off-by: Chengchang Tang >> Signed-off-by: Wei Hu (Xavier) > For ethdev part: > Acked-by: Andrew Rybchenko > > I'd like to highlight that it is behaviour change for some PMDs > which simply ignore (with error/warning log message) > unsupported VLAN offloads, but now it will fail. We should > very carefully consider backporting of these changes. > I'd say we should, since it is rather a bug fix. > > IMHO, it is better to send v3 using > --to-cmd ./devtools/get-maintainer.sh > in order to have all driver maintainers in To. OK, I will send V3. Thanks, Xavier >> --- >> v1 -> v2: cleanup duplicated checks which are done in som PMDs. >> --- >> drivers/net/dpaa2/dpaa2_ethdev.c | 5 ----- >> drivers/net/enic/enic_ethdev.c | 12 ------------ >> drivers/net/fm10k/fm10k_ethdev.c | 20 -------------------- >> drivers/net/hinic/hinic_pmd_ethdev.c | 6 ------ >> drivers/net/i40e/i40e_ethdev.c | 5 ----- >> drivers/net/nfp/nfp_net.c | 5 ----- >> drivers/net/octeontx/octeontx_ethdev_ops.c | 10 ---------- >> drivers/net/octeontx2/otx2_vlan.c | 5 ----- >> drivers/net/qede/qede_ethdev.c | 3 --- >> lib/librte_ethdev/rte_ethdev.c | 21 +++++++++++++++++++++ >> 10 files changed, 21 insertions(+), 71 deletions(-) >> >> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c >> index 2f031ec..da5018f 100644 >> --- a/drivers/net/dpaa2/dpaa2_ethdev.c >> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c >> @@ -169,11 +169,6 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); >> } >> next_mask: >> - if (mask & ETH_VLAN_EXTEND_MASK) { >> - if (dev->data->dev_conf.rxmode.offloads & >> - DEV_RX_OFFLOAD_VLAN_EXTEND) >> - DPAA2_PMD_INFO("VLAN extend offload not supported"); >> - } >> >> return 0; >> } >> diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c >> index 32d5397..ef8900d 100644 >> --- a/drivers/net/enic/enic_ethdev.c >> +++ b/drivers/net/enic/enic_ethdev.c >> @@ -374,18 +374,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) >> enic->ig_vlan_strip_en = 0; >> } >> >> - if ((mask & ETH_VLAN_FILTER_MASK) && >> - (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { >> - dev_warning(enic, >> - "Configuration of VLAN filter is not supported\n"); >> - } >> - >> - if ((mask & ETH_VLAN_EXTEND_MASK) && >> - (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { >> - dev_warning(enic, >> - "Configuration of extended VLAN is not supported\n"); >> - } >> - >> return enic_set_vlan_strip(enic); >> } >> >> diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c >> index f537ab2..47f6f76 100644 >> --- a/drivers/net/fm10k/fm10k_ethdev.c >> +++ b/drivers/net/fm10k/fm10k_ethdev.c >> @@ -1577,26 +1577,6 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) >> static int >> fm10k_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> { >> - if (mask & ETH_VLAN_STRIP_MASK) { >> - if (!(dev->data->dev_conf.rxmode.offloads & >> - DEV_RX_OFFLOAD_VLAN_STRIP)) >> - PMD_INIT_LOG(ERR, "VLAN stripping is " >> - "always on in fm10k"); >> - } >> - >> - if (mask & ETH_VLAN_EXTEND_MASK) { >> - if (dev->data->dev_conf.rxmode.offloads & >> - DEV_RX_OFFLOAD_VLAN_EXTEND) >> - PMD_INIT_LOG(ERR, "VLAN QinQ is not " >> - "supported in fm10k"); >> - } >> - >> - if (mask & ETH_VLAN_FILTER_MASK) { >> - if (!(dev->data->dev_conf.rxmode.offloads & >> - DEV_RX_OFFLOAD_VLAN_FILTER)) >> - PMD_INIT_LOG(ERR, "VLAN filter is always on in fm10k"); >> - } >> - >> return 0; >> } >> >> diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c >> index 0c3e1c0..0009a61 100644 >> --- a/drivers/net/hinic/hinic_pmd_ethdev.c >> +++ b/drivers/net/hinic/hinic_pmd_ethdev.c >> @@ -1701,12 +1701,6 @@ static int hinic_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> nic_dev->proc_dev_name, dev->data->port_id); >> } >> >> - if (mask & ETH_VLAN_EXTEND_MASK) { >> - PMD_DRV_LOG(ERR, "Don't support vlan qinq, device: %s, port_id: %d", >> - nic_dev->proc_dev_name, dev->data->port_id); >> - return -ENOTSUP; >> - } >> - >> return 0; >> } >> >> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c >> index 970a31c..9211cf5 100644 >> --- a/drivers/net/i40e/i40e_ethdev.c >> +++ b/drivers/net/i40e/i40e_ethdev.c >> @@ -3877,11 +3877,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> struct i40e_vsi *vsi = pf->main_vsi; >> struct rte_eth_rxmode *rxmode; >> >> - if (mask & ETH_QINQ_STRIP_MASK) { >> - PMD_DRV_LOG(ERR, "Strip qinq is not supported."); >> - return -ENOTSUP; >> - } >> - >> rxmode = &dev->data->dev_conf.rxmode; >> if (mask & ETH_VLAN_FILTER_MASK) { >> if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER) >> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c >> index 2460ee1..b7a91ae 100644 >> --- a/drivers/net/nfp/nfp_net.c >> +++ b/drivers/net/nfp/nfp_net.c >> @@ -2353,11 +2353,6 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); >> new_ctrl = 0; >> >> - if ((mask & ETH_VLAN_FILTER_OFFLOAD) || >> - (mask & ETH_VLAN_EXTEND_OFFLOAD)) >> - PMD_DRV_LOG(INFO, "No support for ETH_VLAN_FILTER_OFFLOAD or" >> - " ETH_VLAN_EXTEND_OFFLOAD"); >> - >> /* Enable vlan strip if it is not configured yet */ >> if ((mask & ETH_VLAN_STRIP_OFFLOAD) && >> !(hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN)) >> diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c >> index ff627a6..dbe13ce 100644 >> --- a/drivers/net/octeontx/octeontx_ethdev_ops.c >> +++ b/drivers/net/octeontx/octeontx_ethdev_ops.c >> @@ -43,16 +43,6 @@ octeontx_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask) >> >> 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); >> diff --git a/drivers/net/octeontx2/otx2_vlan.c b/drivers/net/octeontx2/otx2_vlan.c >> index 322a565..7357b06 100644 >> --- a/drivers/net/octeontx2/otx2_vlan.c >> +++ b/drivers/net/octeontx2/otx2_vlan.c >> @@ -717,11 +717,6 @@ otx2_nix_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) >> >> rxmode = ð_dev->data->dev_conf.rxmode; >> >> - if (mask & ETH_VLAN_EXTEND_MASK) { >> - otx2_err("Extend offload not supported"); >> - return -ENOTSUP; >> - } >> - >> if (mask & ETH_VLAN_STRIP_MASK) { >> if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) { >> offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; >> diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c >> index c4f8f12..04d17c7 100644 >> --- a/drivers/net/qede/qede_ethdev.c >> +++ b/drivers/net/qede/qede_ethdev.c >> @@ -1036,9 +1036,6 @@ static int qede_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) >> } >> } >> >> - if (mask & ETH_VLAN_EXTEND_MASK) >> - DP_ERR(edev, "Extend VLAN not supported\n"); >> - >> qdev->vlan_offload_mask = mask; >> >> DP_INFO(edev, "VLAN offload mask %d\n", mask); >> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c >> index b0b0474..bf79749 100644 >> --- a/lib/librte_ethdev/rte_ethdev.c >> +++ b/lib/librte_ethdev/rte_ethdev.c >> @@ -3260,12 +3260,14 @@ rte_eth_dev_set_vlan_ether_type(uint16_t port_id, >> int >> rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) >> { >> + struct rte_eth_dev_info dev_info; >> struct rte_eth_dev *dev; >> int ret = 0; >> int mask = 0; >> int cur, org = 0; >> uint64_t orig_offloads; >> uint64_t dev_offloads; >> + uint64_t new_offloads; >> >> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); >> dev = &rte_eth_devices[port_id]; >> @@ -3319,6 +3321,25 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) >> if (mask == 0) >> return ret; >> >> + ret = rte_eth_dev_info_get(port_id, &dev_info); >> + if (ret != 0) >> + return ret; >> + >> + /* >> + * New added Rx VLAN offloading which are not enabled in >> + * rte_eth_dev_configure() must be within its device capabilities >> + */ >> + if ((dev_offloads & dev_info.rx_offload_capa) != dev_offloads) { >> + new_offloads = dev_offloads & ~orig_offloads; >> + RTE_ETHDEV_LOG(ERR, >> + "Ethdev port_id=%u requested new added VLAN offloads " >> + "0x%" PRIx64 " must be within Rx offloads capabilities " >> + "0x%" PRIx64 " in %s()\n", >> + port_id, new_offloads, dev_info.rx_offload_capa, >> + __func__); >> + return -EINVAL; >> + } >> + >> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); >> dev->data->dev_conf.rxmode.offloads = dev_offloads; >> ret = (*dev->dev_ops->vlan_offload_set)(dev, mask); >> > . >