Merge tag 'net-next-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_accel / macsec.c
index 51f1cd8..6b7b563 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/mlx5/device.h>
 #include <linux/mlx5/mlx5_ifc.h>
 #include <linux/xarray.h>
+#include <linux/if_vlan.h>
 
 #include "en.h"
 #include "lib/aso.h"
@@ -348,12 +349,21 @@ static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec,
        sa->macsec_rule = NULL;
 }
 
+static struct mlx5e_priv *macsec_netdev_priv(const struct net_device *dev)
+{
+#if IS_ENABLED(CONFIG_VLAN_8021Q)
+       if (is_vlan_dev(dev))
+               return netdev_priv(vlan_dev_priv(dev)->real_dev);
+#endif
+       return netdev_priv(dev);
+}
+
 static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
                                struct mlx5e_macsec_sa *sa,
                                bool encrypt,
                                bool is_tx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec *macsec = priv->macsec;
        struct mlx5_macsec_rule_attrs rule_attrs;
        struct mlx5_core_dev *mdev = priv->mdev;
@@ -427,7 +437,7 @@ static int macsec_rx_sa_active_update(struct macsec_context *ctx,
                                      struct mlx5e_macsec_sa *rx_sa,
                                      bool active)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec *macsec = priv->macsec;
        int err = 0;
 
@@ -508,9 +518,9 @@ static void update_macsec_epn(struct mlx5e_macsec_sa *sa, const struct macsec_ke
 
 static int mlx5e_macsec_add_txsa(struct macsec_context *ctx)
 {
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_tx_sc *tx_sc = &ctx->secy->tx_sc;
        const struct macsec_tx_sa *ctx_tx_sa = ctx->sa.tx_sa;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
        const struct macsec_secy *secy = ctx->secy;
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5_core_dev *mdev = priv->mdev;
@@ -583,9 +593,9 @@ out:
 
 static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx)
 {
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_tx_sc *tx_sc = &ctx->secy->tx_sc;
        const struct macsec_tx_sa *ctx_tx_sa = ctx->sa.tx_sa;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        u8 assoc_num = ctx->sa.assoc_num;
        struct mlx5e_macsec_sa *tx_sa;
@@ -645,7 +655,7 @@ out:
 
 static int mlx5e_macsec_del_txsa(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        u8 assoc_num = ctx->sa.assoc_num;
        struct mlx5e_macsec_sa *tx_sa;
@@ -696,7 +706,7 @@ static u32 mlx5e_macsec_get_sa_from_hashtable(struct rhashtable *sci_hash, sci_t
 static int mlx5e_macsec_add_rxsc(struct macsec_context *ctx)
 {
        struct mlx5e_macsec_rx_sc_xarray_element *sc_xarray_element;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_rx_sc *ctx_rx_sc = ctx->rx_sc;
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5e_macsec_rx_sc *rx_sc;
@@ -776,7 +786,7 @@ out:
 
 static int mlx5e_macsec_upd_rxsc(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_rx_sc *ctx_rx_sc = ctx->rx_sc;
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5e_macsec_rx_sc *rx_sc;
@@ -854,7 +864,7 @@ static void macsec_del_rxsc_ctx(struct mlx5e_macsec *macsec, struct mlx5e_macsec
 
 static int mlx5e_macsec_del_rxsc(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5e_macsec_rx_sc *rx_sc;
        struct mlx5e_macsec *macsec;
@@ -890,8 +900,8 @@ out:
 
 static int mlx5e_macsec_add_rxsa(struct macsec_context *ctx)
 {
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_rx_sa *ctx_rx_sa = ctx->sa.rx_sa;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5_core_dev *mdev = priv->mdev;
        u8 assoc_num = ctx->sa.assoc_num;
@@ -976,8 +986,8 @@ out:
 
 static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx)
 {
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_rx_sa *ctx_rx_sa = ctx->sa.rx_sa;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        u8 assoc_num = ctx->sa.assoc_num;
        struct mlx5e_macsec_rx_sc *rx_sc;
@@ -1033,7 +1043,7 @@ out:
 
 static int mlx5e_macsec_del_rxsa(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        sci_t sci = ctx->sa.rx_sa->sc->sci;
        struct mlx5e_macsec_rx_sc *rx_sc;
@@ -1085,7 +1095,7 @@ out:
 
 static int mlx5e_macsec_add_secy(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct net_device *dev = ctx->secy->netdev;
        const struct net_device *netdev = ctx->netdev;
        struct mlx5e_macsec_device *macsec_device;
@@ -1137,7 +1147,7 @@ out:
 static int macsec_upd_secy_hw_address(struct macsec_context *ctx,
                                      struct mlx5e_macsec_device *macsec_device)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct net_device *dev = ctx->secy->netdev;
        struct mlx5e_macsec *macsec = priv->macsec;
        struct mlx5e_macsec_rx_sc *rx_sc, *tmp;
@@ -1184,8 +1194,8 @@ out:
  */
 static int mlx5e_macsec_upd_secy(struct macsec_context *ctx)
 {
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        const struct macsec_tx_sc *tx_sc = &ctx->secy->tx_sc;
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
        const struct net_device *dev = ctx->secy->netdev;
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5e_macsec_sa *tx_sa;
@@ -1240,7 +1250,7 @@ out:
 
 static int mlx5e_macsec_del_secy(struct macsec_context *ctx)
 {
-       struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
        struct mlx5e_macsec_device *macsec_device;
        struct mlx5e_macsec_rx_sc *rx_sc, *tmp;
        struct mlx5e_macsec_sa *tx_sa;
@@ -1741,7 +1751,7 @@ void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev,
 {
        struct mlx5e_macsec_rx_sc_xarray_element *sc_xarray_element;
        u32 macsec_meta_data = be32_to_cpu(cqe->ft_metadata);
-       struct mlx5e_priv *priv = netdev_priv(netdev);
+       struct mlx5e_priv *priv = macsec_netdev_priv(netdev);
        struct mlx5e_macsec_rx_sc *rx_sc;
        struct mlx5e_macsec *macsec;
        u32  fs_id;