Commit 21114b7feec29e4425a3ac48a037569c016a46c8

Authored by Antoine Tenart
Committed by David S. Miller
1 parent 8fa9137180

net: macsec: add support for offloading to the MAC

This patch adds a new MACsec offloading option, MACSEC_OFFLOAD_MAC,
allowing a user to select a MAC as a provider for MACsec offloading
operations.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 3 changed files with 13 additions and 2 deletions Side-by-side Diff

drivers/net/macsec.c
... ... @@ -339,7 +339,8 @@
339 339 /* Checks if a MACsec interface is being offloaded to an hardware engine */
340 340 static bool macsec_is_offloaded(struct macsec_dev *macsec)
341 341 {
342   - if (macsec->offload == MACSEC_OFFLOAD_PHY)
  342 + if (macsec->offload == MACSEC_OFFLOAD_MAC ||
  343 + macsec->offload == MACSEC_OFFLOAD_PHY)
343 344 return true;
344 345  
345 346 return false;
... ... @@ -355,6 +356,9 @@
355 356 if (offload == MACSEC_OFFLOAD_PHY)
356 357 return macsec->real_dev->phydev &&
357 358 macsec->real_dev->phydev->macsec_ops;
  359 + else if (offload == MACSEC_OFFLOAD_MAC)
  360 + return macsec->real_dev->features & NETIF_F_HW_MACSEC &&
  361 + macsec->real_dev->macsec_ops;
358 362  
359 363 return false;
360 364 }
361 365  
... ... @@ -369,9 +373,14 @@
369 373  
370 374 if (offload == MACSEC_OFFLOAD_PHY)
371 375 ctx->phydev = macsec->real_dev->phydev;
  376 + else if (offload == MACSEC_OFFLOAD_MAC)
  377 + ctx->netdev = macsec->real_dev;
372 378 }
373 379  
374   - return macsec->real_dev->phydev->macsec_ops;
  380 + if (offload == MACSEC_OFFLOAD_PHY)
  381 + return macsec->real_dev->phydev->macsec_ops;
  382 + else
  383 + return macsec->real_dev->macsec_ops;
375 384 }
376 385  
377 386 /* Returns a pointer to the MACsec ops struct if any and updates the MACsec
include/uapi/linux/if_link.h
... ... @@ -489,6 +489,7 @@
489 489 enum macsec_offload {
490 490 MACSEC_OFFLOAD_OFF = 0,
491 491 MACSEC_OFFLOAD_PHY = 1,
  492 + MACSEC_OFFLOAD_MAC = 2,
492 493 __MACSEC_OFFLOAD_END,
493 494 MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1,
494 495 };
tools/include/uapi/linux/if_link.h
... ... @@ -489,6 +489,7 @@
489 489 enum macsec_offload {
490 490 MACSEC_OFFLOAD_OFF = 0,
491 491 MACSEC_OFFLOAD_PHY = 1,
  492 + MACSEC_OFFLOAD_MAC = 2,
492 493 __MACSEC_OFFLOAD_END,
493 494 MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1,
494 495 };