DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 09/13] net/nfp: improve modularazation of flower cmsg module
Date: Wed, 20 Sep 2023 19:34:50 +0800	[thread overview]
Message-ID: <20230920113454.739356-10-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230920113454.739356-1-chaoyong.he@corigine.com>

Make the header file self-containing by adding the correct include
statement.
Try to keep the API small by move the logic which need not expose from
header file to source file verbatim and remove the unused macro.
Also remove the unneeded header file include statement of source file.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.c | 12 +++-
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 81 ++++++++++++++++++++----
 drivers/net/nfp/nfp_flow.c               |  1 +
 drivers/net/nfp/nfp_mtr.h                | 68 +-------------------
 4 files changed, 82 insertions(+), 80 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 00f94c7492..0b8feec05b 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -3,14 +3,20 @@
  * All rights reserved.
  */
 
+#include "nfp_flower_cmsg.h"
+
 #include "../nfpcore/nfp_nsp.h"
+#include "../nfp_flow.h"
 #include "../nfp_logs.h"
-#include "../nfp_common.h"
-#include "nfp_flower.h"
-#include "nfp_flower_cmsg.h"
 #include "nfp_flower_ctrl.h"
 #include "nfp_flower_representor.h"
 
+static char*
+nfp_flower_cmsg_get_data(struct rte_mbuf *m)
+{
+	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+}
+
 static void *
 nfp_flower_cmsg_init(struct nfp_app_fw_flower *app_fw_flower,
 		struct rte_mbuf *m,
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39..3c2b279f40 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -6,11 +6,7 @@
 #ifndef _NFP_CMSG_H_
 #define _NFP_CMSG_H_
 
-#include <rte_byteorder.h>
-#include <rte_ether.h>
-
-#include "../nfp_mtr.h"
-#include "../nfp_flow.h"
+#include "nfp_flower.h"
 
 struct nfp_flower_cmsg_hdr {
 	rte_be16_t pad;
@@ -351,6 +347,72 @@ struct nfp_flower_stats_frame {
 	rte_be64_t stats_cookie;
 };
 
+/**
+ * See RFC 2698 for more details.
+ * Word[0](Flag options):
+ * [15] p(pps) 1 for pps, 0 for bps
+ *
+ * Meter control message
+ *  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
+ * +-------------------------------+-+---+-----+-+---------+-+---+-+
+ * |            Reserved           |p| Y |TYPE |E|  TSHFV  |P| PC|R|
+ * +-------------------------------+-+---+-----+-+---------+-+---+-+
+ * |                           Profile ID                          |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                        Token Bucket Peak                      |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                     Token Bucket Committed                    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         Peak Burst Size                       |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                      Committed Burst Size                     |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                      Peak Information Rate                    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                    Committed Information Rate                 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_cfg_head {
+	rte_be32_t flags_opts;
+	rte_be32_t profile_id;
+};
+
+/**
+ * Struct nfp_profile_conf - profile config, offload to NIC
+ * @head:        config head information
+ * @bkt_tkn_p:   token bucket peak
+ * @bkt_tkn_c:   token bucket committed
+ * @pbs:         peak burst size
+ * @cbs:         committed burst size
+ * @pir:         peak information rate
+ * @cir:         committed information rate
+ */
+struct nfp_profile_conf {
+	struct nfp_cfg_head head;
+	rte_be32_t bkt_tkn_p;
+	rte_be32_t bkt_tkn_c;
+	rte_be32_t pbs;
+	rte_be32_t cbs;
+	rte_be32_t pir;
+	rte_be32_t cir;
+};
+
+/**
+ * Struct nfp_mtr_stats_reply - meter stats, read from firmware
+ * @head:          config head information
+ * @pass_bytes:    count of passed bytes
+ * @pass_pkts:     count of passed packets
+ * @drop_bytes:    count of dropped bytes
+ * @drop_pkts:     count of dropped packets
+ */
+struct nfp_mtr_stats_reply {
+	struct nfp_cfg_head head;
+	rte_be64_t pass_bytes;
+	rte_be64_t pass_pkts;
+	rte_be64_t drop_bytes;
+	rte_be64_t drop_pkts;
+};
+
 enum nfp_flower_cmsg_port_type {
 	NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC,
 	NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT,
@@ -378,12 +440,6 @@ enum nfp_flower_cmsg_port_vnic_type {
 #define NFP_FLOWER_CMSG_PORT_PCIE_Q(x)          ((x) & 0x3f)         /* [0,5] */
 #define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(x)   ((x) & 0xff)         /* [0,7] */
 
-static inline char*
-nfp_flower_cmsg_get_data(struct rte_mbuf *m)
-{
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
-}
-
 /*
  * Metadata with L2 (1W/4B)
  * ----------------------------------------------------------------
@@ -918,6 +974,9 @@ struct nfp_fl_act_meter {
 	rte_be32_t profile_id;
 };
 
+/* Forward declaration */
+struct nfp_fl_rule_metadata;
+
 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/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 3ed78eab57..9847eb0615 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -14,6 +14,7 @@
 #include "nfp_flow.h"
 #include "nfp_logs.h"
 #include "nfp_rxtx.h"
+#include "nfp_mtr.h"
 #include "flower/nfp_flower.h"
 #include "flower/nfp_flower_cmsg.h"
 #include "flower/nfp_flower_ctrl.h"
diff --git a/drivers/net/nfp/nfp_mtr.h b/drivers/net/nfp/nfp_mtr.h
index f5406381ab..4b1360cad8 100644
--- a/drivers/net/nfp/nfp_mtr.h
+++ b/drivers/net/nfp/nfp_mtr.h
@@ -8,6 +8,8 @@
 
 #include <rte_mtr.h>
 
+#include "flower/nfp_flower_cmsg.h"
+
 /**
  * The max meter count is determined by firmware.
  * The max count is 65536 defined by OF_METER_COUNT.
@@ -16,72 +18,6 @@
 #define NFP_MAX_POLICY_CNT             NFP_MAX_MTR_CNT
 #define NFP_MAX_PROFILE_CNT            NFP_MAX_MTR_CNT
 
-/**
- * See RFC 2698 for more details.
- * Word[0](Flag options):
- * [15] p(pps) 1 for pps, 0 for bps
- *
- * Meter control message
- *  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
- * +-------------------------------+-+---+-----+-+---------+-+---+-+
- * |            Reserved           |p| Y |TYPE |E|  TSHFV  |P| PC|R|
- * +-------------------------------+-+---+-----+-+---------+-+---+-+
- * |                           Profile ID                          |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                        Token Bucket Peak                      |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                     Token Bucket Committed                    |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                         Peak Burst Size                       |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                      Committed Burst Size                     |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                      Peak Information Rate                    |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                    Committed Information Rate                 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-struct nfp_cfg_head {
-	rte_be32_t flags_opts;
-	rte_be32_t profile_id;
-};
-
-/**
- * Struct nfp_profile_conf - profile config, offload to NIC
- * @head:        config head information
- * @bkt_tkn_p:   token bucket peak
- * @bkt_tkn_c:   token bucket committed
- * @pbs:         peak burst size
- * @cbs:         committed burst size
- * @pir:         peak information rate
- * @cir:         committed information rate
- */
-struct nfp_profile_conf {
-	struct nfp_cfg_head head;
-	rte_be32_t bkt_tkn_p;
-	rte_be32_t bkt_tkn_c;
-	rte_be32_t pbs;
-	rte_be32_t cbs;
-	rte_be32_t pir;
-	rte_be32_t cir;
-};
-
-/**
- * Struct nfp_mtr_stats_reply - meter stats, read from firmware
- * @head:          config head information
- * @pass_bytes:    count of passed bytes
- * @pass_pkts:     count of passed packets
- * @drop_bytes:    count of dropped bytes
- * @drop_pkts:     count of dropped packets
- */
-struct nfp_mtr_stats_reply {
-	struct nfp_cfg_head head;
-	rte_be64_t pass_bytes;
-	rte_be64_t pass_pkts;
-	rte_be64_t drop_bytes;
-	rte_be64_t drop_pkts;
-};
-
 /**
  * Struct nfp_mtr_profile - meter profile, stored in driver
  * Can only be used by one meter
-- 
2.39.1


  parent reply	other threads:[~2023-09-20 11:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 11:34 [PATCH 00/13] improve the modularization of NFP PMD Chaoyong He
2023-09-20 11:34 ` [PATCH 01/13] net/nfp: make sure header file is self-containing Chaoyong He
2023-09-20 11:34 ` [PATCH 02/13] net/nfp: improve modularazation of rxtx module Chaoyong He
2023-09-20 11:34 ` [PATCH 03/13] net/nfp: improve modularazation of nfd3 module Chaoyong He
2023-09-20 11:34 ` [PATCH 04/13] net/nfp: improve modularazation of nfdk module Chaoyong He
2023-09-20 11:34 ` [PATCH 05/13] net/nfp: improve modularazation of common module Chaoyong He
2023-09-20 11:34 ` [PATCH 06/13] net/nfp: improve modularazation of flower module Chaoyong He
2023-09-20 11:34 ` [PATCH 07/13] net/nfp: improve modularazation of flower representor module Chaoyong He
2023-09-20 11:34 ` [PATCH 08/13] net/nfp: improve modularazation of flower ctrl module Chaoyong He
2023-09-20 11:34 ` Chaoyong He [this message]
2023-09-20 11:34 ` [PATCH 10/13] net/nfp: improve modularazation of flow module Chaoyong He
2023-09-20 11:34 ` [PATCH 11/13] net/nfp: improve modularazation of meter module Chaoyong He
2023-09-20 11:34 ` [PATCH 12/13] net/nfp: improve modularazation of CPP bridge module Chaoyong He
2023-09-20 11:34 ` [PATCH 13/13] net/nfp: cleanup the include statement of PMD Chaoyong He
2023-09-22 11:23 ` [PATCH 00/13] improve the modularization of NFP PMD Ferruh Yigit
2023-09-25  1:34   ` Chaoyong He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230920113454.739356-10-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).