[v3,17/27] net/nfp: refact the target module

Message ID 20230915091551.1459606-18-chaoyong.he@corigine.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series refact the nfpcore module |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Sept. 15, 2023, 9:15 a.m. UTC
  Move the function declaration into the header file, and sync some
logic from kernel driver.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfpcore/nfp6000/nfp6000.h  | 20 --------------------
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |  1 +
 drivers/net/nfp/nfpcore/nfp_cppcore.c      |  1 +
 drivers/net/nfp/nfpcore/nfp_mutex.c        |  2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c      |  1 -
 drivers/net/nfp/nfpcore/nfp_resource.c     |  2 +-
 drivers/net/nfp/nfpcore/nfp_rtsym.c        |  1 +
 drivers/net/nfp/nfpcore/nfp_target.c       |  7 ++++---
 drivers/net/nfp/nfpcore/nfp_target.h       | 22 ++++++++++++++++++++++
 9 files changed, 31 insertions(+), 26 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp6000/nfp6000.h b/drivers/net/nfp/nfpcore/nfp6000/nfp6000.h
index efaa87c0e5..4c9ac017cc 100644
--- a/drivers/net/nfp/nfpcore/nfp6000/nfp6000.h
+++ b/drivers/net/nfp/nfpcore/nfp6000/nfp6000.h
@@ -6,21 +6,6 @@ 
 #ifndef __NFP_NFP6000_H__
 #define __NFP_NFP6000_H__
 
-/* CPP Target IDs */
-#define NFP_CPP_TARGET_INVALID          0
-#define NFP_CPP_TARGET_NBI              1
-#define NFP_CPP_TARGET_QDR              2
-#define NFP_CPP_TARGET_ILA              6
-#define NFP_CPP_TARGET_MU               7
-#define NFP_CPP_TARGET_PCIE             9
-#define NFP_CPP_TARGET_ARM              10
-#define NFP_CPP_TARGET_CRYPTO           12
-#define NFP_CPP_TARGET_ISLAND_XPB       14      /* Shared with CAP */
-#define NFP_CPP_TARGET_ISLAND_CAP       14      /* Shared with XPB */
-#define NFP_CPP_TARGET_CT_XPB           14
-#define NFP_CPP_TARGET_LOCAL_SCRATCH    15
-#define NFP_CPP_TARGET_CLS              NFP_CPP_TARGET_LOCAL_SCRATCH
-
 #define NFP_ISL_EMEM0                   24
 
 #define NFP_MU_ADDR_ACCESS_TYPE_MASK    3ULL
@@ -52,9 +37,4 @@  nfp_cppat_mu_locality_lsb(int mode, int addr40)
 	}
 }
 
-int nfp_target_pushpull(uint32_t cpp_id, uint64_t address);
-int nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address,
-		uint32_t *cpp_target_id, uint64_t *cpp_target_address,
-		const uint32_t *imb_table);
-
 #endif /* NFP_NFP6000_H */
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index db15411eb2..310cc691cd 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
@@ -34,6 +34,7 @@ 
 
 #include "nfp_cpp.h"
 #include "nfp_logs.h"
+#include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "../nfp_logs.h"
 
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index 0f68c5d667..b7eb53697f 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -16,6 +16,7 @@ 
 
 #include "nfp_cpp.h"
 #include "nfp_logs.h"
+#include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
 #include "nfp_nffw.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c
index 85c33502ca..87a9351ff9 100644
--- a/drivers/net/nfp/nfpcore/nfp_mutex.c
+++ b/drivers/net/nfp/nfpcore/nfp_mutex.c
@@ -9,7 +9,7 @@ 
 
 #include "nfp_cpp.h"
 #include "nfp_logs.h"
-#include "nfp6000/nfp6000.h"
+#include "nfp_target.h"
 
 #define MUTEX_LOCKED(interface)  ((((uint32_t)(interface)) << 16) | 0x000f)
 #define MUTEX_UNLOCK(interface)  (0                               | 0x0000)
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index fba7a1dc12..7d8d35e3dd 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -9,7 +9,6 @@ 
 #include "nfp_cpp.h"
 #include "nfp_logs.h"
 #include "nfp_nsp.h"
