DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/4] add support of partial offload
@ 2024-02-10 10:42 Chaoyong He
  2024-02-10 10:42 ` [PATCH 1/4] net/nfp: support MARK flow action Chaoyong He
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-10 10:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to add support of partial offload for NFP PMD.

Long Wu (4):
  net/nfp: support MARK flow action
  net/nfp: add interface to check representor
  net/nfp: representor adds RSS configuration
  net/nfp: support RSS flow action

 doc/guides/nics/features/nfp.ini              |   1 +
 drivers/common/nfp/nfp_common_ctrl.h          |   1 +
 drivers/net/nfp/flower/nfp_flower.c           |  12 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  16 ++
 drivers/net/nfp/flower/nfp_flower_flow.c      | 153 +++++++++++++++++-
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 +
 .../net/nfp/flower/nfp_flower_representor.c   |  19 +++
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 drivers/net/nfp/nfp_mtr.c                     |   2 +-
 drivers/net/nfp/nfp_net_common.c              |  27 ++--
 drivers/net/nfp/nfp_net_common.h              |  10 ++
 11 files changed, 233 insertions(+), 17 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/4] net/nfp: support MARK flow action
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
@ 2024-02-10 10:42 ` Chaoyong He
  2024-02-10 10:42 ` [PATCH 2/4] net/nfp: add interface to check representor Chaoyong He
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-10 10:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of MARK action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 16 ++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.c | 27 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 8fb55f44a2..c94ea706bb 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -959,6 +959,22 @@ struct nfp_fl_act_meter {
 	rte_be32_t profile_id;
 };
 
+/*
+ * Mark
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | res |  opcode |  res  | len_lw|            reserved           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         Mark                                  |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_mark {
+	struct nfp_fl_act_head head;
+	rte_be16_t reserved;
+	rte_be32_t mark;
+};
+
 int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
 int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
 		struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index e26be30d18..8667f8e901 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -83,6 +83,7 @@
 #define NFP_FL_ACTION_OPCODE_METER              24
 #define NFP_FL_ACTION_OPCODE_CT_NAT_EXT         25
 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE        26
+#define NFP_FL_ACTION_OPCODE_SET_MARK           27
 #define NFP_FL_ACTION_OPCODE_NUM                32
 
 #define NFP_FL_OUT_FLAGS_LAST            RTE_BIT32(15)
@@ -1138,6 +1139,10 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_CONNTRACK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3487,6 +3492,23 @@ nfp_flow_action_meter(struct nfp_flower_representor *representor,
 	return 0;
 }
 
+static void
+nfp_flow_action_mark(char *act_data,
+		const struct rte_flow_action *action)
+{
+	struct nfp_fl_act_mark *fl_mark;
+	const struct rte_flow_action_mark *mark;
+	size_t act_size = sizeof(struct nfp_fl_act_mark);
+
+	mark = action->conf;
+
+	fl_mark = (struct nfp_fl_act_mark *)act_data;
+	fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MARK;
+	fl_mark->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
+	fl_mark->reserved     = 0;
+	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3734,6 +3756,11 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_CONNTRACK");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
+			nfp_flow_action_mark(position, action);
+			position += sizeof(struct nfp_fl_act_mark);
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 2/4] net/nfp: add interface to check representor
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
  2024-02-10 10:42 ` [PATCH 1/4] net/nfp: support MARK flow action Chaoyong He
@ 2024-02-10 10:42 ` Chaoyong He
  2024-02-12 16:24   ` Ferruh Yigit
  2024-02-10 10:42 ` [PATCH 3/4] net/nfp: representor adds RSS configuration Chaoyong He
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Chaoyong He @ 2024-02-10 10:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add a interface to check if a device is a representor.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 drivers/net/nfp/nfp_mtr.c                |  2 +-
 drivers/net/nfp/nfp_net_common.c         | 10 ++++++++--
 drivers/net/nfp/nfp_net_common.h         |  1 +
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 8667f8e901..07833fdbdb 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4348,7 +4348,7 @@ int
 nfp_flow_ops_get(struct rte_eth_dev *dev,
 		const struct rte_flow_ops **ops)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!nfp_net_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is not a representor.");
 		return -EINVAL;
diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c
index 255977ec22..11da5c07ed 100644
--- a/drivers/net/nfp/nfp_mtr.c
+++ b/drivers/net/nfp/nfp_mtr.c
@@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = {
 int
 nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!nfp_net_dev_is_repr(dev)) {
 		PMD_DRV_LOG(ERR, "Port is not a representor");
 		return -EINVAL;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 72c9a41b00..7a0b0c9973 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -156,6 +156,12 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
 	[NFP_NET_CFG_STS_LINK_RATE_100G]        = RTE_ETH_SPEED_NUM_100G,
 };
 
+bool
+nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev)
+{
+	return ((eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
 static uint16_t
 nfp_net_link_speed_rte2nfp(uint16_t speed)
 {
@@ -241,7 +247,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (nfp_net_dev_is_repr(dev)) {
 		struct nfp_flower_representor *repr;
 		repr = dev->data->dev_private;
 		hw = repr->app_fw_flower->pf_hw;
@@ -2139,7 +2145,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 
 	hw = nfp_net_get_hw(dev);
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (nfp_net_dev_is_repr(dev)) {
 		snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
 			hw->ver.extend, hw->ver.class,
 			hw->ver.major, hw->ver.minor);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e374739022..1d96b0e9d1 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -307,6 +307,7 @@ int nfp_net_fec_get(struct rte_eth_dev *dev,
 		uint32_t *fec_capa);
 int nfp_net_fec_set(struct rte_eth_dev *dev,
 		uint32_t fec_capa);
+bool nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev);
 
 #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
 	((struct nfp_app_fw_nic *)app_fw_priv)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 3/4] net/nfp: representor adds RSS configuration
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
  2024-02-10 10:42 ` [PATCH 1/4] net/nfp: support MARK flow action Chaoyong He
  2024-02-10 10:42 ` [PATCH 2/4] net/nfp: add interface to check representor Chaoyong He
@ 2024-02-10 10:42 ` Chaoyong He
  2024-02-10 10:42 ` [PATCH 4/4] net/nfp: support RSS flow action Chaoyong He
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-10 10:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add RSS configuration in representor initializaion.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h            |  1 +
 drivers/net/nfp/flower/nfp_flower.c             | 12 ++++++++++--
 drivers/net/nfp/flower/nfp_flower_representor.c | 13 +++++++++++++
 drivers/net/nfp/nfp_net_common.c                | 17 ++++++-----------
 drivers/net/nfp/nfp_net_common.h                |  9 +++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index d65fcd17cb..d0a3fc696c 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -253,6 +253,7 @@ struct nfp_net_fw_ver {
 #define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
 #define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
 #define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define   NFP_NET_CFG_RSS_CRC32           (1 << 26) /* Use CRC32 hash */
 #define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
 #define NFP_NET_CFG_RSS_KEY_SZ          0x28
 #define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index e84e6ebbff..c6a744e868 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -31,6 +31,8 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	struct nfp_net_hw *net_hw;
+	struct rte_eth_conf *dev_conf;
+	struct rte_eth_rxmode *rxmode;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
@@ -48,8 +50,14 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	/* Writing configuration parameters in the device */
 	nfp_net_params_setup(net_hw);
 
-	update |= NFP_NET_CFG_UPDATE_RSS;
-	new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	dev_conf = &dev->data->dev_conf;
+	rxmode = &dev_conf->rxmode;
+
+	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0) {
+		nfp_net_rss_config_default(dev);
+		update |= NFP_NET_CFG_UPDATE_RSS;
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	}
 
 	/* Enable device */
 	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 4f4df0cd2e..7284a1e84d 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -44,6 +44,12 @@ static int
 nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
+	struct nfp_net_hw *pf_hw;
+	struct nfp_flower_representor *repr;
+
+	repr = dev->data->dev_private;
+	pf_hw = repr->app_fw_flower->pf_hw;
+
 	/* Hardcoded pktlen and queues for now */
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = 1;
@@ -64,6 +70,13 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 
 	dev_info->max_mac_addrs = 1;
 
+	if ((pf_hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
+		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
+		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 7a0b0c9973..66aaf7ab09 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1269,16 +1269,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
-
-		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
-				RTE_ETH_RSS_NONFRAG_IPV4_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV4_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
-				RTE_ETH_RSS_IPV6 |
-				RTE_ETH_RSS_NONFRAG_IPV6_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV6_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV6_SCTP;
-
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
 		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 	}
@@ -1794,7 +1785,11 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 		cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_SCTP;
 
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_MASK;
-	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
+
+	if (nfp_net_dev_is_repr(dev))
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_CRC32;
+	else
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
 	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 1d96b0e9d1..04482455d2 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -41,6 +41,15 @@
 
 #define NFP_BEAT_LENGTH         8
 
+/* RSS capability*/
+#define NFP_NET_RSS_CAP (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
+				RTE_ETH_RSS_NONFRAG_IPV6_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
 /*
  * Each PF has corresponding word to beat:
  * Offset | Usage
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 4/4] net/nfp: support RSS flow action
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
                   ` (2 preceding siblings ...)
  2024-02-10 10:42 ` [PATCH 3/4] net/nfp: representor adds RSS configuration Chaoyong He
@ 2024-02-10 10:42 ` Chaoyong He
  2024-02-12 10:10 ` [PATCH 0/4] add support of partial offload David Marchand
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
  5 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-10 10:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of RSS action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 doc/guides/nics/features/nfp.ini              |   1 +
 drivers/net/nfp/flower/nfp_flower_flow.c      | 124 ++++++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 ++
 .../net/nfp/flower/nfp_flower_representor.c   |   6 +
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 5 files changed, 140 insertions(+)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 3494111f86..b20049b4f5 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -59,6 +59,7 @@ queue                = Y
 raw_decap            = Y
 raw_encap            = Y
 represented_port     = Y
+rss                  = Y
 port_id              = Y
 set_ipv4_dscp        = Y
 set_ipv4_dst         = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 07833fdbdb..1e208b9107 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1143,6 +1143,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3509,6 +3512,116 @@ nfp_flow_action_mark(char *act_data,
 	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
 }
 
+static int
+nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
+		const struct rte_flow_action *action,
+		struct nfp_fl_rss **rss_store)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct rte_eth_rss_conf rss_conf;
+	struct nfp_fl_rss *rss_store_tmp;
+	const struct rte_flow_action_rss *rss;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss = action->conf;
+
+	if (rss->key_len > NFP_NET_CFG_RSS_KEY_SZ) {
+		PMD_DRV_LOG(ERR, "Unsupported rss key length.");
+		return -ENOTSUP;
+	}
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		return ret;
+	}
+
+	rss_store_tmp = calloc(1, sizeof(struct nfp_fl_rss));
+	if (rss_store_tmp == NULL) {
+		PMD_DRV_LOG(ERR, "Alloc memory for rss storage failed.");
+		return -ENOMEM;
+	}
+
+	if (rss->types != 0) {
+		rss_conf.rss_hf |= rss->types;
+
+		rss_store_tmp->types = rss->types;
+	}
+
+	if (rss->key_len != 0 && rss->key != NULL) {
+		memcpy(rss_conf.rss_key, rss->key, rss->key_len);
+		rss_conf.rss_key_len = rss->key_len;
+
+		memcpy(rss_store_tmp->key, rss->key, rss->key_len);
+		rss_store_tmp->key_len = rss->key_len;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+		free(rss_store_tmp);
+		return ret;
+	}
+
+	*rss_store = rss_store_tmp;
+
+	return 0;
+}
+
+static int
+nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
+		struct rte_flow *nfp_flow)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct nfp_fl_rss *rss_store;
+	struct rte_eth_rss_conf rss_conf;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		goto exit;
+	}
+
+	rss_store = nfp_flow->rss;
+
+	if ((rss_conf.rss_hf & rss_store->types) != 0)
+		rss_conf.rss_hf &= (~(rss_store->types));
+
+	/* Need default RSS configuration */
+	if (rss_conf.rss_hf == 0)
+		rss_conf.rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6;
+
+	if (rss_conf.rss_key_len == rss_store->key_len &&
+			memcmp(rss_conf.rss_key, rss_store->key, rss_store->key_len) == 0) {
+		rss_conf.rss_key = NULL;
+		rss_conf.rss_key_len = 0;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+
+exit:
+	free(nfp_flow->rss);
+
+	return ret;
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3761,6 +3874,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 			nfp_flow_action_mark(position, action);
 			position += sizeof(struct nfp_fl_act_mark);
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS");
+			ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss);
+			if (ret != 0)
+				return ret;
+			nfp_flow->type = NFP_FLOW_RSS;
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
@@ -4099,6 +4219,10 @@ nfp_flow_destroy(struct rte_eth_dev *dev,
 		/* Delete the entry in pre tunnel table */
 		ret = nfp_pre_tun_table_check_del(representor, nfp_flow);
 		break;
+	case NFP_FLOW_RSS:
+		/* Clear corresponding RSS configuration */
+		ret = nfp_flow_action_rss_del(representor, nfp_flow);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid nfp flow type %d.", nfp_flow->type);
 		ret = -EINVAL;
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h
index 75f18c6bd5..5d927edde9 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.h
+++ b/drivers/net/nfp/flower/nfp_flower_flow.h
@@ -33,6 +33,7 @@ enum nfp_flow_type {
 	NFP_FLOW_COMMON,
 	NFP_FLOW_ENCAP,
 	NFP_FLOW_DECAP,
+	NFP_FLOW_RSS,
 };
 
 struct nfp_fl_key_ls {
@@ -121,6 +122,12 @@ struct nfp_ipv6_addr_entry {
 	int ref_count;
 };
 
+struct nfp_fl_rss {
+	uint8_t key[NFP_NET_CFG_RSS_KEY_SZ];
+	uint32_t key_len;
+	uint64_t types;
+};
+
 #define NFP_TUN_PRE_TUN_RULE_LIMIT  32
 
 struct nfp_flow_priv {
@@ -166,6 +173,7 @@ struct nfp_flow_priv {
 struct rte_flow {
 	struct nfp_fl_payload payload;
 	struct nfp_fl_tun tun;
+	struct nfp_fl_rss *rss;
 	size_t length;
 	uint32_t hash_key;
 	uint32_t mtr_id;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 7284a1e84d..b2c55879ca 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -860,3 +860,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower)
 
 	return ret;
 }
+
+bool
+nfp_flower_repr_is_vf(struct nfp_flower_representor *repr)
+{
+	return repr->repr_type == NFP_REPR_TYPE_VF;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 8053617562..7a4e7ecfc1 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -24,5 +24,6 @@ struct nfp_flower_representor {
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower);
+bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr);
 
 #endif /* __NFP_FLOWER_REPRESENTOR_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/4] add support of partial offload
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
                   ` (3 preceding siblings ...)
  2024-02-10 10:42 ` [PATCH 4/4] net/nfp: support RSS flow action Chaoyong He
@ 2024-02-12 10:10 ` David Marchand
  2024-02-17  1:31   ` Chaoyong He
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
  5 siblings, 1 reply; 22+ messages in thread
From: David Marchand @ 2024-02-12 10:10 UTC (permalink / raw)
  To: Chaoyong He; +Cc: dev, oss-drivers

On Sat, Feb 10, 2024 at 11:42 AM Chaoyong He <chaoyong.he@corigine.com> wrote:
>
> This patch series aims to add support of partial offload for NFP PMD.

Partial offload is not a DPDK thing.
I guess you are referring to OVS partial offload.
If so, it is better to make it clear so that reviewers and other that
read this thread understand what this series aims at doing.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/4] net/nfp: add interface to check representor
  2024-02-10 10:42 ` [PATCH 2/4] net/nfp: add interface to check representor Chaoyong He
