]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net/mlx5e: Move MACsec flow steering operations to be used as core library
authorPatrisious Haddad <phaddad@nvidia.com>
Tue, 29 Nov 2022 12:50:22 +0000 (14:50 +0200)
committerLeon Romanovsky <leon@kernel.org>
Sun, 20 Aug 2023 09:35:23 +0000 (12:35 +0300)
Move MACsec flow steering operations(macsec_fs) from core/en_accel to
core/lib, this mandates moving MACsec statistics structure from the
general MACsec code header(en_accel/macsec.h) to macsec_fs header to
remove macsec_fs.h dependency over en_accel/macsec.h.

This to lay the ground for RoCE MACsec by moving all the data
that will need to be accessed by both ethernet MACsec and
RoCE MACsec to be shared at core.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/Kconfig
drivers/net/ethernet/mellanox/mlx5/core/Makefile
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.h
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c [moved from drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c with 99% similarity]
drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.h [moved from drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.h with 65% similarity]

index bb1d7b039a7e5b1d736a5c7b3b13d9801c749228..f3b284db1b5bddf53518236c9078990704ac4305 100644 (file)
@@ -139,7 +139,7 @@ config MLX5_CORE_IPOIB
        help
          MLX5 IPoIB offloads & acceleration support.
 
-config MLX5_EN_MACSEC
+config MLX5_MACSEC
        bool "Connect-X support for MACSec offload"
        depends on MLX5_CORE_EN
        depends on MACSEC
index 35f00700a4d6cacfe7593ed799c7c06888cbe250..ade063b57cd506c352b00069d1efa088000d191f 100644 (file)
@@ -94,7 +94,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib/ipoib.o ipoib/ethtool.o ipoib/ipoib
 #
 mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o
 
-mlx5_core-$(CONFIG_MLX5_EN_MACSEC) += en_accel/macsec.o en_accel/macsec_fs.o \
+mlx5_core-$(CONFIG_MLX5_MACSEC) += en_accel/macsec.o lib/macsec_fs.o \
                                      en_accel/macsec_stats.o
 
 mlx5_core-$(CONFIG_MLX5_EN_IPSEC) += en_accel/ipsec.o en_accel/ipsec_rxtx.o \
