From: Chengchang Tang Date: Mon, 2 Nov 2020 14:38:12 +0000 (+0800) Subject: net/hns3: limit promiscuous mode for VF X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=82c737f0a66a68789469484e632e31cb19d9d105;p=dpdk.git net/hns3: limit promiscuous mode for VF For Kunpeng920, both tx and rx promisc is set when the promisc mode is enabled. In other words, all the ingress packets and the packets sent from the PF and other VFs on the same physical port will be copied to the function which set promisc mode on. Kunpeng930 support to turn off the tx unicast promisc. A limit promisc mode is introduced, which means turn off the tx unicast promisc when promisc is set. Signed-off-by: Chengchang Tang Signed-off-by: Lijun Ou --- diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index dcae15482e..b23c90e0a9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -41,6 +41,9 @@ #define HNS3_SW_SHIFT_AND_DISCARD_MODE 0 #define HNS3_HW_SHIFT_AND_DISCARD_MODE 1 +#define HNS3_UNLIMIT_PROMISC_MODE 0 +#define HNS3_LIMIT_PROMISC_MODE 1 + #define HNS3_UC_MACADDR_NUM 128 #define HNS3_VF_UC_MACADDR_NUM 48 #define HNS3_MC_MACADDR_NUM 128 @@ -528,6 +531,24 @@ struct hns3_hw { * is enabled. */ uint8_t vlan_mode; + /* + * promisc mode. + * value range: + * HNS3_UNLIMIT_PROMISC_MODE/HNS3_LIMIT_PROMISC_MODE + * + * - HNS3_UNLIMIT_PROMISC_MODE + * In this mode, TX unicast promisc will be configured when promisc + * is set, driver can receive all the ingress and outgoing traffic. + * In the words, all the ingress packets, all the packets sent from + * the PF and other VFs on the same physical port. + * + * - HNS3_LIMIT_PROMISC_MODE + * In this mode, TX unicast promisc is shutdown when promisc mode + * is set. So, driver will only receive all the ingress traffic. + * The packets sent from the PF and other VFs on the same physical + * port won't be copied to the function which has set promisc mode. + */ + uint8_t promisc_mode; uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */ struct hns3_port_base_vlan_config port_base_vlan_cfg; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 05a9341269..c903e07dbf 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -610,6 +610,7 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, req->msg[1] = en_bc_pmc ? 1 : 0; req->msg[2] = en_uc_pmc ? 1 : 0; req->msg[3] = en_mc_pmc ? 1 : 0; + req->msg[4] = hw->promisc_mode == HNS3_LIMIT_PROMISC_MODE ? 1 : 0; ret = hns3_cmd_send(hw, &desc, 1); if (ret) @@ -1214,6 +1215,7 @@ hns3vf_get_capability(struct hns3_hw *hw) hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN; hw->rss_info.ipv6_sctp_offload_supported = false; + hw->promisc_mode = HNS3_UNLIMIT_PROMISC_MODE; return 0; } @@ -1231,6 +1233,7 @@ hns3vf_get_capability(struct hns3_hw *hw) hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM; hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; hw->rss_info.ipv6_sctp_offload_supported = true; + hw->promisc_mode = HNS3_LIMIT_PROMISC_MODE; return 0; }