@ 2024-02-12 16:24   ` Ferruh Yigit
  2024-02-17  1:31     ` Chaoyong He
  0 siblings, 1 reply; 22+ messages in thread
From: Ferruh Yigit @ 2024-02-12 16:24 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu, Peng Zhang

On 2/10/2024 10:42 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> Add a interface to check if a device is a representor.
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>

<...>

> @@ -156,6 +156,12 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
>  	[NFP_NET_CFG_STS_LINK_RATE_100G]        = RTE_ETH_SPEED_NUM_100G,
>  };
>  
> +bool
> +nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev)
> +{
> +	return ((eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
> +}
> +
>

There is similar need for other drivers too,
can you please add this as API for drivers (ethdev_driver.h), update
existing usage in other drivers, and use it in your driver?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH 2/4] net/nfp: add interface to check representor
  2024-02-12 16:24   ` Ferruh Yigit
@ 2024-02-17  1:31     ` Chaoyong He
  0 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-17  1:31 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Long Wu, Nole Zhang

> On 2/10/2024 10:42 AM, Chaoyong He wrote:
> > From: Long Wu <long.wu@corigine.com>
> >
> > Add a interface to check if a device is a representor.
> >
> > Signed-off-by: Long Wu <long.wu@corigine.com>
> > Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> 
> <...>
> 
> > @@ -156,6 +156,12 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
> >  	[NFP_NET_CFG_STS_LINK_RATE_100G]        =
> RTE_ETH_SPEED_NUM_100G,
> >  };
> >
> > +bool
> > +nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev) {
> > +	return ((eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) !=
> 0);
> > +}
> > +
> >
> 
> There is similar need for other drivers too,
> can you please add this as API for drivers (ethdev_driver.h), update
> existing usage in other drivers, and use it in your driver?

Okay, will do in next version patch, thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH 0/4] add support of partial offload
  2024-02-12 10:10 ` [PATCH 0/4] add support of partial offload David Marchand
@ 2024-02-17  1:31   ` Chaoyong He
  0 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-17  1:31 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, oss-drivers

> On Sat, Feb 10, 2024 at 11:42 AM Chaoyong He <chaoyong.he@corigine.com>
> wrote:
> >
> > This patch series aims to add support of partial offload for NFP PMD.
> 
> Partial offload is not a DPDK thing.
> I guess you are referring to OVS partial offload.
> If so, it is better to make it clear so that reviewers and other that read this thread
> understand what this series aims at doing.

Okay, will do it in next patch version, thanks.

> 
> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 0/4] add support of MARK and RSS flow action
  2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
                   ` (4 preceding siblings ...)
  2024-02-12 10:10 ` [PATCH 0/4] add support of partial offload David Marchand
@ 2024-02-23  2:42 ` Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
                     ` (4 more replies)
  5 siblings, 5 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-23  2:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series add the support of MARK and RSS flow action for NFP
PMD, also add a new function to help check if a device is representor
port.

---
v2:
* Modify the title and description of patch series to make it more
 clear.
* Add a new function to ethdev library, PMDs can use it to check if a
* device is representor port.
---