-#include "nfp6000/nfp6000.h"
 
 #define NSP_ETH_NBI_PORT_COUNT          24
 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c
index e4a3a42eea..ee987c4438 100644
--- a/drivers/net/nfp/nfpcore/nfp_resource.c
+++ b/drivers/net/nfp/nfpcore/nfp_resource.c
@@ -7,7 +7,7 @@ 
 
 #include "nfp_crc.h"
 #include "nfp_logs.h"
-#include "nfp6000/nfp6000.h"
+#include "nfp_target.h"
 
 #define NFP_RESOURCE_TBL_TARGET         NFP_CPP_TARGET_MU
 #define NFP_RESOURCE_TBL_BASE           0x8100000000ULL
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c
index 2d4100dda2..022753f98a 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.c
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c
@@ -14,6 +14,7 @@ 
 
 #include "nfp_logs.h"
 #include "nfp_mip.h"
+#include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 
 enum nfp_rtsym_type {
diff --git a/drivers/net/nfp/nfpcore/nfp_target.c b/drivers/net/nfp/nfpcore/nfp_target.c
index 540b242a43..ecb45f7928 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.c
+++ b/drivers/net/nfp/nfpcore/nfp_target.c
@@ -3,6 +3,8 @@ 
  * All rights reserved.
  */
 
+#include "nfp_target.h"
+
 #include "nfp_cpp.h"
 #include "nfp6000/nfp6000.h"
 
@@ -315,8 +317,7 @@  nfp6000_mu(uint32_t cpp_id,
 	} else if (island == 1 ||
 			(island >= 4 && island <= 7) ||
 			(island >= 12 && island <= 13) ||
-			(island >= 32 && island <= 47) ||
-			(island >= 48 && island <= 51)) {
+			(island >= 32 && island <= 51)) {
 		pp = nfp6000_mu_ctm(cpp_id);
 	} else {
 		pp = -EINVAL;
@@ -510,7 +511,7 @@  nfp_target_pushpull(uint32_t cpp_id,
 		return nfp6000_cap_xpb(cpp_id);
 	case NFP_CPP_TARGET_CLS:
 		return nfp6000_cls(cpp_id);
-	case 0:
+	case NFP_CPP_TARGET_INVALID:
 		return target_rw(cpp_id, P32, 4, 4);
 	default:
 		return -EINVAL;
diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h
index 2a2f083914..47527b4040 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.h
+++ b/drivers/net/nfp/nfpcore/nfp_target.h
@@ -6,4 +6,26 @@ 
 #ifndef __NFP_TARGET_H__
 #define __NFP_TARGET_H__
 
+#include <stdint.h>
+
+/* CPP Target IDs */
+#define NFP_CPP_TARGET_INVALID          0
+#define NFP_CPP_TARGET_NBI              1
+#define NFP_CPP_TARGET_QDR              2
+#define NFP_CPP_TARGET_ILA              6
+#define NFP_CPP_TARGET_MU               7
+#define NFP_CPP_TARGET_PCIE             9
+#define NFP_CPP_TARGET_ARM              10
+#define NFP_CPP_TARGET_CRYPTO           12
+#define NFP_CPP_TARGET_ISLAND_XPB       14      /* Shared with CAP */
+#define NFP_CPP_TARGET_ISLAND_CAP       14      /* Shared with XPB */
+#define NFP_CPP_TARGET_CT_XPB           14
+#define NFP_CPP_TARGET_LOCAL_SCRATCH    15
+#define NFP_CPP_TARGET_CLS              NFP_CPP_TARGET_LOCAL_SCRATCH
+
+int nfp_target_pushpull(uint32_t cpp_id, uint64_t address);
+int nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address,
+		uint32_t *cpp_target_id, uint64_t *cpp_target_address,
+		const uint32_t *imb_table);
+
 #endif /* __NFP_TARGET_H__ */