add MACSEC hw offload to atlantic PMD
Subsystems (2)
v2 cover add MACSEC hw offload to atlantic PMD
This patchset implements MACSEC hardware offload configuration in Atlantic PMD via experimental PMD API.
There is an agreement to work on 19.08 timeframe for the generic MACSEC API inside of rte_security.
v2 changes:
- Removed public API changes for macsec, leave only PMD experimental API for MACSEC in a form, similar to what ixgbe driver provides.
- Joined doc and features update into commit where macsec features gets actually enabled
Igor Russkikh (2):
net/atlantic: bump internal driver version
net/atlantic: public experimental macsec API
Pavel Belous (5):
net/atlantic: macsec hardware structures declaration net/atlantic: enable macsec configuration net/atlantic: macsec firmware interface net/atlantic: interrupt handling of macsec events net/atlantic: implement macsec statistics
doc/guides/nics/atlantic.rst | 6 + doc/guides/nics/features/atlantic.ini | 1 + drivers/net/atlantic/Makefile | 1 + drivers/net/atlantic/atl_common.h | 2 +- drivers/net/atlantic/atl_ethdev.c | 364 +++++++++++++++++- drivers/net/atlantic/atl_ethdev.h | 14 +- drivers/net/atlantic/atl_types.h | 39 ++ drivers/net/atlantic/hw_atl/hw_atl_utils.h | 148 +++++++ .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 51 +++ drivers/net/atlantic/meson.build | 1 + drivers/net/atlantic/rte_pmd_atlantic.c | 102 +++++ drivers/net/atlantic/rte_pmd_atlantic.h | 41 ++ .../net/atlantic/rte_pmd_atlantic_version.map | 12 + 13 files changed, 765 insertions(+), 17 deletions(-) create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
Signature · 1 line
2.17.1
PATCH v2 1/7 net/atlantic: macsec hardware structures declaration
From: Pavel Belous <[email protected]>
Here we define hardware and software configuration structures for macsec interface. MACSEC itself is implemented in Phy module, but its configuration is done via firmware interface
--- drivers/net/atlantic/atl_types.h | 37 ++++++ drivers/net/atlantic/hw_atl/hw_atl_utils.h | 148 +++++++++++++++++++++ 2 files changed, 185 insertions(+)
drivers/net/atlantic/atl_types.h +37 -0
@@ -59,6 +59,39 @@ struct aq_rss_parameters {u8 indirection_table[HW_ATL_B0_RSS_REDIRECTION_MAX ]; }; +/* Macsec stuff */ +struct aq_macsec_config { +struct { +u32 macsec_enabled; +u32 encryption_enabled; +u32 replay_protection_enabled; + } common; + +struct { +u32 idx; +u32 mac[2 ];/* 6 bytes */ + } txsc; + +struct { +u32 idx; +u32 an;/* association number on the local side */ +u32 pn;/* packet number on the local side */ +u32 key[4 ];/* 128 bit key */ + } txsa; + +struct { +u32 mac[2 ];/* 6 bytes */ +u32 pi; + } rxsc; + +struct { +u32 idx; +u32 an;/* association number on the remote side */ +u32 pn;/* packet number on the remote side */ +u32 key[4 ];/* 128 bit key */ + } rxsa; +}; +struct aq_hw_cfg_s {bool is_lro;bool is_rss;
@@ -75,6 +108,7 @@ struct aq_hw_cfg_s {uint32_t flow_control;struct aq_rss_parameters aq_rss; +struct aq_macsec_config aq_macsec; };struct aq_hw_s {
@@ -143,6 +177,9 @@ struct aq_fw_ops {int (*set_eeprom)(struct aq_hw_s *self,int dev_addr,u32 *data,u32 len); +int (*send_macsec_req)(struct aq_hw_s *self, +struct macsec_msg_fw_request *req, +struct macsec_msg_fw_response *response); };struct atl_sw_stats {
drivers/net/atlantic/hw_atl/hw_atl_utils.h +148 -0
154 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/7 net/atlantic: enable macsec configuration
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
This is a driver side of macsec configuration routines. It fills in config structures and sends requests to FW for configuration activities.
We declare macsec offload bits in DPDK offload capabilities.
Also update documentation with feature matrix for the enabled feature.
--- doc/guides/nics/atlantic.rst | 6 + doc/guides/nics/features/atlantic.ini | 1 + drivers/net/atlantic/atl_ethdev.c | 216 ++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 12 ++ 4 files changed, 235 insertions(+)
doc/guides/nics/atlantic.rst +6 -0
@@ -19,6 +19,12 @@ Supported features - RSS (Receive Side Scaling) - Checksum offload - Jumbo Frame upto 16K +- MACSEC offload + +Experimental API features +^^^^^^^^^^^^^^^^^^^^^^^^^ + +- MACSEC PMD API is considered as experimental and is subject to change/removal in next DPDK releases. Configuration Information ^^^^^^^^^^^^^^^^^^^^^^^^^
doc/guides/nics/features/atlantic.ini +1 -0
@@ -20,6 +20,7 @@ VLAN filter = Y Flow control = Y CRC offload = Y VLAN offload = Y +MACsec offload = Y L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y
drivers/net/atlantic/atl_ethdev.c +216 -0
240 lines not on this page · raw message
drivers/net/atlantic/atl_ethdev.h +12 -0
@@ -104,4 +104,16 @@ uint16_t atl_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t atl_prep_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +int atl_macsec_enable (struct rte_eth_dev *dev,uint8_t encr,uint8_t repl_prot); +int atl_macsec_disable (struct rte_eth_dev *dev); +int atl_macsec_config_txsc (struct rte_eth_dev *dev,uint8_t *mac); +int atl_macsec_config_rxsc (struct rte_eth_dev *dev, +uint8_t *mac,uint16_t pi); +int atl_macsec_select_txsa (struct rte_eth_dev *dev,uint8_t idx, +uint8_t an,uint32_t pn,uint8_t *key); +int atl_macsec_select_rxsa (struct rte_eth_dev *dev,uint8_t idx, +uint8_t an,uint32_t pn,uint8_t *key); + +bool is_atlantic_supported (struct rte_eth_dev *dev); +#endif /* _ATLANTIC_ETHDEV_H_ */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 2/7] net/atlantic: enable macsec configuration
Quoted 13 lines · Igor Russkikh
From: Pavel Belous <[email protected]>
This is a driver side of macsec configuration routines. It fills in config structures and sends requests to FW for configuration activities.
We declare macsec offload bits in DPDK offload capabilities.
Also update documentation with feature matrix for the enabled feature.
Signed-off-by Pavel Belous <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
<...>
drivers/net/atlantic/atl_ethdev.c atl_dev_reset(struct rte_eth_dev *dev) · line 704
Quoted 6 lines
drivers/net/atlantic/atl_ethdev.c +2
-0@@ -698,6 +700,205 @@ atl_dev_reset(struct rte_eth_dev *dev)return ret; } +static int +atl_dev_configure_macsec (struct rte_eth_dev *dev)
The build is broken in this patch [1] because static function defined but not used, indeed this is similar for other functions but they don't cause a build error since they are not static.
It can be good to add the APIs using these functions and functions in same patch.
[1].../dpdk/drivers/net/atlantic/atl_ethdev.c:704:1: error:
‘atl_dev_configure_macsec’ defined but not used [-Werror=unused-function]
atl_dev_configure_macsec(struct rte_eth_dev *dev)
^~~~~~~~~~~~~~~~~~~~~~~~
PATCH v2 3/7 net/atlantic: macsec firmware interface
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
Implementation of firmware interface for macsec configuration. Structure with config data is written into FW memory, then we trigger FW to execute the request and wait for result.
--- drivers/net/atlantic/atl_types.h | 2 + .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+)
drivers/net/atlantic/atl_types.h +2 -0
@@ -128,6 +128,8 @@ struct aq_hw_s {struct hw_atl_stats_s last_stats;struct aq_stats_s curr_stats; +u32 caps_lo; +u64 speed;unsigned int chip_features;u32 fw_ver_actual;
drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +51 -0
73 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 4/7 net/atlantic: interrupt handling of macsec events
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
MACSEC should be configured only after link up event, thus we use link interrupt to file an alarm for configuration.
FW also uses link interrupt line to indicate incoming events from MACSEC. These may include key expiration, packet counter wrap, etc. We pass these events to the upper layers.
--- drivers/net/atlantic/atl_ethdev.c | 66 ++++++++++++++++++++++++++----- drivers/net/atlantic/atl_ethdev.h | 2 +- 2 files changed, 57 insertions(+), 11 deletions(-)
drivers/net/atlantic/atl_ethdev.c +56 -10
@@ -4,6 +4,7 @@#include <rte_string_fns.h> #include <rte_ethdev_pci.h> +#include <rte_alarm.h> #include "atl_ethdev.h" #include "atl_common.h"
@@ -1070,13 +1071,20 @@ atl_dev_supported_ptypes_get(struct rte_eth_dev *dev)return NULL ; } +static void +atl_dev_delayed_handler (void *param) +{ +struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + +atl_dev_configure_macsec (dev); +} + +/* return 0 means link status changed, -1 means not changed */ static int atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) {struct aq_hw_s *hw =ATL_DEV_PRIVATE_TO_HW (dev->data->dev_private); -struct atl_interrupt *intr = -ATL_DEV_PRIVATE_TO_INTR (dev->data->dev_private);struct rte_eth_link link, old;int err =0 ;
@@ -1103,8 +1111,6 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)return 0 ; } - intr->flags &= ~ATL_FLAG_NEED_LINK_CONFIG ; - link.link_status =ETH_LINK_UP ; link.link_duplex =ETH_LINK_FULL_DUPLEX ; link.link_speed = hw->aq_link_status.mbps;
@@ -1114,6 +1120,10 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)if (link.link_status == old.link_status)return -1 ; +if (rte_eal_alarm_set (1000 *1000 , + atl_dev_delayed_handler, (void *)dev) <0 ) +PMD_DRV_LOG (ERR ,"rte_eal_alarm_set fail" ); +return 0 ; }
@@ -1191,8 +1201,9 @@ atl_dev_interrupt_get_status(struct rte_eth_dev *dev)hw_atl_b0_hw_irq_read (hw, &cause);atl_disable_intr (hw); - intr->flags = cause &BIT (ATL_IRQ_CAUSE_LINK ) ? -ATL_FLAG_NEED_LINK_UPDATE :0 ; + +if (cause &BIT (ATL_IRQ_CAUSE_LINK )) + intr->flags |=ATL_FLAG_NEED_LINK_UPDATE ;return 0 ; }
@@ -1257,15 +1268,50 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev, {struct atl_interrupt *intr =ATL_DEV_PRIVATE_TO_INTR (dev->data->dev_private); +struct atl_adapter *adapter = + (struct atl_adapter *)dev->data->dev_private; +struct aq_hw_s *hw = &adapter->hw; + +if (!(intr->flags &ATL_FLAG_NEED_LINK_UPDATE )) + goto done; -if (intr->flags &ATL_FLAG_NEED_LINK_UPDATE ) { -atl_dev_link_update (dev,0 ); - intr->flags &= ~ATL_FLAG_NEED_LINK_UPDATE ; + intr->flags &= ~ATL_FLAG_NEED_LINK_UPDATE ; + +/* Notify userapp if link status changed */ +if (!atl_dev_link_update (dev,0 )) {atl_dev_link_status_print (dev);_rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_INTR_LSC ,NULL ); + }else { +if (hw->aq_fw_ops->send_macsec_req ==NULL ) + goto done; + +/* Check macsec Keys expired */ +struct get_stats req = {0 }; +struct macsec_msg_fw_request msg = {0 }; +struct macsec_msg_fw_response resp = {0 }; + + req.ingress_sa_index =0x0 ; + req.egress_sc_index =0x0 ; + req.egress_sa_index =0x0 ; + msg.msg_type = macsec_get_stats_msg; + msg.stats = req; + +int err = hw->aq_fw_ops->send_macsec_req (hw, &msg, &resp); +if (err) { +PMD_DRV_LOG (ERR ,"send_macsec_req fail" ); + goto done; + } +if (resp.stats.egress_threshold_expired || + resp.stats.ingress_threshold_expired || + resp.stats.egress_expired || + resp.stats.ingress_expired) { +PMD_DRV_LOG (INFO ,"RTE_ETH_EVENT_MACSEC" ); +_rte_eth_dev_callback_process (dev, +RTE_ETH_EVENT_MACSEC ,NULL ); + } } - +done:atl_enable_intr (dev);rte_intr_enable (intr_handle);
drivers/net/atlantic/atl_ethdev.h +1 -1
@@ -34,7 +34,7 @@ (&((struct atl_adapter *)adapter)->hw_cfg)#define ATL_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0) -#define ATL_FLAG_NEED_LINK_CONFIG (uint32_t)(4 << 0) +#define ATL_FLAG_MACSEC (uint32_t)(4 << 0)struct atl_interrupt {uint32_t flags;
Signature · 1 line
2.17.1
PATCH v2 5/7 net/atlantic: implement macsec statistics
In reply to Igor RusskikhFrom: Pavel Belous <[email protected]>
We add extra xstat fields to include macsec counters and stats
--- drivers/net/atlantic/atl_ethdev.c | 82 +++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 5 deletions(-)
drivers/net/atlantic/atl_ethdev.c +77 -5
@@ -193,14 +193,27 @@ static const struct rte_eth_desc_lim tx_desc_lim = { .nb_mtu_seg_max = ATL_TX_MAX_SEG, }; +enum atl_xstats_type { +XSTATS_TYPE_MSM =0 , +XSTATS_TYPE_MACSEC , +}; +#define ATL_XSTATS_FIELD (name) { \ #name, \ - offsetof(struct aq_stats_s, name) \ + offsetof(struct aq_stats_s, name), \ + XSTATS_TYPE_MSM \ +} + +#define ATL_MACSEC_XSTATS_FIELD (name) { \ + #name, \ + offsetof(struct macsec_stats, name), \ + XSTATS_TYPE_MACSEC \ }struct atl_xstats_tbl_s {const char *name;unsigned int offset; +enum atl_xstats_type type; };static struct atl_xstats_tbl_s atl_xstats_tbl[] = {
@@ -218,6 +231,38 @@ static struct atl_xstats_tbl_s atl_xstats_tbl[] = {ATL_XSTATS_FIELD (mbtc),ATL_XSTATS_FIELD (bbrc ),ATL_XSTATS_FIELD (bbtc ), +/* Ingress Common Counters */ +ATL_MACSEC_XSTATS_FIELD (in_ctl_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_tagged_miss_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_untagged_miss_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_notag_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_untagged_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_bad_tag_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_no_sci_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_unknown_sci_pkts ), +/* Ingress SA Counters */ +ATL_MACSEC_XSTATS_FIELD (in_untagged_hit_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_not_using_sa ), +ATL_MACSEC_XSTATS_FIELD (in_unused_sa ), +ATL_MACSEC_XSTATS_FIELD (in_not_valid_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_invalid_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_ok_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_unchecked_pkts ), +ATL_MACSEC_XSTATS_FIELD (in_validated_octets ), +ATL_MACSEC_XSTATS_FIELD (in_decrypted_octets ), +/* Egress Common Counters */ +ATL_MACSEC_XSTATS_FIELD (out_ctl_pkts ), +ATL_MACSEC_XSTATS_FIELD (out_unknown_sa_pkts ), +ATL_MACSEC_XSTATS_FIELD (out_untagged_pkts ), +ATL_MACSEC_XSTATS_FIELD (out_too_long ), +/* Egress SC Counters */ +ATL_MACSEC_XSTATS_FIELD (out_sc_protected_pkts ), +ATL_MACSEC_XSTATS_FIELD (out_sc_encrypted_pkts ), +/* Egress SA Counters */ +ATL_MACSEC_XSTATS_FIELD (out_sa_hit_drop_redirect ), +ATL_MACSEC_XSTATS_FIELD (out_sa_protected2_pkts ), +ATL_MACSEC_XSTATS_FIELD (out_sa_protected_pkts ), + ATL_MACSEC_XSTATS_FIELD(out_sa_encrypted_pkts), };static const struct eth_dev_ops atl_eth_dev_ops = {
@@ -968,19 +1013,46 @@ static int atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n) { - struct atl_adapter *adapter = ATL_DEV_TO_ADAPTER(dev); + struct atl_adapter *adapter = + (struct atl_adapter *)dev->data->dev_private;struct aq_hw_s *hw = &adapter->hw; +struct get_stats req = {0 }; +struct macsec_msg_fw_request msg = {0 }; +struct macsec_msg_fw_response resp = {0 }; +int err =-1 ;unsigned int i;if (!stats)return 0 ; +if (hw->aq_fw_ops->send_macsec_req !=NULL ) { + req.ingress_sa_index =0xff ; + req.egress_sc_index =0xff ; + req.egress_sa_index =0xff ; + + msg.msg_type = macsec_get_stats_msg; + msg.stats = req; + + err = hw->aq_fw_ops->send_macsec_req (hw, &msg, &resp); + } +for (i =0 ; i < n && i <RTE_DIM (atl_xstats_tbl); i++) { stats[i].id = i; - stats[i].value = *(u64 *)((uint8_t *)&hw->curr_stats + - atl_xstats_tbl[i].offset); - } +switch (atl_xstats_tbl[i].type) { +case XSTATS_TYPE_MSM : + stats[i].value = *(u64 *)((uint8_t *)&hw->curr_stats + + atl_xstats_tbl[i].offset); +break ; +case XSTATS_TYPE_MACSEC : +if (err) + goto done; + stats[i].value = *(u64 *)((uint8_t *)&resp.stats + + atl_xstats_tbl[i].offset); +break ; + } + } +done:return i; }
Signature · 1 line
2.17.1
PATCH v2 6/7 net/atlantic: bump internal driver version
In reply to Igor RusskikhVersion is synced with internal Aquantia's driver versioning
--- drivers/net/atlantic/atl_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/atlantic/atl_common.h +1 -1
@@ -5,7 +5,7 @@#ifndef AQ_COMMON_H #define AQ_COMMON_H -#define ATL_PMD_DRIVER_VERSION "0.4.1" +#define ATL_PMD_DRIVER_VERSION "0.6.7"#define PCI_VENDOR_ID_AQUANTIA 0x1D6A
Signature · 1 line
2.17.1
PATCH v2 7/7 net/atlantic: public experimental macsec API
In reply to Igor RusskikhAdd public visible macsec API functions.
These are wrappers over internal configuration routines, validating and converting port no into dev pointer
--- drivers/net/atlantic/Makefile | 1 + drivers/net/atlantic/meson.build | 1 + drivers/net/atlantic/rte_pmd_atlantic.c | 102 ++++++++++++++++++ drivers/net/atlantic/rte_pmd_atlantic.h | 41 +++++++ .../net/atlantic/rte_pmd_atlantic_version.map | 12 +++ 5 files changed, 157 insertions(+) create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
drivers/net/atlantic/Makefile +1 -0
@@ -31,5 +31,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c +SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/meson.build +1 -0
@@ -9,4 +9,5 @@ sources = files( 'hw_atl/hw_atl_llh.c', 'hw_atl/hw_atl_utils_fw2x.c', 'hw_atl/hw_atl_utils.c', + 'rte_pmd_atlantic.c', )
drivers/net/atlantic/rte_pmd_atlantic.c new file +102 -0
102 lines not on this page · raw message
drivers/net/atlantic/rte_pmd_atlantic.h new file +41 -0
41 lines not on this page · raw message
drivers/net/atlantic/rte_pmd_atlantic_version.map +12 -0
@@ -2,3 +2,15 @@ DPDK_18.11 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pmd_atl_macsec_enable; + rte_pmd_atl_macsec_disable; + rte_pmd_atl_macsec_config_txsc; + rte_pmd_atl_macsec_config_rxsc; + rte_pmd_atl_macsec_select_txsa; + rte_pmd_atl_macsec_select_rxsa; +}; +
Signature · 1 line
2.17.1