Long Wu (4):
  ethdev: add function to check representor port
  net/nfp: support MARK flow action
  net/nfp: add representor RSS configuration
  net/nfp: support RSS flow action

 doc/guides/nics/features/nfp.ini              |   1 +
 doc/guides/rel_notes/release_24_03.rst        |   3 +
 drivers/common/nfp/nfp_common_ctrl.h          |   1 +
 drivers/net/bnxt/bnxt.h                       |   3 -
 drivers/net/bnxt/bnxt_ethdev.c                |   4 +-
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c    |  12 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   4 +-
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c       |   4 +-
 drivers/net/cpfl/cpfl_representor.c           |   2 +-
 drivers/net/enic/enic.h                       |   5 -
 drivers/net/enic/enic_ethdev.c                |   2 +-
 drivers/net/enic/enic_fm_flow.c               |  20 +--
 drivers/net/enic/enic_main.c                  |   4 +-
 drivers/net/i40e/i40e_ethdev.c                |   2 +-
 drivers/net/ice/ice_dcf_ethdev.c              |   2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              |   2 +-
 drivers/net/nfp/flower/nfp_flower.c           |  12 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  16 ++
 drivers/net/nfp/flower/nfp_flower_flow.c      | 153 +++++++++++++++++-
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 +
 .../net/nfp/flower/nfp_flower_representor.c   |  19 +++
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 drivers/net/nfp/nfp_mtr.c                     |   2 +-
 drivers/net/nfp/nfp_net_common.c              |  21 +--
 drivers/net/nfp/nfp_net_common.h              |   9 ++
 drivers/net/nfp/nfp_net_flow.c                |   2 +-
 lib/ethdev/ethdev_driver.h                    |  17 ++
 27 files changed, 276 insertions(+), 55 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 1/4] ethdev: add function to check representor port
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
@ 2024-02-23  2:42   ` Chaoyong He
  2024-02-23  9:29     ` Ferruh Yigit
  2024-02-23  2:42   ` [PATCH v2 2/4] net/nfp: support MARK flow action Chaoyong He
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 22+ messages in thread
From: Chaoyong He @ 2024-02-23  2:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add a function to check if a device is representor port, also
modified the related codes for PMDs.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 doc/guides/rel_notes/release_24_03.rst     |  3 +++
 drivers/net/bnxt/bnxt.h                    |  3 ---
 drivers/net/bnxt/bnxt_ethdev.c             |  4 ++--
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 12 ++++++------
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c         |  4 ++--
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c    |  4 ++--
 drivers/net/cpfl/cpfl_representor.c        |  2 +-
 drivers/net/enic/enic.h                    |  5 -----
 drivers/net/enic/enic_ethdev.c             |  2 +-
 drivers/net/enic/enic_fm_flow.c            | 20 ++++++++++----------
 drivers/net/enic/enic_main.c               |  4 ++--
 drivers/net/i40e/i40e_ethdev.c             |  2 +-
 drivers/net/ice/ice_dcf_ethdev.c           |  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c           |  2 +-
 drivers/net/nfp/flower/nfp_flower_flow.c   |  2 +-
 drivers/net/nfp/nfp_mtr.c                  |  2 +-
 drivers/net/nfp/nfp_net_common.c           |  4 ++--
 drivers/net/nfp/nfp_net_flow.c             |  2 +-
 lib/ethdev/ethdev_driver.h                 | 17 +++++++++++++++++
 19 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index 879bb4944c..8178417b98 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -185,6 +185,9 @@ API Changes
 * ethdev: Renamed structure ``rte_flow_action_modify_data`` to be
   ``rte_flow_field_data`` for more generic usage.
 
+* ethdev: Add new function ``rte_eth_dev_is_repr()`` to check if a device is
+  representor port.
+
 
 ABI Changes
 -----------
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index fcf2b8be97..82036a16a1 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -1204,9 +1204,6 @@ extern const struct rte_flow_ops bnxt_flow_meter_ops;
 	} \
 } while (0)
 
-#define	BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)	\
-		((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
-
 extern int bnxt_logtype_driver;
 #define RTE_LOGTYPE_BNXT bnxt_logtype_driver
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f8d83662f4..825e9c1941 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3525,7 +3525,7 @@ bnxt_flow_ops_get_op(struct rte_eth_dev *dev,
 	if (!bp)
 		return -EIO;
 
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct bnxt_representor *vfr = dev->data->dev_private;
 		bp = vfr->parent_dev->data->dev_private;
 		/* parent is deleted while children are still valid */
@@ -6781,7 +6781,7 @@ static int bnxt_pci_remove(struct rte_pci_device *pci_dev)
 
 	PMD_DRV_LOG(DEBUG, "BNXT Port:%d pci remove\n", eth_dev->data->port_id);
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+		if (rte_eth_dev_is_repr(eth_dev))
 			return rte_eth_dev_destroy(eth_dev,
 						   bnxt_representor_uninit);
 		else
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
index 239191e14e..96d61c3ed2 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
@@ -202,7 +202,7 @@ bnxt_pmd_get_svif(uint16_t port_id, bool func_svif,
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -260,7 +260,7 @@ bnxt_pmd_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -285,7 +285,7 @@ bnxt_pmd_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -308,7 +308,7 @@ bnxt_pmd_get_interface_type(uint16_t port)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev))
+	if (rte_eth_dev_is_repr(eth_dev))
 		return BNXT_ULP_INTF_TYPE_VF_REP;
 
 	bp = eth_dev->data->dev_private;
@@ -330,7 +330,7 @@ bnxt_pmd_get_phy_port_id(uint16_t port_id)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -350,7 +350,7 @@ bnxt_pmd_get_parif(uint16_t port_id, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 274e935a1f..33028c470f 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -1559,7 +1559,7 @@ bnxt_ulp_destroy_vfr_default_rules(struct bnxt *bp, bool global)
 	struct rte_eth_dev *vfr_eth_dev;
 	struct bnxt_representor *vfr_bp;
 
-	if (!BNXT_TRUFLOW_EN(bp) || BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+	if (!BNXT_TRUFLOW_EN(bp) || rte_eth_dev_is_repr(bp->eth_dev))
 		return;
 
 	if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -2316,7 +2316,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 {
 	struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
 
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct bnxt_representor *vfr = dev->data->dev_private;
 
 		bp = vfr->parent_dev->data->dev_private;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
index fe1f65deb9..8237dbd294 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
@@ -449,7 +449,7 @@ bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global)
 	uint16_t port_id;
 
 	if (!BNXT_TRUFLOW_EN(bp) ||
-	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+	    rte_eth_dev_is_repr(bp->eth_dev))
 		return;
 
 	if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -514,7 +514,7 @@ bnxt_ulp_create_df_rules(struct bnxt *bp)
 	int rc = 0;
 
 	if (!BNXT_TRUFLOW_EN(bp) ||
-	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev) || !bp->ulp_ctx)
+	    rte_eth_dev_is_repr(bp->eth_dev) || !bp->ulp_ctx)
 		return 0;
 
 	port_id = bp->eth_dev->data->port_id;
diff --git a/drivers/net/cpfl/cpfl_representor.c b/drivers/net/cpfl/cpfl_representor.c
index e2ed9eda04..60b72b5ec1 100644
--- a/drivers/net/cpfl/cpfl_representor.c
+++ b/drivers/net/cpfl/cpfl_representor.c
@@ -339,7 +339,7 @@ cpfl_repr_link_update(struct rte_eth_dev *ethdev,
 	struct cpfl_vport_id vi;
 	int ret;
 
-	if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(ethdev)) {
 		PMD_INIT_LOG(ERR, "This ethdev is not representor.");
 		return -EINVAL;
 	}
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 78778704f2..f46903ea9e 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -233,11 +233,6 @@ struct enic_vf_representor {
 #define VF_ENIC_TO_VF_REP(vf_enic) \
 	container_of(vf_enic, struct enic_vf_representor, enic)
 
-static inline int enic_is_vf_rep(struct enic *enic)
-{
-	return !!(enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR);
-}
-
 /* Compute ethdev's max packet size from MTU */
 static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
 {
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 7e040c36c4..cad8db2f6f 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1386,7 +1386,7 @@ static int eth_enic_pci_remove(struct rte_pci_device *pci_dev)
 	ethdev = rte_eth_dev_allocated(pci_dev->device.name);
 	if (!ethdev)
 		return -ENODEV;
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_destroy(ethdev, enic_vf_representor_uninit);
 	else
 		return rte_eth_dev_destroy(ethdev, eth_enic_dev_uninit);
diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c
index 90027dc676..8988148454 100644
--- a/drivers/net/enic/enic_fm_flow.c
+++ b/drivers/net/enic/enic_fm_flow.c
@@ -1535,14 +1535,14 @@ vf_egress_port_id_action(struct enic_flowman *fm,
 	ENICPMD_FUNC_TRACE();
 	src_enic = fm->user_enic;
 	dst_enic = pmd_priv(dst_dev);
-	if (!(src_enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(src_enic->rte_dev)) {
 		return rte_flow_error_set(error, EINVAL,
 			RTE_FLOW_ERROR_TYPE_ACTION,
 			NULL, "source port is not VF representor");
 	}
 
 	/* VF -> PF uplink. dst is not VF representor */
-	if (!(dst_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(dst_dev)) {
 		/* PF is the VF's PF? Then nothing to do */
 		vf = VF_ENIC_TO_VF_REP(src_enic);
 		if (vf->pf == dst_enic) {
@@ -1954,7 +1954,7 @@ enic_fm_copy_action(struct enic_flowman *fm,
 	if (!(overlap & (FATE | PASSTHRU | COUNT | PORT_ID)))
 		goto unsupported;
 	/* Egress from VF: need implicit WQ match */
-	if (enic_is_vf_rep(enic) && !ingress) {
+	if (rte_eth_dev_is_repr(enic->rte_dev) && !ingress) {
 		fmt->ftm_data.fk_wq_id = 0;
 		fmt->ftm_mask.fk_wq_id = 0xffff;
 		fmt->ftm_data.fk_wq_vnic = enic->fm_vnic_handle;
@@ -3226,7 +3226,7 @@ enic_fm_init(struct enic *enic)
 		return 0;
 	ENICPMD_FUNC_TRACE();
 	/* Get vnic handle and save for port-id action */
-	if (enic_is_vf_rep(enic))
+	if (rte_eth_dev_is_repr(enic->rte_dev))
 		addr = &VF_ENIC_TO_VF_REP(enic)->bdf;
 	else
 		addr = &RTE_ETH_DEV_TO_PCI(enic->rte_dev)->addr;
@@ -3240,7 +3240,7 @@ enic_fm_init(struct enic *enic)
 	enic->fm_vnic_uif = vnic_dev_uif(enic->vdev);
 	ENICPMD_LOG(DEBUG, "uif %u", enic->fm_vnic_uif);
 	/* Nothing else to do for representor. It will share the PF flowman */
-	if (enic_is_vf_rep(enic))
+	if (rte_eth_dev_is_repr(enic->rte_dev))
 		return 0;
 	fm = calloc(1, sizeof(*fm));
 	if (fm == NULL) {
@@ -3321,7 +3321,7 @@ enic_fm_destroy(struct enic *enic)
 	struct enic_fm_fet *fet;
 
 	ENICPMD_FUNC_TRACE();
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		delete_rep_flows(enic);
 		return;
 	}
@@ -3358,7 +3358,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
 	int ret;
 
 	ENICPMD_FUNC_TRACE();
-	if (enic_is_vf_rep(pf))
+	if (rte_eth_dev_is_repr(pf->rte_dev))
 		return -EINVAL;
 	cur = pf;
 	cur_a = &RTE_ETH_DEV_TO_PCI(cur->rte_dev)->addr;
@@ -3367,7 +3367,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
 		dev = &rte_eth_devices[pid];
 		if (!dev_is_enic(dev))
 			continue;
-		if (dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+		if (rte_eth_dev_is_repr(dev))
 			continue;
 		if (dev == cur->rte_dev)
 			continue;
@@ -3597,7 +3597,7 @@ delete_rep_flows(struct enic *enic)
 	struct rte_eth_dev *dev;
 	uint32_t i;
 
-	RTE_ASSERT(enic_is_vf_rep(enic));
+	RTE_ASSERT(rte_eth_dev_is_repr(enic->rte_dev));
 	vf = VF_ENIC_TO_VF_REP(enic);
 	dev = vf->pf->rte_dev;
 	for (i = 0; i < ARRAY_SIZE(vf->vf2rep_flow); i++) {
@@ -3617,7 +3617,7 @@ begin_fm(struct enic *enic)
 	struct enic_flowman *fm;
 
 	/* Representor uses PF flowman */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		vf = VF_ENIC_TO_VF_REP(enic);
 		fm = vf->pf->fm;
 	} else {
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index a6aaa760ca..2f681315b6 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -824,7 +824,7 @@ int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
 	 * Representor uses a reserved PF queue. Translate representor
 	 * queue number to PF queue number.
 	 */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		RTE_ASSERT(queue_idx == 0);
 		vf = VF_ENIC_TO_VF_REP(enic);
 		sop_queue_idx = vf->pf_rq_sop_idx;
@@ -1053,7 +1053,7 @@ int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
 	 * Representor uses a reserved PF queue. Translate representor
 	 * queue number to PF queue number.
 	 */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		RTE_ASSERT(queue_idx == 0);
 		vf = VF_ENIC_TO_VF_REP(enic);
 		queue_idx = vf->pf_wq_idx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4d21341382..ddbc2962bc 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -706,7 +706,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
 	if (!ethdev)
 		return 0;
 
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 					i40e_vf_representor_uninit);
 	else
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index bebf356f4d..d58ec9d907 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -2131,7 +2131,7 @@ eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
 	if (!eth_dev)
 		return 0;
 
-	if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(eth_dev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 						      ice_dcf_vf_repr_uninit);
 	else
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0cd3d0b105..c61c52b296 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1842,7 +1842,7 @@ static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
 	if (!ethdev)
 		return 0;
 
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 					ixgbe_vf_representor_uninit);
 	else
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index e26be30d18..501a8d87bd 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4321,7 +4321,7 @@ int
 nfp_flow_ops_get(struct rte_eth_dev *dev,
 		const struct rte_flow_ops **ops)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!rte_eth_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is not a representor.");
 		return -EINVAL;
diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c
index 255977ec22..6abc6dc9bc 100644
--- a/drivers/net/nfp/nfp_mtr.c
+++ b/drivers/net/nfp/nfp_mtr.c
@@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = {
 int
 nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!rte_eth_dev_is_repr(dev)) {
 		PMD_DRV_LOG(ERR, "Port is not a representor");
 		return -EINVAL;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 99c319eb2d..0ee2811926 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -241,7 +241,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct nfp_flower_representor *repr;
 		repr = dev->data->dev_private;
 		hw = repr->app_fw_flower->pf_hw;
@@ -2143,7 +2143,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 
 	hw = nfp_net_get_hw(dev);
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
 			hw->ver.extend, hw->ver.class,
 			hw->ver.major, hw->ver.minor);
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 98e8499756..3b33f3b6e9 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -932,7 +932,7 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev,
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is a representor.");
 		return -EINVAL;
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 0e4c1f0743..f46c102558 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -2120,6 +2120,23 @@ struct rte_eth_fdir_conf {
 	struct rte_eth_fdir_flex_conf flex_conf;
 };
 
+/**
+ * @internal
+ * Check if the ethdev is a representor port.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  false the ethdev is not a representor port.
+ *  true  the ethdev is a representor port.
+ */
+static inline bool
+rte_eth_dev_is_repr(const struct rte_eth_dev *dev)
+{
+	return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 2/4] net/nfp: support MARK flow action
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
@ 2024-02-23  2:42   ` Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 3/4] net/nfp: add representor RSS configuration Chaoyong He
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-23  2:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of MARK action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 16 ++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.c | 27 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 8fb55f44a2..c94ea706bb 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -959,6 +959,22 @@ struct nfp_fl_act_meter {
 	rte_be32_t profile_id;
 };
 
