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 DA19CA04C5; Sat, 5 Sep 2020 05:00:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 79C391C124; Sat, 5 Sep 2020 04:59:54 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 38A411C11E; Sat, 5 Sep 2020 04:59:52 +0200 (CEST) IronPort-SDR: bzQVIOeCHKXDT86lzSaRlNdzomrMK1GYpXPILIaE5Es42fURiYcxusKwNfhYP6PklYknIEVCpZ 6HlOHRSbCpog== X-IronPort-AV: E=McAfee;i="6000,8403,9734"; a="137886693" X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="137886693" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 19:59:51 -0700 IronPort-SDR: vn1oF8llWCtsakmDXauZM2WO81nt4XmWje07FOixGSCOSDMkCmo23Oh9oeq12o6BP70h0dyyh+ SUzeAEvfVLkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="406052732" Received: from unknown (HELO localhost.localdomain) ([10.239.255.52]) by fmsmga001.fm.intel.com with ESMTP; 04 Sep 2020 19:59:49 -0700 From: Guinan Sun To: dev@dpdk.org Cc: Beilei Xing , Qi Zhang , Qiming Yang , Guinan Sun , stable@dpdk.org, Przemyslaw Patynowski Date: Sat, 5 Sep 2020 02:49:35 +0000 Message-Id: <20200905024938.14609-7-guinanx.sun@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200905024938.14609-1-guinanx.sun@intel.com> References: <20200905024938.14609-1-guinanx.sun@intel.com> Subject: [dpdk-dev] [PATCH 6/9] net/i40e/base: fix Rx only for unicast promisc on VLAN 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" Set promiscuous mode to rx traffic only if VSI has VLANs configured. Rename misleading PROMISC_TX bit to proper name. Added I40E_AQC_SET_VSI_PROMISC_RX_ONLY during VSI unicast promiscuous mode configuration with port VLAN. Aligned unicast promiscuous with VLAN to the one without VLAN. Previously other VFs could listen to unicast tx traffic of other VFs. Fixes: 8db9e2a1b232 ("i40e: base driver") Cc: stable@dpdk.org Signed-off-by: Przemyslaw Patynowski Signed-off-by: Guinan Sun --- drivers/net/i40e/base/i40e_adminq_cmd.h | 2 +- drivers/net/i40e/base/i40e_common.c | 36 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h b/drivers/net/i40e/base/i40e_adminq_cmd.h index 4db8cdd8c..d6402a691 100644 --- a/drivers/net/i40e/base/i40e_adminq_cmd.h +++ b/drivers/net/i40e/base/i40e_adminq_cmd.h @@ -1222,7 +1222,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes { #define I40E_AQC_SET_VSI_PROMISC_BROADCAST 0x04 #define I40E_AQC_SET_VSI_DEFAULT 0x08 #define I40E_AQC_SET_VSI_PROMISC_VLAN 0x10 -#define I40E_AQC_SET_VSI_PROMISC_TX 0x8000 +#define I40E_AQC_SET_VSI_PROMISC_RX_ONLY 0x8000 __le16 seid; #define I40E_AQC_VSI_PROM_CMD_SEID_MASK 0x3FF __le16 vlan_tag; diff --git a/drivers/net/i40e/base/i40e_common.c b/drivers/net/i40e/base/i40e_common.c index 15f4e91a4..cd8b27e40 100644 --- a/drivers/net/i40e/base/i40e_common.c +++ b/drivers/net/i40e/base/i40e_common.c @@ -2270,6 +2270,22 @@ enum i40e_status_code i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags, return status; } +/** + * i40e_hw_ver_ge + * @hw: pointer to the hw struct + * @maj: api major value + * @min: api minor value + * + * Assert whether current HW api version is greater/equal than provided. + **/ +static bool i40e_hw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min) +{ + if (hw->aq.api_maj_ver > maj || + (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min)) + return true; + return false; +} + /** * i40e_aq_add_vsi * @hw: pointer to the hw struct @@ -2395,18 +2411,16 @@ enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw, if (set) { flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST; - if (rx_only_promisc && - (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) || - (hw->aq.api_maj_ver > 1))) - flags |= I40E_AQC_SET_VSI_PROMISC_TX; + if (rx_only_promisc && i40e_hw_ver_ge(hw, 1, 5)) + flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY; } cmd->promiscuous_flags = CPU_TO_LE16(flags); cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST); - if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) || - (hw->aq.api_maj_ver > 1)) - cmd->valid_flags |= CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_TX); + if (i40e_hw_ver_ge(hw, 1, 5)) + cmd->valid_flags |= + CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY); cmd->seid = CPU_TO_LE16(seid); status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); @@ -2538,11 +2552,17 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw, i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_set_vsi_promiscuous_modes); - if (enable) + if (enable) { flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST; + if (i40e_hw_ver_ge(hw, 1, 5)) + flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY; + } cmd->promiscuous_flags = CPU_TO_LE16(flags); cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST); + if (i40e_hw_ver_ge(hw, 1, 5)) + cmd->valid_flags |= + CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY); cmd->seid = CPU_TO_LE16(seid); cmd->vlan_tag = CPU_TO_LE16(vid | I40E_AQC_SET_VSI_VLAN_VALID); -- 2.17.1