index b1807bfb815f1a43f6c5858d1a3aea5120ecb35b..b82217de9e9f1b6490a8a1e41c203fcad7d42257 100644 (file)
@@ -917,7 +917,7 @@ struct mlx5e_priv {
 
        const struct mlx5e_profile *profile;
        void                      *ppriv;
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
        struct mlx5e_macsec       *macsec;
 #endif
 #ifdef CONFIG_MLX5_EN_IPSEC
index bac4717548c67e9e6ac900929de542e1b19b6bdf..caa34b9c161e5188a9ac1607a01e8c390d95d568 100644 (file)
@@ -138,7 +138,7 @@ static inline bool mlx5e_accel_tx_begin(struct net_device *dev,
        }
 #endif
 
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
        if (unlikely(mlx5e_macsec_skb_is_offload(skb))) {
                struct mlx5e_priv *priv = netdev_priv(dev);
 
@@ -173,7 +173,7 @@ static inline void mlx5e_accel_tx_eseg(struct mlx5e_priv *priv,
                mlx5e_ipsec_tx_build_eseg(priv, skb, eseg);
 #endif
 
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
        if (unlikely(mlx5e_macsec_skb_is_offload(skb)))
                mlx5e_macsec_tx_build_eseg(priv->macsec, skb, eseg);
 #endif
index 592b165530ffa376031f19fa54736b345f9fc612..b26044efdec6a1fdc595606cb1d4cd6c1ab48974 100644 (file)
@@ -10,7 +10,6 @@
 #include "lib/aso.h"
 #include "lib/crypto.h"
 #include "en_accel/macsec.h"
-#include "en_accel/macsec_fs.h"
 
 #define MLX5_MACSEC_EPN_SCOPE_MID 0x80000000L
 #define MLX5E_MACSEC_ASO_CTX_SZ MLX5_ST_SZ_BYTES(macsec_aso)
index 347380a2cd9c7fca2b903eec872f8c1978b512fb..1f9c4a2723b2febc9ad60a88f417a84c68c574db 100644 (file)
@@ -4,32 +4,16 @@
 #ifndef __MLX5_EN_ACCEL_MACSEC_H__
 #define __MLX5_EN_ACCEL_MACSEC_H__
 
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
 
 #include <linux/mlx5/driver.h>
 #include <net/macsec.h>
 #include <net/dst_metadata.h>
-
-/* Bit31 - 30: MACsec marker, Bit15-0: MACsec id */
-#define MLX5_MACEC_RX_FS_ID_MAX USHRT_MAX /* Must be power of two */
-#define MLX5_MACSEC_RX_FS_ID_MASK MLX5_MACEC_RX_FS_ID_MAX
-#define MLX5_MACSEC_METADATA_MARKER(metadata)  ((((metadata) >> 30) & 0x3)  == 0x1)
-#define MLX5_MACSEC_RX_METADAT_HANDLE(metadata)  ((metadata) & MLX5_MACSEC_RX_FS_ID_MASK)
+#include "lib/macsec_fs.h"
 
 struct mlx5e_priv;
 struct mlx5e_macsec;
 
-struct mlx5e_macsec_stats {
-       u64 macsec_rx_pkts;
-       u64 macsec_rx_bytes;
-       u64 macsec_rx_pkts_drop;
-       u64 macsec_rx_bytes_drop;
-       u64 macsec_tx_pkts;
-       u64 macsec_tx_bytes;
-       u64 macsec_tx_pkts_drop;
-       u64 macsec_tx_bytes_drop;
-};
-
 void mlx5e_macsec_build_netdev(struct mlx5e_priv *priv);
 int mlx5e_macsec_init(struct mlx5e_priv *priv);
 void mlx5e_macsec_cleanup(struct mlx5e_priv *priv);
@@ -68,6 +52,6 @@ static inline void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev,
                                                      struct mlx5_cqe64 *cqe)
 {}
 static inline bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev) { return false; }
-#endif  /* CONFIG_MLX5_EN_MACSEC */
+#endif  /* CONFIG_MLX5_MACSEC */
 
 #endif /* __MLX5_ACCEL_EN_MACSEC_H__ */
index 4d77055abd4be3659672663e97c6b4269435119c..8d7a5a81516294565d7652c726dd3f3bcb708c31 100644 (file)
@@ -2490,7 +2490,7 @@ mlx5e_stats_grp_t mlx5e_nic_stats_grps[] = {
        &MLX5E_STATS_GRP(per_port_buff_congest),
        &MLX5E_STATS_GRP(ptp),
        &MLX5E_STATS_GRP(qos),
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
        &MLX5E_STATS_GRP(macsec_hw),
 #endif
 };
similarity index 99%
rename from drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c
rename to drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
index 7fc901a6ec5fcbb5bb5433aedf156eb318f7d052..3d816ee382e3ce4bac0daf37ca006e2fcaf3c769 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/if_vlan.h>
 #include "fs_core.h"
 #include "en/fs.h"
-#include "en_accel/macsec_fs.h"
+#include "lib/macsec_fs.h"
 #include "mlx5_core.h"
 
 /* MACsec TX flow steering */
similarity index 65%
rename from drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.h
rename to drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.h
index b429648d4ee7111d60b5640be132ba73313a8f0e..b282c0850e16f0e02fa464ec752e896050ac94d0 100644 (file)
@@ -4,9 +4,13 @@
 #ifndef __MLX5_MACSEC_STEERING_H__
 #define __MLX5_MACSEC_STEERING_H__
 
-#ifdef CONFIG_MLX5_EN_MACSEC
+#ifdef CONFIG_MLX5_MACSEC
 
-#include "en_accel/macsec.h"
+/* Bit31 - 30: MACsec marker, Bit15-0: MACsec id */
+#define MLX5_MACEC_RX_FS_ID_MAX USHRT_MAX /* Must be power of two */
+#define MLX5_MACSEC_RX_FS_ID_MASK MLX5_MACEC_RX_FS_ID_MAX
+#define MLX5_MACSEC_METADATA_MARKER(metadata)  ((((metadata) >> 30) & 0x3)  == 0x1)
+#define MLX5_MACSEC_RX_METADAT_HANDLE(metadata)  ((metadata) & MLX5_MACSEC_RX_FS_ID_MASK)
 
 #define MLX5_MACSEC_NUM_OF_SUPPORTED_INTERFACES 16
 
@@ -20,6 +24,17 @@ struct mlx5_macsec_rule_attrs {
        int action;
 };
 
+struct mlx5e_macsec_stats {
+       u64 macsec_rx_pkts;
+       u64 macsec_rx_bytes;
+       u64 macsec_rx_pkts_drop;
+       u64 macsec_rx_bytes_drop;
+       u64 macsec_tx_pkts;
+       u64 macsec_tx_bytes;
+       u64 macsec_tx_pkts_drop;
+       u64 macsec_tx_bytes_drop;
+};
+
 enum mlx5_macsec_action {
        MLX5_ACCEL_MACSEC_ACTION_ENCRYPT,
        MLX5_ACCEL_MACSEC_ACTION_DECRYPT,