+/*
+ * Mark
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | res |  opcode |  res  | len_lw|            reserved           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         Mark                                  |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_mark {
+	struct nfp_fl_act_head head;
+	rte_be16_t reserved;
+	rte_be32_t mark;
+};
+
 int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
 int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
 		struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 501a8d87bd..b3a2c1cdaf 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -83,6 +83,7 @@
 #define NFP_FL_ACTION_OPCODE_METER              24
 #define NFP_FL_ACTION_OPCODE_CT_NAT_EXT         25
 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE        26
+#define NFP_FL_ACTION_OPCODE_SET_MARK           27
 #define NFP_FL_ACTION_OPCODE_NUM                32
 
 #define NFP_FL_OUT_FLAGS_LAST            RTE_BIT32(15)
@@ -1138,6 +1139,10 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_CONNTRACK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3487,6 +3492,23 @@ nfp_flow_action_meter(struct nfp_flower_representor *representor,
 	return 0;
 }
 
+static void
+nfp_flow_action_mark(char *act_data,
+		const struct rte_flow_action *action)
+{
+	struct nfp_fl_act_mark *fl_mark;
+	const struct rte_flow_action_mark *mark;
+	size_t act_size = sizeof(struct nfp_fl_act_mark);
+
+	mark = action->conf;
+
+	fl_mark = (struct nfp_fl_act_mark *)act_data;
+	fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MARK;
+	fl_mark->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
+	fl_mark->reserved     = 0;
+	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3734,6 +3756,11 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_CONNTRACK");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
+			nfp_flow_action_mark(position, action);
+			position += sizeof(struct nfp_fl_act_mark);
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 3/4] net/nfp: add representor RSS configuration
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 2/4] net/nfp: support MARK flow action Chaoyong He
@ 2024-02-23  2:42   ` Chaoyong He
  2024-02-23  2:42   ` [PATCH v2 4/4] net/nfp: support RSS flow action Chaoyong He
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-23  2:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add RSS configuration logics in representor initialization function.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h            |  1 +
 drivers/net/nfp/flower/nfp_flower.c             | 12 ++++++++++--
 drivers/net/nfp/flower/nfp_flower_representor.c | 13 +++++++++++++
 drivers/net/nfp/nfp_net_common.c                | 17 ++++++-----------
 drivers/net/nfp/nfp_net_common.h                |  9 +++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 93722bc350..7749ba6459 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -254,6 +254,7 @@ struct nfp_net_fw_ver {
 #define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
 #define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
 #define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define   NFP_NET_CFG_RSS_CRC32           (1 << 26) /* Use CRC32 hash */
 #define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
 #define NFP_NET_CFG_RSS_KEY_SZ          0x28
 #define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index e84e6ebbff..c6a744e868 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -31,6 +31,8 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	struct nfp_net_hw *net_hw;
+	struct rte_eth_conf *dev_conf;
+	struct rte_eth_rxmode *rxmode;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
@@ -48,8 +50,14 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	/* Writing configuration parameters in the device */
 	nfp_net_params_setup(net_hw);
 
-	update |= NFP_NET_CFG_UPDATE_RSS;
-	new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	dev_conf = &dev->data->dev_conf;
+	rxmode = &dev_conf->rxmode;
+
+	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0) {
+		nfp_net_rss_config_default(dev);
+		update |= NFP_NET_CFG_UPDATE_RSS;
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	}
 
 	/* Enable device */
 	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 4f4df0cd2e..7284a1e84d 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -44,6 +44,12 @@ static int
 nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
+	struct nfp_net_hw *pf_hw;
+	struct nfp_flower_representor *repr;
+
+	repr = dev->data->dev_private;
+	pf_hw = repr->app_fw_flower->pf_hw;
+
 	/* Hardcoded pktlen and queues for now */
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = 1;
@@ -64,6 +70,13 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 
 	dev_info->max_mac_addrs = 1;
 
