Skip to content

Commit 70ebb89

Browse files
committed
Merge: CNB94: macsec: Use helper macsec_netdev_priv for offload drivers
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3647 JIRA: https://issues.redhat.com/browse/RHEL-22387 Tested: Just built. There is no functional change for existing drivers. Commits: ``` bd9424e ("macsec: Use helper macsec_netdev_priv for offload drivers") ``` Signed-off-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Kamal Heib <kheib@redhat.com> Approved-by: Petr Oros <poros@redhat.com> Approved-by: Xin Long <lxin@redhat.com> Signed-off-by: Scott Weaver <scweaver@redhat.com>
2 parents cc601d9 + 946d0b1 commit 70ebb89

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_macsec.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int aq_get_txsc_stats(struct aq_hw_s *hw, const int sc_idx,
289289

290290
static int aq_mdo_dev_open(struct macsec_context *ctx)
291291
{
292-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
292+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
293293
int ret = 0;
294294

295295
if (netif_carrier_ok(nic->ndev))
@@ -300,7 +300,7 @@ static int aq_mdo_dev_open(struct macsec_context *ctx)
300300

301301
static int aq_mdo_dev_stop(struct macsec_context *ctx)
302302
{
303-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
303+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
304304
int i;
305305

306306
for (i = 0; i < AQ_MACSEC_MAX_SC; i++) {
@@ -439,7 +439,7 @@ static enum aq_macsec_sc_sa sc_sa_from_num_an(const int num_an)
439439

440440
static int aq_mdo_add_secy(struct macsec_context *ctx)
441441
{
442-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
442+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
443443
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
444444
const struct macsec_secy *secy = ctx->secy;
445445
enum aq_macsec_sc_sa sc_sa;
@@ -474,7 +474,7 @@ static int aq_mdo_add_secy(struct macsec_context *ctx)
474474

475475
static int aq_mdo_upd_secy(struct macsec_context *ctx)
476476
{
477-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
477+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
478478
const struct macsec_secy *secy = ctx->secy;
479479
int txsc_idx;
480480
int ret = 0;
@@ -528,7 +528,7 @@ static int aq_clear_txsc(struct aq_nic_s *nic, const int txsc_idx,
528528

529529
static int aq_mdo_del_secy(struct macsec_context *ctx)
530530
{
531-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
531+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
532532
int ret = 0;
533533

534534
if (!nic->macsec_cfg)
@@ -576,7 +576,7 @@ static int aq_update_txsa(struct aq_nic_s *nic, const unsigned int sc_idx,
576576

577577
static int aq_mdo_add_txsa(struct macsec_context *ctx)
578578
{
579-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
579+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
580580
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
581581
const struct macsec_secy *secy = ctx->secy;
582582
struct aq_macsec_txsc *aq_txsc;
@@ -603,7 +603,7 @@ static int aq_mdo_add_txsa(struct macsec_context *ctx)
603603

604604
static int aq_mdo_upd_txsa(struct macsec_context *ctx)
605605
{
606-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
606+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
607607
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
608608
const struct macsec_secy *secy = ctx->secy;
609609
struct aq_macsec_txsc *aq_txsc;
@@ -652,7 +652,7 @@ static int aq_clear_txsa(struct aq_nic_s *nic, struct aq_macsec_txsc *aq_txsc,
652652

653653
static int aq_mdo_del_txsa(struct macsec_context *ctx)
654654
{
655-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
655+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
656656
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
657657
int txsc_idx;
658658
int ret = 0;
@@ -744,7 +744,7 @@ static int aq_set_rxsc(struct aq_nic_s *nic, const u32 rxsc_idx)
744744

745745
static int aq_mdo_add_rxsc(struct macsec_context *ctx)
746746
{
747-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
747+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
748748
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
749749
const u32 rxsc_idx_max = aq_sc_idx_max(cfg->sc_sa);
750750
u32 rxsc_idx;
@@ -775,7 +775,7 @@ static int aq_mdo_add_rxsc(struct macsec_context *ctx)
775775

776776
static int aq_mdo_upd_rxsc(struct macsec_context *ctx)
777777
{
778-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
778+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
779779
int rxsc_idx;
780780
int ret = 0;
781781

@@ -838,7 +838,7 @@ static int aq_clear_rxsc(struct aq_nic_s *nic, const int rxsc_idx,
838838

839839
static int aq_mdo_del_rxsc(struct macsec_context *ctx)
840840
{
841-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
841+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
842842
enum aq_clear_type clear_type = AQ_CLEAR_SW;
843843
int rxsc_idx;
844844
int ret = 0;
@@ -906,8 +906,8 @@ static int aq_update_rxsa(struct aq_nic_s *nic, const unsigned int sc_idx,
906906

907907
static int aq_mdo_add_rxsa(struct macsec_context *ctx)
908908
{
909+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
909910
const struct macsec_rx_sc *rx_sc = ctx->sa.rx_sa->sc;
910-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
911911
const struct macsec_secy *secy = ctx->secy;
912912
struct aq_macsec_rxsc *aq_rxsc;
913913
int rxsc_idx;
@@ -933,8 +933,8 @@ static int aq_mdo_add_rxsa(struct macsec_context *ctx)
933933

934934
static int aq_mdo_upd_rxsa(struct macsec_context *ctx)
935935
{
936+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
936937
const struct macsec_rx_sc *rx_sc = ctx->sa.rx_sa->sc;
937-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
938938
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
939939
const struct macsec_secy *secy = ctx->secy;
940940
int rxsc_idx;
@@ -982,8 +982,8 @@ static int aq_clear_rxsa(struct aq_nic_s *nic, struct aq_macsec_rxsc *aq_rxsc,
982982

983983
static int aq_mdo_del_rxsa(struct macsec_context *ctx)
984984
{
985+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
985986
const struct macsec_rx_sc *rx_sc = ctx->sa.rx_sa->sc;
986-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
987987
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
988988
int rxsc_idx;
989989
int ret = 0;
@@ -1000,7 +1000,7 @@ static int aq_mdo_del_rxsa(struct macsec_context *ctx)
10001000

10011001
static int aq_mdo_get_dev_stats(struct macsec_context *ctx)
10021002
{
1003-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
1003+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
10041004
struct aq_macsec_common_stats *stats = &nic->macsec_cfg->stats;
10051005
struct aq_hw_s *hw = nic->aq_hw;
10061006

@@ -1020,7 +1020,7 @@ static int aq_mdo_get_dev_stats(struct macsec_context *ctx)
10201020

10211021
static int aq_mdo_get_tx_sc_stats(struct macsec_context *ctx)
10221022
{
1023-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
1023+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
10241024
struct aq_macsec_tx_sc_stats *stats;
10251025
struct aq_hw_s *hw = nic->aq_hw;
10261026
struct aq_macsec_txsc *aq_txsc;
@@ -1044,7 +1044,7 @@ static int aq_mdo_get_tx_sc_stats(struct macsec_context *ctx)
10441044

10451045
static int aq_mdo_get_tx_sa_stats(struct macsec_context *ctx)
10461046
{
1047-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
1047+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
10481048
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
10491049
struct aq_macsec_tx_sa_stats *stats;
10501050
struct aq_hw_s *hw = nic->aq_hw;
@@ -1084,7 +1084,7 @@ static int aq_mdo_get_tx_sa_stats(struct macsec_context *ctx)
10841084

10851085
static int aq_mdo_get_rx_sc_stats(struct macsec_context *ctx)
10861086
{
1087-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
1087+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
10881088
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
10891089
struct aq_macsec_rx_sa_stats *stats;
10901090
struct aq_hw_s *hw = nic->aq_hw;
@@ -1129,7 +1129,7 @@ static int aq_mdo_get_rx_sc_stats(struct macsec_context *ctx)
11291129

11301130
static int aq_mdo_get_rx_sa_stats(struct macsec_context *ctx)
11311131
{
1132-
struct aq_nic_s *nic = netdev_priv(ctx->netdev);
1132+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev);
11331133
struct aq_macsec_cfg *cfg = nic->macsec_cfg;
11341134
struct aq_macsec_rx_sa_stats *stats;
11351135
struct aq_hw_s *hw = nic->aq_hw;
@@ -1399,7 +1399,7 @@ static void aq_check_txsa_expiration(struct aq_nic_s *nic)
13991399
#define AQ_LOCKED_MDO_DEF(mdo) \
14001400
static int aq_locked_mdo_##mdo(struct macsec_context *ctx) \
14011401
{ \
1402-
struct aq_nic_s *nic = netdev_priv(ctx->netdev); \
1402+
struct aq_nic_s *nic = macsec_netdev_priv(ctx->netdev); \
14031403
int ret; \
14041404
mutex_lock(&nic->macsec_mutex); \
14051405
ret = aq_mdo_##mdo(ctx); \

include/net/macsec.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define _NET_MACSEC_H_
99

1010
#include <linux/u64_stats_sync.h>
11+
#include <linux/if_vlan.h>
1112
#include <uapi/linux/if_link.h>
1213
#include <uapi/linux/if_macsec.h>
1314

@@ -323,4 +324,13 @@ static inline bool macsec_send_sci(const struct macsec_secy *secy)
323324
struct net_device *macsec_get_real_dev(const struct net_device *dev);
324325
bool macsec_netdev_is_offloaded(struct net_device *dev);
325326

327+
static inline void *macsec_netdev_priv(const struct net_device *dev)
328+
{
329+
#if IS_ENABLED(CONFIG_VLAN_8021Q)
330+
if (is_vlan_dev(dev))
331+
return netdev_priv(vlan_dev_priv(dev)->real_dev);
332+
#endif
333+
return netdev_priv(dev);
334+
}
335+
326336
#endif /* _NET_MACSEC_H_ */

0 commit comments

Comments
 (0)