[dpdk-dev] [PATCH 1/8] net/hns3: add limit promisc mode to VF

Lijun Ou oulijun at huawei.com
Mon Nov 2 15:38:12 CET 2020


From: Chengchang Tang <tangchengchang at huawei.com>

For kunpeng920, both tx and rx promisc is set when the promisc mode
is open. In the word, 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 <tangchengchang at huawei.com>
Signed-off-by: Lijun Ou <oulijun at huawei.com>
---
 drivers/net/hns3/hns3_ethdev.h    | 21 +++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev_vf.c |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index dcae154..b23c90e 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 05a9341..c903e07 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;
 }
-- 
2.7.4



More information about the dev mailing list