+	if ((pf_hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
+		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
+		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 0ee2811926..26ea4ec92f 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1267,16 +1267,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
-
-		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
-				RTE_ETH_RSS_NONFRAG_IPV4_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV4_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
-				RTE_ETH_RSS_IPV6 |
-				RTE_ETH_RSS_NONFRAG_IPV6_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV6_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV6_SCTP;
-
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
 		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 	}
@@ -1792,7 +1783,11 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 		cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_SCTP;
 
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_MASK;
-	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
+
+	if (rte_eth_dev_is_repr(dev))
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_CRC32;
+	else
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
 	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e374739022..1c24045b7d 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -41,6 +41,15 @@
 
 #define NFP_BEAT_LENGTH         8
 
+/* RSS capability*/
+#define NFP_NET_RSS_CAP (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
+				RTE_ETH_RSS_NONFRAG_IPV6_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
 /*
  * Each PF has corresponding word to beat:
  * Offset | Usage
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 4/4] net/nfp: support RSS flow action
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
                     ` (2 preceding siblings ...)
  2024-02-23  2:42   ` [PATCH v2 3/4] net/nfp: add representor RSS configuration Chaoyong He
@ 2024-02-23  2:42   ` Chaoyong He
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-23  2:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of RSS action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 doc/guides/nics/features/nfp.ini              |   1 +
 drivers/net/nfp/flower/nfp_flower_flow.c      | 124 ++++++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 ++
 .../net/nfp/flower/nfp_flower_representor.c   |   6 +
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 5 files changed, 140 insertions(+)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 3494111f86..b20049b4f5 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -59,6 +59,7 @@ queue                = Y
 raw_decap            = Y
 raw_encap            = Y
 represented_port     = Y
+rss                  = Y
 port_id              = Y
 set_ipv4_dscp        = Y
 set_ipv4_dst         = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index b3a2c1cdaf..086cc8079a 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1143,6 +1143,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3509,6 +3512,116 @@ nfp_flow_action_mark(char *act_data,
 	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
 }
 
+static int
+nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
+		const struct rte_flow_action *action,
+		struct nfp_fl_rss **rss_store)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct rte_eth_rss_conf rss_conf;
+	struct nfp_fl_rss *rss_store_tmp;
+	const struct rte_flow_action_rss *rss;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss = action->conf;
+
+	if (rss->key_len > NFP_NET_CFG_RSS_KEY_SZ) {
+		PMD_DRV_LOG(ERR, "Unsupported rss key length.");
+		return -ENOTSUP;
+	}
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		return ret;
+	}
+
+	rss_store_tmp = calloc(1, sizeof(struct nfp_fl_rss));
+	if (rss_store_tmp == NULL) {
+		PMD_DRV_LOG(ERR, "Alloc memory for rss storage failed.");
+		return -ENOMEM;
+	}
+
+	if (rss->types != 0) {
+		rss_conf.rss_hf |= rss->types;
+
+		rss_store_tmp->types = rss->types;
+	}
+
+	if (rss->key_len != 0 && rss->key != NULL) {
+		memcpy(rss_conf.rss_key, rss->key, rss->key_len);
+		rss_conf.rss_key_len = rss->key_len;
+
+		memcpy(rss_store_tmp->key, rss->key, rss->key_len);
+		rss_store_tmp->key_len = rss->key_len;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+		free(rss_store_tmp);
+		return ret;
+	}
+
+	*rss_store = rss_store_tmp;
+
+	return 0;
+}
+
+static int
+nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
+		struct rte_flow *nfp_flow)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct nfp_fl_rss *rss_store;
+	struct rte_eth_rss_conf rss_conf;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		goto exit;
+	}
+
+	rss_store = nfp_flow->rss;
+
+	if ((rss_conf.rss_hf & rss_store->types) != 0)
+		rss_conf.rss_hf &= (~(rss_store->types));
+
+	/* Need default RSS configuration */
+	if (rss_conf.rss_hf == 0)
+		rss_conf.rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6;
+
+	if (rss_conf.rss_key_len == rss_store->key_len &&
+			memcmp(rss_conf.rss_key, rss_store->key, rss_store->key_len) == 0) {
+		rss_conf.rss_key = NULL;
+		rss_conf.rss_key_len = 0;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+
+exit:
+	free(nfp_flow->rss);
+
+	return ret;
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3761,6 +3874,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 			nfp_flow_action_mark(position, action);
 			position += sizeof(struct nfp_fl_act_mark);
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS");
+			ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss);
+			if (ret != 0)
+				return ret;
+			nfp_flow->type = NFP_FLOW_RSS;
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
@@ -4099,6 +4219,10 @@ nfp_flow_destroy(struct rte_eth_dev *dev,
 		/* Delete the entry in pre tunnel table */
 		ret = nfp_pre_tun_table_check_del(representor, nfp_flow);
 		break;
+	case NFP_FLOW_RSS:
+		/* Clear corresponding RSS configuration */
+		ret = nfp_flow_action_rss_del(representor, nfp_flow);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid nfp flow type %d.", nfp_flow->type);
 		ret = -EINVAL;
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h
index 75f18c6bd5..5d927edde9 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.h
+++ b/drivers/net/nfp/flower/nfp_flower_flow.h
@@ -33,6 +33,7 @@ enum nfp_flow_type {
 	NFP_FLOW_COMMON,
 	NFP_FLOW_ENCAP,
 	NFP_FLOW_DECAP,
+	NFP_FLOW_RSS,
 };
 
 struct nfp_fl_key_ls {
@@ -121,6 +122,12 @@ struct nfp_ipv6_addr_entry {
 	int ref_count;
 };
 
+struct nfp_fl_rss {
+	uint8_t key[NFP_NET_CFG_RSS_KEY_SZ];
+	uint32_t key_len;
+	uint64_t types;
+};
+
 #define NFP_TUN_PRE_TUN_RULE_LIMIT  32
 
 struct nfp_flow_priv {
@@ -166,6 +173,7 @@ struct nfp_flow_priv {
 struct rte_flow {
 	struct nfp_fl_payload payload;
 	struct nfp_fl_tun tun;
+	struct nfp_fl_rss *rss;
 	size_t length;
 	uint32_t hash_key;
 	uint32_t mtr_id;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 7284a1e84d..b2c55879ca 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -860,3 +860,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower)
 
 	return ret;
 }
+
+bool
+nfp_flower_repr_is_vf(struct nfp_flower_representor *repr)
+{
+	return repr->repr_type == NFP_REPR_TYPE_VF;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 8053617562..7a4e7ecfc1 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -24,5 +24,6 @@ struct nfp_flower_representor {
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower);
+bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr);
 
 #endif /* __NFP_FLOWER_REPRESENTOR_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] ethdev: add function to check representor port
  2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
@ 2024-02-23  9:29     ` Ferruh Yigit
  0 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2024-02-23  9:29 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu, Peng Zhang

On 2/23/2024 2:42 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> Add a function to check if a device is representor port, also
> modified the related codes for PMDs.
> 

Thanks Long for the patch.

> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> ---
>  doc/guides/rel_notes/release_24_03.rst     |  3 +++
>  drivers/net/bnxt/bnxt.h                    |  3 ---
>  drivers/net/bnxt/bnxt_ethdev.c             |  4 ++--
>  drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 12 ++++++------
>  drivers/net/bnxt/tf_ulp/bnxt_ulp.c         |  4 ++--
>  drivers/net/bnxt/tf_ulp/ulp_def_rules.c    |  4 ++--
>  drivers/net/cpfl/cpfl_representor.c        |  2 +-
>  drivers/net/enic/enic.h                    |  5 -----
>  drivers/net/enic/enic_ethdev.c             |  2 +-
>  drivers/net/enic/enic_fm_flow.c            | 20 ++++++++++----------
>  drivers/net/enic/enic_main.c               |  4 ++--
>  drivers/net/i40e/i40e_ethdev.c             |  2 +-
>  drivers/net/ice/ice_dcf_ethdev.c           |  2 +-
>  drivers/net/ixgbe/ixgbe_ethdev.c           |  2 +-
>  drivers/net/nfp/flower/nfp_flower_flow.c   |  2 +-
>  drivers/net/nfp/nfp_mtr.c                  |  2 +-
>  drivers/net/nfp/nfp_net_common.c           |  4 ++--
>  drivers/net/nfp/nfp_net_flow.c             |  2 +-
>  lib/ethdev/ethdev_driver.h                 | 17 +++++++++++++++++
>  19 files changed, 54 insertions(+), 42 deletions(-)
> 

There are two more instance in 'rte_class_eth.c'

> diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
> index 879bb4944c..8178417b98 100644
> --- a/doc/guides/rel_notes/release_24_03.rst
> +++ b/doc/guides/rel_notes/release_24_03.rst
> @@ -185,6 +185,9 @@ API Changes
>  * ethdev: Renamed structure ``rte_flow_action_modify_data`` to be
>    ``rte_flow_field_data`` for more generic usage.
>  
> +* ethdev: Add new function ``rte_eth_dev_is_repr()`` to check if a device is
> +  representor port.
> +
>  

This is not user facing API, no need to update the release notes.

<...>

> +/**
> + * @internal
> + * Check if the ethdev is a representor port.
> + *
> + * @param dev
> + *  Pointer to struct rte_eth_dev.
> + *
> + * @return
> + *  false the ethdev is not a representor port.
> + *  true  the ethdev is a representor port.
> + */
> +static inline bool
> +rte_eth_dev_is_repr(const struct rte_eth_dev *dev)
> +{
> +	return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
> +}
> +

There is a 'rte_eth_representor_id_get()' API above, can you move this
new one below it to group them together?


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 0/4] add support of MARK and RSS flow action
  2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
                     ` (3 preceding siblings ...)
  2024-02-23  2:42   ` [PATCH v2 4/4] net/nfp: support RSS flow action Chaoyong He
@ 2024-02-26  1:44   ` Chaoyong He
  2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
                       ` (4 more replies)
  4 siblings, 5 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-26  1:44 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series add the support of MARK and RSS flow action for NFP
PMD, also add a new function to help check if a device is representor
port.

---
v2:
* Modify the title and description of patch series to make it more
 clear.
* Add a new function to ethdev library, PMDs can use it to check if a
* device is representor port.
v3:
* Drop the update of release notes.
* Replace two more instance in 'rte_class_eth.c' with the new add helper
 function.
---

Long Wu (4):
  ethdev: add function to check representor port
  net/nfp: support MARK flow action
  net/nfp: add representor RSS configuration
  net/nfp: support RSS flow action

 doc/guides/nics/features/nfp.ini              |   1 +
 drivers/common/nfp/nfp_common_ctrl.h          |   1 +
 drivers/net/bnxt/bnxt.h                       |   3 -
 drivers/net/bnxt/bnxt_ethdev.c                |   4 +-
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c    |  12 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   4 +-
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c       |   4 +-
 drivers/net/cpfl/cpfl_representor.c           |   2 +-
 drivers/net/enic/enic.h                       |   5 -
 drivers/net/enic/enic_ethdev.c                |   2 +-
 drivers/net/enic/enic_fm_flow.c               |  20 +--
 drivers/net/enic/enic_main.c                  |   4 +-
 drivers/net/i40e/i40e_ethdev.c                |   2 +-
 drivers/net/ice/ice_dcf_ethdev.c              |   2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              |   2 +-
 drivers/net/nfp/flower/nfp_flower.c           |  12 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  16 ++
 drivers/net/nfp/flower/nfp_flower_flow.c      | 153 +++++++++++++++++-
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 +
 .../net/nfp/flower/nfp_flower_representor.c   |  19 +++
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 drivers/net/nfp/nfp_mtr.c                     |   2 +-
 drivers/net/nfp/nfp_net_common.c              |  21 +--
 drivers/net/nfp/nfp_net_common.h              |   9 ++
 drivers/net/nfp/nfp_net_flow.c                |   2 +-
 lib/ethdev/ethdev_driver.h                    |  17 ++
 lib/ethdev/rte_class_eth.c                    |   4 +-
 27 files changed, 275 insertions(+), 57 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/4] ethdev: add function to check representor port
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
@ 2024-02-26  1:44     ` Chaoyong He
  2024-02-26 14:31       ` Ferruh Yigit
  2024-02-26  1:44     ` [PATCH v3 2/4] net/nfp: support MARK flow action Chaoyong He
                       ` (3 subsequent siblings)
  4 siblings, 1 reply; 22+ messages in thread
From: Chaoyong He @ 2024-02-26  1:44 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add a function to check if a device is representor port, also
modified the related codes for PMDs.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/bnxt/bnxt.h                    |  3 ---
 drivers/net/bnxt/bnxt_ethdev.c             |  4 ++--
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 12 ++++++------
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c         |  4 ++--
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c    |  4 ++--
 drivers/net/cpfl/cpfl_representor.c        |  2 +-
 drivers/net/enic/enic.h                    |  5 -----
 drivers/net/enic/enic_ethdev.c             |  2 +-
 drivers/net/enic/enic_fm_flow.c            | 20 ++++++++++----------
 drivers/net/enic/enic_main.c               |  4 ++--
 drivers/net/i40e/i40e_ethdev.c             |  2 +-
 drivers/net/ice/ice_dcf_ethdev.c           |  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c           |  2 +-
 drivers/net/nfp/flower/nfp_flower_flow.c   |  2 +-
 drivers/net/nfp/nfp_mtr.c                  |  2 +-
 drivers/net/nfp/nfp_net_common.c           |  4 ++--
 drivers/net/nfp/nfp_net_flow.c             |  2 +-
 lib/ethdev/ethdev_driver.h                 | 17 +++++++++++++++++
 lib/ethdev/rte_class_eth.c                 |  4 ++--
 19 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index fcf2b8be97..82036a16a1 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -1204,9 +1204,6 @@ extern const struct rte_flow_ops bnxt_flow_meter_ops;
 	} \
 } while (0)
 
-#define	BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)	\
-		((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
-
 extern int bnxt_logtype_driver;
 #define RTE_LOGTYPE_BNXT bnxt_logtype_driver
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f8d83662f4..825e9c1941 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3525,7 +3525,7 @@ bnxt_flow_ops_get_op(struct rte_eth_dev *dev,
 	if (!bp)
 		return -EIO;
 
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct bnxt_representor *vfr = dev->data->dev_private;
 		bp = vfr->parent_dev->data->dev_private;
 		/* parent is deleted while children are still valid */
@@ -6781,7 +6781,7 @@ static int bnxt_pci_remove(struct rte_pci_device *pci_dev)
 
 	PMD_DRV_LOG(DEBUG, "BNXT Port:%d pci remove\n", eth_dev->data->port_id);
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-		if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+		if (rte_eth_dev_is_repr(eth_dev))
 			return rte_eth_dev_destroy(eth_dev,
 						   bnxt_representor_uninit);
 		else
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
index 239191e14e..96d61c3ed2 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
@@ -202,7 +202,7 @@ bnxt_pmd_get_svif(uint16_t port_id, bool func_svif,
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -260,7 +260,7 @@ bnxt_pmd_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -285,7 +285,7 @@ bnxt_pmd_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -308,7 +308,7 @@ bnxt_pmd_get_interface_type(uint16_t port)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev))
+	if (rte_eth_dev_is_repr(eth_dev))
 		return BNXT_ULP_INTF_TYPE_VF_REP;
 
 	bp = eth_dev->data->dev_private;
@@ -330,7 +330,7 @@ bnxt_pmd_get_phy_port_id(uint16_t port_id)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
@@ -350,7 +350,7 @@ bnxt_pmd_get_parif(uint16_t port_id, enum bnxt_ulp_intf_type type)
 	struct bnxt *bp;
 
 	eth_dev = &rte_eth_devices[port_id];
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+	if (rte_eth_dev_is_repr(eth_dev)) {
 		struct bnxt_representor *vfr = eth_dev->data->dev_private;
 		if (!vfr)
 			return 0;
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 274e935a1f..33028c470f 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -1559,7 +1559,7 @@ bnxt_ulp_destroy_vfr_default_rules(struct bnxt *bp, bool global)
 	struct rte_eth_dev *vfr_eth_dev;
 	struct bnxt_representor *vfr_bp;
 
-	if (!BNXT_TRUFLOW_EN(bp) || BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+	if (!BNXT_TRUFLOW_EN(bp) || rte_eth_dev_is_repr(bp->eth_dev))
 		return;
 
 	if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -2316,7 +2316,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 {
 	struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
 
-	if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct bnxt_representor *vfr = dev->data->dev_private;
 
 		bp = vfr->parent_dev->data->dev_private;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
index fe1f65deb9..8237dbd294 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
@@ -449,7 +449,7 @@ bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global)
 	uint16_t port_id;
 
 	if (!BNXT_TRUFLOW_EN(bp) ||
-	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+	    rte_eth_dev_is_repr(bp->eth_dev))
 		return;
 
 	if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -514,7 +514,7 @@ bnxt_ulp_create_df_rules(struct bnxt *bp)
 	int rc = 0;
 
 	if (!BNXT_TRUFLOW_EN(bp) ||
-	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev) || !bp->ulp_ctx)
+	    rte_eth_dev_is_repr(bp->eth_dev) || !bp->ulp_ctx)
 		return 0;
 
 	port_id = bp->eth_dev->data->port_id;
diff --git a/drivers/net/cpfl/cpfl_representor.c b/drivers/net/cpfl/cpfl_representor.c
index e2ed9eda04..60b72b5ec1 100644
--- a/drivers/net/cpfl/cpfl_representor.c
+++ b/drivers/net/cpfl/cpfl_representor.c
@@ -339,7 +339,7 @@ cpfl_repr_link_update(struct rte_eth_dev *ethdev,
 	struct cpfl_vport_id vi;
 	int ret;
 
-	if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(ethdev)) {
 		PMD_INIT_LOG(ERR, "This ethdev is not representor.");
 		return -EINVAL;
 	}
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 78778704f2..f46903ea9e 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -233,11 +233,6 @@ struct enic_vf_representor {
 #define VF_ENIC_TO_VF_REP(vf_enic) \
 	container_of(vf_enic, struct enic_vf_representor, enic)
 
-static inline int enic_is_vf_rep(struct enic *enic)
-{
-	return !!(enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR);
-}
-
 /* Compute ethdev's max packet size from MTU */
 static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
 {
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 7e040c36c4..cad8db2f6f 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1386,7 +1386,7 @@ static int eth_enic_pci_remove(struct rte_pci_device *pci_dev)
 	ethdev = rte_eth_dev_allocated(pci_dev->device.name);
 	if (!ethdev)
 		return -ENODEV;
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_destroy(ethdev, enic_vf_representor_uninit);
 	else
 		return rte_eth_dev_destroy(ethdev, eth_enic_dev_uninit);
diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c
index 90027dc676..8988148454 100644
--- a/drivers/net/enic/enic_fm_flow.c
+++ b/drivers/net/enic/enic_fm_flow.c
@@ -1535,14 +1535,14 @@ vf_egress_port_id_action(struct enic_flowman *fm,
 	ENICPMD_FUNC_TRACE();
 	src_enic = fm->user_enic;
 	dst_enic = pmd_priv(dst_dev);
-	if (!(src_enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(src_enic->rte_dev)) {
 		return rte_flow_error_set(error, EINVAL,
 			RTE_FLOW_ERROR_TYPE_ACTION,
 			NULL, "source port is not VF representor");
 	}
 
 	/* VF -> PF uplink. dst is not VF representor */
-	if (!(dst_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+	if (!rte_eth_dev_is_repr(dst_dev)) {
 		/* PF is the VF's PF? Then nothing to do */
 		vf = VF_ENIC_TO_VF_REP(src_enic);
 		if (vf->pf == dst_enic) {
@@ -1954,7 +1954,7 @@ enic_fm_copy_action(struct enic_flowman *fm,
 	if (!(overlap & (FATE | PASSTHRU | COUNT | PORT_ID)))
 		goto unsupported;
 	/* Egress from VF: need implicit WQ match */
-	if (enic_is_vf_rep(enic) && !ingress) {
+	if (rte_eth_dev_is_repr(enic->rte_dev) && !ingress) {
 		fmt->ftm_data.fk_wq_id = 0;
 		fmt->ftm_mask.fk_wq_id = 0xffff;
 		fmt->ftm_data.fk_wq_vnic = enic->fm_vnic_handle;
@@ -3226,7 +3226,7 @@ enic_fm_init(struct enic *enic)
 		return 0;
 	ENICPMD_FUNC_TRACE();
 	/* Get vnic handle and save for port-id action */
-	if (enic_is_vf_rep(enic))
+	if (rte_eth_dev_is_repr(enic->rte_dev))
 		addr = &VF_ENIC_TO_VF_REP(enic)->bdf;
 	else
 		addr = &RTE_ETH_DEV_TO_PCI(enic->rte_dev)->addr;
@@ -3240,7 +3240,7 @@ enic_fm_init(struct enic *enic)
 	enic->fm_vnic_uif = vnic_dev_uif(enic->vdev);
 	ENICPMD_LOG(DEBUG, "uif %u", enic->fm_vnic_uif);
 	/* Nothing else to do for representor. It will share the PF flowman */
-	if (enic_is_vf_rep(enic))
+	if (rte_eth_dev_is_repr(enic->rte_dev))
 		return 0;
 	fm = calloc(1, sizeof(*fm));
 	if (fm == NULL) {
@@ -3321,7 +3321,7 @@ enic_fm_destroy(struct enic *enic)
 	struct enic_fm_fet *fet;
 
 	ENICPMD_FUNC_TRACE();
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		delete_rep_flows(enic);
 		return;
 	}
@@ -3358,7 +3358,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
 	int ret;
 
 	ENICPMD_FUNC_TRACE();
-	if (enic_is_vf_rep(pf))
+	if (rte_eth_dev_is_repr(pf->rte_dev))
 		return -EINVAL;
 	cur = pf;
 	cur_a = &RTE_ETH_DEV_TO_PCI(cur->rte_dev)->addr;
@@ -3367,7 +3367,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
 		dev = &rte_eth_devices[pid];
 		if (!dev_is_enic(dev))
 			continue;
-		if (dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+		if (rte_eth_dev_is_repr(dev))
 			continue;
 		if (dev == cur->rte_dev)
 			continue;
@@ -3597,7 +3597,7 @@ delete_rep_flows(struct enic *enic)
 	struct rte_eth_dev *dev;
 	uint32_t i;
 
-	RTE_ASSERT(enic_is_vf_rep(enic));
+	RTE_ASSERT(rte_eth_dev_is_repr(enic->rte_dev));
 	vf = VF_ENIC_TO_VF_REP(enic);
 	dev = vf->pf->rte_dev;
 	for (i = 0; i < ARRAY_SIZE(vf->vf2rep_flow); i++) {
@@ -3617,7 +3617,7 @@ begin_fm(struct enic *enic)
 	struct enic_flowman *fm;
 
 	/* Representor uses PF flowman */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		vf = VF_ENIC_TO_VF_REP(enic);
 		fm = vf->pf->fm;
 	} else {
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index a6aaa760ca..2f681315b6 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -824,7 +824,7 @@ int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
 	 * Representor uses a reserved PF queue. Translate representor
 	 * queue number to PF queue number.
 	 */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		RTE_ASSERT(queue_idx == 0);
 		vf = VF_ENIC_TO_VF_REP(enic);
 		sop_queue_idx = vf->pf_rq_sop_idx;
@@ -1053,7 +1053,7 @@ int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
 	 * Representor uses a reserved PF queue. Translate representor
 	 * queue number to PF queue number.
 	 */
-	if (enic_is_vf_rep(enic)) {
+	if (rte_eth_dev_is_repr(enic->rte_dev)) {
 		RTE_ASSERT(queue_idx == 0);
 		vf = VF_ENIC_TO_VF_REP(enic);
 		queue_idx = vf->pf_wq_idx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4d21341382..ddbc2962bc 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -706,7 +706,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
 	if (!ethdev)
 		return 0;
 
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 					i40e_vf_representor_uninit);
 	else
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index bebf356f4d..d58ec9d907 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -2131,7 +2131,7 @@ eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
 	if (!eth_dev)
 		return 0;
 
-	if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(eth_dev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 						      ice_dcf_vf_repr_uninit);
 	else
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0cd3d0b105..c61c52b296 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1842,7 +1842,7 @@ static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
 	if (!ethdev)
 		return 0;
 
-	if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+	if (rte_eth_dev_is_repr(ethdev))
 		return rte_eth_dev_pci_generic_remove(pci_dev,
 					ixgbe_vf_representor_uninit);
 	else
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index e26be30d18..501a8d87bd 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4321,7 +4321,7 @@ int
 nfp_flow_ops_get(struct rte_eth_dev *dev,
 		const struct rte_flow_ops **ops)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!rte_eth_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is not a representor.");
 		return -EINVAL;
diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c
index 255977ec22..6abc6dc9bc 100644
--- a/drivers/net/nfp/nfp_mtr.c
+++ b/drivers/net/nfp/nfp_mtr.c
@@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = {
 int
 nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!rte_eth_dev_is_repr(dev)) {
 		PMD_DRV_LOG(ERR, "Port is not a representor");
 		return -EINVAL;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 99c319eb2d..0ee2811926 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -241,7 +241,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		struct nfp_flower_representor *repr;
 		repr = dev->data->dev_private;
 		hw = repr->app_fw_flower->pf_hw;
@@ -2143,7 +2143,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 
 	hw = nfp_net_get_hw(dev);
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
 			hw->ver.extend, hw->ver.class,
 			hw->ver.major, hw->ver.minor);
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 98e8499756..3b33f3b6e9 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -932,7 +932,7 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev,
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (rte_eth_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is a representor.");
 		return -EINVAL;
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 0e4c1f0743..0b088fdab7 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1813,6 +1813,23 @@ rte_eth_representor_id_get(uint16_t port_id,
 			   int controller, int pf, int representor_port,
 			   uint16_t *repr_id);
 
+/**
+ * @internal
+ * Check if the ethdev is a representor port.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  false the ethdev is not a representor port.
+ *  true  the ethdev is a representor port.
+ */
+static inline bool
+rte_eth_dev_is_repr(const struct rte_eth_dev *dev)
+{
+	return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
 /**
  * PMD helper function to parse ethdev arguments
  *
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c
index bc003db8af..b52f1dd9f2 100644
--- a/lib/ethdev/rte_class_eth.c
+++ b/lib/ethdev/rte_class_eth.c
@@ -69,7 +69,7 @@ eth_representor_cmp(const char *key __rte_unused,
 	struct rte_eth_devargs eth_da;
 	uint16_t id = 0, nc, np, nf, i, c, p, f;
 
-	if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0)
+	if (!rte_eth_dev_is_repr(edev))
 		return -1; /* not a representor port */
 
 	/* Parse devargs representor values. */
@@ -143,7 +143,7 @@ eth_dev_match(const struct rte_eth_dev *edev,
 	}
 	/* if no representor key, default is to not match representor ports */
 	if (ret != 0)
-		if ((edev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0)
+		if (rte_eth_dev_is_repr(edev))
 			return -1; /* do not match any representor */
 
 	return 0;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 2/4] net/nfp: support MARK flow action
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
  2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
@ 2024-02-26  1:44     ` Chaoyong He
  2024-02-26  1:44     ` [PATCH v3 3/4] net/nfp: add representor RSS configuration Chaoyong He
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-26  1:44 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of MARK action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 16 ++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.c | 27 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 8fb55f44a2..c94ea706bb 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -959,6 +959,22 @@ struct nfp_fl_act_meter {
 	rte_be32_t profile_id;
 };
 
+/*
+ * Mark
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | res |  opcode |  res  | len_lw|            reserved           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         Mark                                  |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_mark {
+	struct nfp_fl_act_head head;
+	rte_be16_t reserved;
+	rte_be32_t mark;
+};
+
 int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
 int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
 		struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 501a8d87bd..b3a2c1cdaf 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -83,6 +83,7 @@
 #define NFP_FL_ACTION_OPCODE_METER              24
 #define NFP_FL_ACTION_OPCODE_CT_NAT_EXT         25
 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE        26
+#define NFP_FL_ACTION_OPCODE_SET_MARK           27
 #define NFP_FL_ACTION_OPCODE_NUM                32
 
 #define NFP_FL_OUT_FLAGS_LAST            RTE_BIT32(15)
@@ -1138,6 +1139,10 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_CONNTRACK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3487,6 +3492,23 @@ nfp_flow_action_meter(struct nfp_flower_representor *representor,
 	return 0;
 }
 
+static void
+nfp_flow_action_mark(char *act_data,
+		const struct rte_flow_action *action)
+{
+	struct nfp_fl_act_mark *fl_mark;
+	const struct rte_flow_action_mark *mark;
+	size_t act_size = sizeof(struct nfp_fl_act_mark);
+
+	mark = action->conf;
+
+	fl_mark = (struct nfp_fl_act_mark *)act_data;
+	fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MARK;
+	fl_mark->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
+	fl_mark->reserved     = 0;
+	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3734,6 +3756,11 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_CONNTRACK");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
+			nfp_flow_action_mark(position, action);
+			position += sizeof(struct nfp_fl_act_mark);
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 3/4] net/nfp: add representor RSS configuration
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
  2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
  2024-02-26  1:44     ` [PATCH v3 2/4] net/nfp: support MARK flow action Chaoyong He
@ 2024-02-26  1:44     ` Chaoyong He
  2024-02-26  1:45     ` [PATCH v3 4/4] net/nfp: support RSS flow action Chaoyong He
  2024-02-26 14:31     ` [PATCH v3 0/4] add support of MARK and " Ferruh Yigit
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-26  1:44 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add RSS configuration logics in representor initialization function.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h            |  1 +
 drivers/net/nfp/flower/nfp_flower.c             | 12 ++++++++++--
 drivers/net/nfp/flower/nfp_flower_representor.c | 13 +++++++++++++
 drivers/net/nfp/nfp_net_common.c                | 17 ++++++-----------
 drivers/net/nfp/nfp_net_common.h                |  9 +++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 93722bc350..7749ba6459 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -254,6 +254,7 @@ struct nfp_net_fw_ver {
 #define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
 #define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
 #define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define   NFP_NET_CFG_RSS_CRC32           (1 << 26) /* Use CRC32 hash */
 #define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
 #define NFP_NET_CFG_RSS_KEY_SZ          0x28
 #define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index e84e6ebbff..c6a744e868 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -31,6 +31,8 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	struct nfp_net_hw *net_hw;
+	struct rte_eth_conf *dev_conf;
+	struct rte_eth_rxmode *rxmode;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
@@ -48,8 +50,14 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	/* Writing configuration parameters in the device */
 	nfp_net_params_setup(net_hw);
 
-	update |= NFP_NET_CFG_UPDATE_RSS;
-	new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	dev_conf = &dev->data->dev_conf;
+	rxmode = &dev_conf->rxmode;
+
+	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0) {
+		nfp_net_rss_config_default(dev);
+		update |= NFP_NET_CFG_UPDATE_RSS;
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	}
 
 	/* Enable device */
 	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 4f4df0cd2e..7284a1e84d 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -44,6 +44,12 @@ static int
 nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
+	struct nfp_net_hw *pf_hw;
+	struct nfp_flower_representor *repr;
+
+	repr = dev->data->dev_private;
+	pf_hw = repr->app_fw_flower->pf_hw;
+
 	/* Hardcoded pktlen and queues for now */
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = 1;
@@ -64,6 +70,13 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 
 	dev_info->max_mac_addrs = 1;
 
+	if ((pf_hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
+		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
+		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 0ee2811926..26ea4ec92f 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1267,16 +1267,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
-
-		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
-				RTE_ETH_RSS_NONFRAG_IPV4_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV4_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
-				RTE_ETH_RSS_IPV6 |
-				RTE_ETH_RSS_NONFRAG_IPV6_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV6_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV6_SCTP;
-
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
 		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 	}
@@ -1792,7 +1783,11 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 		cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_SCTP;
 
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_MASK;
-	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
+
+	if (rte_eth_dev_is_repr(dev))
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_CRC32;
+	else
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
 	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e374739022..1c24045b7d 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -41,6 +41,15 @@
 
 #define NFP_BEAT_LENGTH         8
 
+/* RSS capability*/
+#define NFP_NET_RSS_CAP (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
+				RTE_ETH_RSS_NONFRAG_IPV6_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
 /*
  * Each PF has corresponding word to beat:
  * Offset | Usage
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 4/4] net/nfp: support RSS flow action
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
                       ` (2 preceding siblings ...)
  2024-02-26  1:44     ` [PATCH v3 3/4] net/nfp: add representor RSS configuration Chaoyong He
@ 2024-02-26  1:45     ` Chaoyong He
  2024-02-26 14:31     ` [PATCH v3 0/4] add support of MARK and " Ferruh Yigit
  4 siblings, 0 replies; 22+ messages in thread
From: Chaoyong He @ 2024-02-26  1:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of RSS action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 doc/guides/nics/features/nfp.ini              |   1 +
 drivers/net/nfp/flower/nfp_flower_flow.c      | 124 ++++++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.h      |   8 ++
 .../net/nfp/flower/nfp_flower_representor.c   |   6 +
 .../net/nfp/flower/nfp_flower_representor.h   |   1 +
 5 files changed, 140 insertions(+)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 3494111f86..b20049b4f5 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -59,6 +59,7 @@ queue                = Y
 raw_decap            = Y
 raw_encap            = Y
 represented_port     = Y
+rss                  = Y
 port_id              = Y
 set_ipv4_dscp        = Y
 set_ipv4_dst         = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index b3a2c1cdaf..086cc8079a 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1143,6 +1143,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3509,6 +3512,116 @@ nfp_flow_action_mark(char *act_data,
 	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
 }
 
+static int
+nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
+		const struct rte_flow_action *action,
+		struct nfp_fl_rss **rss_store)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct rte_eth_rss_conf rss_conf;
+	struct nfp_fl_rss *rss_store_tmp;
+	const struct rte_flow_action_rss *rss;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss = action->conf;
+
+	if (rss->key_len > NFP_NET_CFG_RSS_KEY_SZ) {
+		PMD_DRV_LOG(ERR, "Unsupported rss key length.");
+		return -ENOTSUP;
+	}
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		return ret;
+	}
+
+	rss_store_tmp = calloc(1, sizeof(struct nfp_fl_rss));
+	if (rss_store_tmp == NULL) {
+		PMD_DRV_LOG(ERR, "Alloc memory for rss storage failed.");
+		return -ENOMEM;
+	}
+
+	if (rss->types != 0) {
+		rss_conf.rss_hf |= rss->types;
+
+		rss_store_tmp->types = rss->types;
+	}
+
+	if (rss->key_len != 0 && rss->key != NULL) {
+		memcpy(rss_conf.rss_key, rss->key, rss->key_len);
+		rss_conf.rss_key_len = rss->key_len;
+
+		memcpy(rss_store_tmp->key, rss->key, rss->key_len);
+		rss_store_tmp->key_len = rss->key_len;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+		free(rss_store_tmp);
+		return ret;
+	}
+
+	*rss_store = rss_store_tmp;
+
+	return 0;
+}
+
+static int
+nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
+		struct rte_flow *nfp_flow)
+{
+	int ret;
+	struct nfp_net_hw *pf_hw;
+	struct nfp_fl_rss *rss_store;
+	struct rte_eth_rss_conf rss_conf;
+	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
+
+	if (nfp_flower_repr_is_vf(representor))
+		return 0;
+
+	rss_conf.rss_hf = 0;
+	rss_conf.rss_key = rss_key;
+	pf_hw = representor->app_fw_flower->pf_hw;
+	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
+		goto exit;
+	}
+
+	rss_store = nfp_flow->rss;
+
+	if ((rss_conf.rss_hf & rss_store->types) != 0)
+		rss_conf.rss_hf &= (~(rss_store->types));
+
+	/* Need default RSS configuration */
+	if (rss_conf.rss_hf == 0)
+		rss_conf.rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6;
+
+	if (rss_conf.rss_key_len == rss_store->key_len &&
+			memcmp(rss_conf.rss_key, rss_store->key, rss_store->key_len) == 0) {
+		rss_conf.rss_key = NULL;
+		rss_conf.rss_key_len = 0;
+	}
+
+	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
+
+exit:
+	free(nfp_flow->rss);
+
+	return ret;
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3761,6 +3874,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 			nfp_flow_action_mark(position, action);
 			position += sizeof(struct nfp_fl_act_mark);
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS");
+			ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss);
+			if (ret != 0)
+				return ret;
+			nfp_flow->type = NFP_FLOW_RSS;
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;
@@ -4099,6 +4219,10 @@ nfp_flow_destroy(struct rte_eth_dev *dev,
 		/* Delete the entry in pre tunnel table */
 		ret = nfp_pre_tun_table_check_del(representor, nfp_flow);
 		break;
+	case NFP_FLOW_RSS:
+		/* Clear corresponding RSS configuration */
+		ret = nfp_flow_action_rss_del(representor, nfp_flow);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid nfp flow type %d.", nfp_flow->type);
 		ret = -EINVAL;
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h
index 75f18c6bd5..5d927edde9 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.h
+++ b/drivers/net/nfp/flower/nfp_flower_flow.h
@@ -33,6 +33,7 @@ enum nfp_flow_type {
 	NFP_FLOW_COMMON,
 	NFP_FLOW_ENCAP,
 	NFP_FLOW_DECAP,
+	NFP_FLOW_RSS,
 };
 
 struct nfp_fl_key_ls {
@@ -121,6 +122,12 @@ struct nfp_ipv6_addr_entry {
 	int ref_count;
 };
 
+struct nfp_fl_rss {
+	uint8_t key[NFP_NET_CFG_RSS_KEY_SZ];
+	uint32_t key_len;
+	uint64_t types;
+};
+
 #define NFP_TUN_PRE_TUN_RULE_LIMIT  32
 
 struct nfp_flow_priv {
@@ -166,6 +173,7 @@ struct nfp_flow_priv {
 struct rte_flow {
 	struct nfp_fl_payload payload;
 	struct nfp_fl_tun tun;
+	struct nfp_fl_rss *rss;
 	size_t length;
 	uint32_t hash_key;
 	uint32_t mtr_id;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 7284a1e84d..b2c55879ca 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -860,3 +860,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower)
 
 	return ret;
 }
+
+bool
+nfp_flower_repr_is_vf(struct nfp_flower_representor *repr)
+{
+	return repr->repr_type == NFP_REPR_TYPE_VF;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 8053617562..7a4e7ecfc1 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -24,5 +24,6 @@ struct nfp_flower_representor {
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower);
+bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr);
 
 #endif /* __NFP_FLOWER_REPRESENTOR_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/4] ethdev: add function to check representor port
  2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
@ 2024-02-26 14:31       ` Ferruh Yigit
  0 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2024-02-26 14:31 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu, Peng Zhang

On 2/26/2024 1:44 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> Add a function to check if a device is representor port, also
> modified the related codes for PMDs.
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
>

Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 0/4] add support of MARK and RSS flow action
  2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
                       ` (3 preceding siblings ...)
  2024-02-26  1:45     ` [PATCH v3 4/4] net/nfp: support RSS flow action Chaoyong He
@ 2024-02-26 14:31     ` Ferruh Yigit
  4 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2024-02-26 14:31 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 2/26/2024 1:44 AM, Chaoyong He wrote:
> This patch series add the support of MARK and RSS flow action for NFP
> PMD, also add a new function to help check if a device is representor
> port.
> 
> ---
> v2:
> * Modify the title and description of patch series to make it more
>  clear.
> * Add a new function to ethdev library, PMDs can use it to check if a
> * device is representor port.
> v3:
> * Drop the update of release notes.
> * Replace two more instance in 'rte_class_eth.c' with the new add helper
>  function.
> ---
> 
> Long Wu (4):
>   ethdev: add function to check representor port
>   net/nfp: support MARK flow action
>   net/nfp: add representor RSS configuration
>   net/nfp: support RSS flow action
> 

Series applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-02-26 14:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
2024-02-10 10:42 ` [PATCH 1/4] net/nfp: support MARK flow action Chaoyong He
2024-02-10 10:42 ` [PATCH 2/4] net/nfp: add interface to check representor Chaoyong He
2024-02-12 16:24   ` Ferruh Yigit
2024-02-17  1:31     ` Chaoyong He
2024-02-10 10:42 ` [PATCH 3/4] net/nfp: representor adds RSS configuration Chaoyong He
2024-02-10 10:42 ` [PATCH 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-12 10:10 ` [PATCH 0/4] add support of partial offload David Marchand
2024-02-17  1:31   ` Chaoyong He
2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
2024-02-23  9:29     ` Ferruh Yigit
2024-02-23  2:42   ` [PATCH v2 2/4] net/nfp: support MARK flow action Chaoyong He
2024-02-23  2:42   ` [PATCH v2 3/4] net/nfp: add representor RSS configuration Chaoyong He
2024-02-23  2:42   ` [PATCH v2 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
2024-02-26 14:31       ` Ferruh Yigit
2024-02-26  1:44     ` [PATCH v3 2/4] net/nfp: support MARK flow action Chaoyong He
2024-02-26  1:44     ` [PATCH v3 3/4] net/nfp: add representor RSS configuration Chaoyong He
2024-02-26  1:45     ` [PATCH v3 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-26 14:31     ` [PATCH v3 0/4] add support of MARK and " Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).