1993ea577SAkhil Goyal /* SPDX-License-Identifier: BSD-3-Clause 2993ea577SAkhil Goyal * Copyright(C) 2023 Marvell. 3993ea577SAkhil Goyal */ 4993ea577SAkhil Goyal 5993ea577SAkhil Goyal #include <stdio.h> 6993ea577SAkhil Goyal #include <inttypes.h> 7993ea577SAkhil Goyal 8993ea577SAkhil Goyal #include <rte_ethdev.h> 9993ea577SAkhil Goyal #include <rte_malloc.h> 10993ea577SAkhil Goyal #include <rte_security.h> 11993ea577SAkhil Goyal 12993ea577SAkhil Goyal #include "test.h" 13993ea577SAkhil Goyal #include "test_security_inline_macsec_vectors.h" 14993ea577SAkhil Goyal 15993ea577SAkhil Goyal #ifdef RTE_EXEC_ENV_WINDOWS 16993ea577SAkhil Goyal static int 17993ea577SAkhil Goyal test_inline_macsec(void) 18993ea577SAkhil Goyal { 19993ea577SAkhil Goyal printf("Inline MACsec not supported on Windows, skipping test\n"); 20993ea577SAkhil Goyal return TEST_SKIPPED; 21993ea577SAkhil Goyal } 22993ea577SAkhil Goyal 23993ea577SAkhil Goyal #else 24993ea577SAkhil Goyal 25993ea577SAkhil Goyal #define NB_ETHPORTS_USED 1 26993ea577SAkhil Goyal #define MEMPOOL_CACHE_SIZE 32 27993ea577SAkhil Goyal #define RTE_TEST_RX_DESC_DEFAULT 1024 28993ea577SAkhil Goyal #define RTE_TEST_TX_DESC_DEFAULT 1024 29993ea577SAkhil Goyal #define RTE_PORT_ALL (~(uint16_t)0x0) 30993ea577SAkhil Goyal 31993ea577SAkhil Goyal #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ 32993ea577SAkhil Goyal #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ 33993ea577SAkhil Goyal #define RX_WTHRESH 0 /**< Default values of RX write-back threshold reg. */ 34993ea577SAkhil Goyal 35993ea577SAkhil Goyal #define TX_PTHRESH 32 /**< Default values of TX prefetch threshold reg. */ 36993ea577SAkhil Goyal #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ 37993ea577SAkhil Goyal #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ 38993ea577SAkhil Goyal 39993ea577SAkhil Goyal #define MAX_TRAFFIC_BURST 2048 40993ea577SAkhil Goyal #define NB_MBUF 10240 41993ea577SAkhil Goyal 42993ea577SAkhil Goyal #define MCS_INVALID_SA 0xFFFF 43993ea577SAkhil Goyal #define MCS_DEFAULT_PN_THRESHOLD 0xFFFFF 44993ea577SAkhil Goyal 45993ea577SAkhil Goyal static struct rte_mempool *mbufpool; 46993ea577SAkhil Goyal static struct rte_mempool *sess_pool; 47993ea577SAkhil Goyal /* ethernet addresses of ports */ 48993ea577SAkhil Goyal static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; 49993ea577SAkhil Goyal 50993ea577SAkhil Goyal struct mcs_test_opts { 51993ea577SAkhil Goyal int val_frames; 52993ea577SAkhil Goyal int nb_td; 53993ea577SAkhil Goyal uint16_t mtu; 54993ea577SAkhil Goyal uint8_t sa_in_use; 55993ea577SAkhil Goyal bool encrypt; 56993ea577SAkhil Goyal bool protect_frames; 57993ea577SAkhil Goyal uint8_t sectag_insert_mode; 58993ea577SAkhil Goyal uint8_t nb_vlan; 59993ea577SAkhil Goyal uint32_t replay_win_sz; 60993ea577SAkhil Goyal uint8_t replay_protect; 61993ea577SAkhil Goyal uint8_t rekey_en; 62993ea577SAkhil Goyal const struct mcs_test_vector *rekey_td; 63993ea577SAkhil Goyal bool dump_all_stats; 64993ea577SAkhil Goyal uint8_t check_untagged_rx; 65993ea577SAkhil Goyal uint8_t check_bad_tag_cnt; 66993ea577SAkhil Goyal uint8_t check_sa_not_in_use; 67993ea577SAkhil Goyal uint8_t check_decap_stats; 68993ea577SAkhil Goyal uint8_t check_verify_only_stats; 69993ea577SAkhil Goyal uint8_t check_pkts_invalid_stats; 70993ea577SAkhil Goyal uint8_t check_pkts_unchecked_stats; 71993ea577SAkhil Goyal uint8_t check_out_pkts_untagged; 72993ea577SAkhil Goyal uint8_t check_out_pkts_toolong; 73993ea577SAkhil Goyal uint8_t check_encap_stats; 74993ea577SAkhil Goyal uint8_t check_auth_only_stats; 75993ea577SAkhil Goyal uint8_t check_sectag_interrupts; 76993ea577SAkhil Goyal }; 77993ea577SAkhil Goyal 78993ea577SAkhil Goyal static struct rte_eth_conf port_conf = { 79993ea577SAkhil Goyal .rxmode = { 80993ea577SAkhil Goyal .mq_mode = RTE_ETH_MQ_RX_NONE, 81993ea577SAkhil Goyal .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM | 82993ea577SAkhil Goyal RTE_ETH_RX_OFFLOAD_MACSEC_STRIP, 83993ea577SAkhil Goyal }, 84993ea577SAkhil Goyal .txmode = { 85993ea577SAkhil Goyal .mq_mode = RTE_ETH_MQ_TX_NONE, 86993ea577SAkhil Goyal .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | 87993ea577SAkhil Goyal RTE_ETH_TX_OFFLOAD_MACSEC_INSERT, 88993ea577SAkhil Goyal }, 89993ea577SAkhil Goyal .lpbk_mode = 1, /* enable loopback */ 90993ea577SAkhil Goyal }; 91993ea577SAkhil Goyal 92993ea577SAkhil Goyal static struct rte_eth_rxconf rx_conf = { 93993ea577SAkhil Goyal .rx_thresh = { 94993ea577SAkhil Goyal .pthresh = RX_PTHRESH, 95993ea577SAkhil Goyal .hthresh = RX_HTHRESH, 96993ea577SAkhil Goyal .wthresh = RX_WTHRESH, 97993ea577SAkhil Goyal }, 98993ea577SAkhil Goyal .rx_free_thresh = 32, 99993ea577SAkhil Goyal }; 100993ea577SAkhil Goyal 101993ea577SAkhil Goyal static struct rte_eth_txconf tx_conf = { 102993ea577SAkhil Goyal .tx_thresh = { 103993ea577SAkhil Goyal .pthresh = TX_PTHRESH, 104993ea577SAkhil Goyal .hthresh = TX_HTHRESH, 105993ea577SAkhil Goyal .wthresh = TX_WTHRESH, 106993ea577SAkhil Goyal }, 107993ea577SAkhil Goyal .tx_free_thresh = 32, /* Use PMD default values */ 108993ea577SAkhil Goyal .tx_rs_thresh = 32, /* Use PMD default values */ 109993ea577SAkhil Goyal }; 110993ea577SAkhil Goyal 111993ea577SAkhil Goyal static uint16_t port_id; 112993ea577SAkhil Goyal 113993ea577SAkhil Goyal static uint64_t link_mbps; 114993ea577SAkhil Goyal 115993ea577SAkhil Goyal static struct rte_flow *default_tx_flow[RTE_MAX_ETHPORTS]; 116993ea577SAkhil Goyal static struct rte_flow *default_rx_flow[RTE_MAX_ETHPORTS]; 117993ea577SAkhil Goyal 118993ea577SAkhil Goyal static struct rte_mbuf **tx_pkts_burst; 119993ea577SAkhil Goyal static struct rte_mbuf **rx_pkts_burst; 120993ea577SAkhil Goyal 121993ea577SAkhil Goyal static inline struct rte_mbuf * 122993ea577SAkhil Goyal init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len) 123993ea577SAkhil Goyal { 124993ea577SAkhil Goyal struct rte_mbuf *pkt; 125993ea577SAkhil Goyal 126993ea577SAkhil Goyal pkt = rte_pktmbuf_alloc(mp); 127993ea577SAkhil Goyal if (pkt == NULL) 128993ea577SAkhil Goyal return NULL; 129993ea577SAkhil Goyal 130993ea577SAkhil Goyal rte_memcpy(rte_pktmbuf_append(pkt, len), data, len); 131993ea577SAkhil Goyal 132993ea577SAkhil Goyal return pkt; 133993ea577SAkhil Goyal } 134993ea577SAkhil Goyal 135993ea577SAkhil Goyal static int 136993ea577SAkhil Goyal init_mempools(unsigned int nb_mbuf) 137993ea577SAkhil Goyal { 138993ea577SAkhil Goyal struct rte_security_ctx *sec_ctx; 139993ea577SAkhil Goyal uint16_t nb_sess = 512; 140993ea577SAkhil Goyal uint32_t sess_sz; 141993ea577SAkhil Goyal char s[64]; 142993ea577SAkhil Goyal 143993ea577SAkhil Goyal if (mbufpool == NULL) { 144993ea577SAkhil Goyal snprintf(s, sizeof(s), "mbuf_pool"); 145993ea577SAkhil Goyal mbufpool = rte_pktmbuf_pool_create(s, nb_mbuf, 146993ea577SAkhil Goyal MEMPOOL_CACHE_SIZE, 0, 147993ea577SAkhil Goyal RTE_MBUF_DEFAULT_BUF_SIZE, SOCKET_ID_ANY); 148993ea577SAkhil Goyal if (mbufpool == NULL) { 149993ea577SAkhil Goyal printf("Cannot init mbuf pool\n"); 150993ea577SAkhil Goyal return TEST_FAILED; 151993ea577SAkhil Goyal } 152993ea577SAkhil Goyal printf("Allocated mbuf pool\n"); 153993ea577SAkhil Goyal } 154993ea577SAkhil Goyal 155993ea577SAkhil Goyal sec_ctx = rte_eth_dev_get_sec_ctx(port_id); 156993ea577SAkhil Goyal if (sec_ctx == NULL) { 157993ea577SAkhil Goyal printf("Device does not support Security ctx\n"); 158993ea577SAkhil Goyal return TEST_SKIPPED; 159993ea577SAkhil Goyal } 160993ea577SAkhil Goyal sess_sz = rte_security_session_get_size(sec_ctx); 161993ea577SAkhil Goyal if (sess_pool == NULL) { 162993ea577SAkhil Goyal snprintf(s, sizeof(s), "sess_pool"); 163993ea577SAkhil Goyal sess_pool = rte_mempool_create(s, nb_sess, sess_sz, 164993ea577SAkhil Goyal MEMPOOL_CACHE_SIZE, 0, 165993ea577SAkhil Goyal NULL, NULL, NULL, NULL, 166993ea577SAkhil Goyal SOCKET_ID_ANY, 0); 167993ea577SAkhil Goyal if (sess_pool == NULL) { 168993ea577SAkhil Goyal printf("Cannot init sess pool\n"); 169993ea577SAkhil Goyal return TEST_FAILED; 170993ea577SAkhil Goyal } 171993ea577SAkhil Goyal printf("Allocated sess pool\n"); 172993ea577SAkhil Goyal } 173993ea577SAkhil Goyal 174993ea577SAkhil Goyal return 0; 175993ea577SAkhil Goyal } 176993ea577SAkhil Goyal 177993ea577SAkhil Goyal static void 178993ea577SAkhil Goyal fill_macsec_sa_conf(const struct mcs_test_vector *td, struct rte_security_macsec_sa *sa, 179993ea577SAkhil Goyal enum rte_security_macsec_direction dir, uint8_t an, uint8_t tci_off) 180993ea577SAkhil Goyal { 181993ea577SAkhil Goyal sa->dir = dir; 182993ea577SAkhil Goyal 183993ea577SAkhil Goyal sa->key.data = td->sa_key.data; 184993ea577SAkhil Goyal sa->key.length = td->sa_key.len; 185993ea577SAkhil Goyal 186993ea577SAkhil Goyal memcpy((uint8_t *)sa->salt, (const uint8_t *)td->salt, RTE_SECURITY_MACSEC_SALT_LEN); 187993ea577SAkhil Goyal 188993ea577SAkhil Goyal /* AN is set as per the value in secure packet in test vector */ 189993ea577SAkhil Goyal sa->an = an & RTE_MACSEC_AN_MASK; 190993ea577SAkhil Goyal 191993ea577SAkhil Goyal sa->ssci = td->ssci; 192993ea577SAkhil Goyal sa->xpn = td->xpn; 193993ea577SAkhil Goyal /* Starting packet number which is expected to come next. 194993ea577SAkhil Goyal * It is take from the test vector so that we can match the out packet. 195993ea577SAkhil Goyal */ 196993ea577SAkhil Goyal sa->next_pn = *(const uint32_t *)(&td->secure_pkt.data[tci_off + 2]); 197993ea577SAkhil Goyal } 198993ea577SAkhil Goyal 199993ea577SAkhil Goyal static void 200993ea577SAkhil Goyal fill_macsec_sc_conf(const struct mcs_test_vector *td, 201993ea577SAkhil Goyal struct rte_security_macsec_sc *sc_conf, 202993ea577SAkhil Goyal const struct mcs_test_opts *opts, 203993ea577SAkhil Goyal enum rte_security_macsec_direction dir, 204993ea577SAkhil Goyal uint16_t sa_id[], uint8_t tci_off) 205993ea577SAkhil Goyal { 206993ea577SAkhil Goyal uint8_t i; 207993ea577SAkhil Goyal 208993ea577SAkhil Goyal sc_conf->dir = dir; 209993ea577SAkhil Goyal if (dir == RTE_SECURITY_MACSEC_DIR_TX) { 210993ea577SAkhil Goyal sc_conf->sc_tx.sa_id = sa_id[0]; 211993ea577SAkhil Goyal if (sa_id[1] != MCS_INVALID_SA) { 212993ea577SAkhil Goyal sc_conf->sc_tx.sa_id_rekey = sa_id[1]; 213993ea577SAkhil Goyal sc_conf->sc_tx.re_key_en = 1; 214993ea577SAkhil Goyal } 215993ea577SAkhil Goyal sc_conf->sc_tx.active = 1; 216993ea577SAkhil Goyal /* is SCI valid */ 217993ea577SAkhil Goyal if (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_SC) { 218993ea577SAkhil Goyal memcpy(&sc_conf->sc_tx.sci, &td->secure_pkt.data[tci_off + 6], 219993ea577SAkhil Goyal sizeof(sc_conf->sc_tx.sci)); 220993ea577SAkhil Goyal sc_conf->sc_tx.sci = rte_be_to_cpu_64(sc_conf->sc_tx.sci); 221993ea577SAkhil Goyal } else if (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_ES) { 222993ea577SAkhil Goyal /* sci = source_mac + port_id when ES.bit = 1 & SC.bit = 0 */ 223993ea577SAkhil Goyal const uint8_t *smac = td->plain_pkt.data + RTE_ETHER_ADDR_LEN; 224993ea577SAkhil Goyal uint8_t *ptr = (uint8_t *)&sc_conf->sc_tx.sci; 225993ea577SAkhil Goyal 226993ea577SAkhil Goyal ptr[0] = 0x01; 227993ea577SAkhil Goyal ptr[1] = 0; 228993ea577SAkhil Goyal for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) 229993ea577SAkhil Goyal ptr[2 + i] = smac[RTE_ETHER_ADDR_LEN - 1 - i]; 230993ea577SAkhil Goyal } else { 231993ea577SAkhil Goyal /* use some default SCI */ 232993ea577SAkhil Goyal sc_conf->sc_tx.sci = 0xf1341e023a2b1c5d; 233993ea577SAkhil Goyal } 234993ea577SAkhil Goyal } else { 235993ea577SAkhil Goyal for (i = 0; i < RTE_SECURITY_MACSEC_NUM_AN; i++) { 236993ea577SAkhil Goyal sc_conf->sc_rx.sa_id[i] = sa_id[i]; 237993ea577SAkhil Goyal sc_conf->sc_rx.sa_in_use[i] = opts->sa_in_use; 238993ea577SAkhil Goyal } 239993ea577SAkhil Goyal sc_conf->sc_rx.active = 1; 240993ea577SAkhil Goyal } 241993ea577SAkhil Goyal } 242993ea577SAkhil Goyal 243993ea577SAkhil Goyal 244993ea577SAkhil Goyal /* Create Inline MACsec session */ 245993ea577SAkhil Goyal static int 246993ea577SAkhil Goyal fill_session_conf(const struct mcs_test_vector *td, uint16_t portid __rte_unused, 247993ea577SAkhil Goyal const struct mcs_test_opts *opts, 248993ea577SAkhil Goyal struct rte_security_session_conf *sess_conf, 249993ea577SAkhil Goyal enum rte_security_macsec_direction dir, 250993ea577SAkhil Goyal uint16_t sc_id, 251993ea577SAkhil Goyal uint8_t tci_off) 252993ea577SAkhil Goyal { 253993ea577SAkhil Goyal sess_conf->action_type = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL; 254993ea577SAkhil Goyal sess_conf->protocol = RTE_SECURITY_PROTOCOL_MACSEC; 255993ea577SAkhil Goyal sess_conf->macsec.dir = dir; 256993ea577SAkhil Goyal sess_conf->macsec.alg = td->alg; 257993ea577SAkhil Goyal sess_conf->macsec.cipher_off = 0; 258993ea577SAkhil Goyal if (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_SC) { 259993ea577SAkhil Goyal sess_conf->macsec.sci = rte_be_to_cpu_64(*(const uint64_t *) 260993ea577SAkhil Goyal (&td->secure_pkt.data[tci_off + 6])); 261993ea577SAkhil Goyal } else if (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_ES) { 262993ea577SAkhil Goyal /* sci = source_mac + port_id when ES.bit = 1 & SC.bit = 0 */ 263993ea577SAkhil Goyal const uint8_t *smac = td->plain_pkt.data + RTE_ETHER_ADDR_LEN; 264993ea577SAkhil Goyal uint8_t *ptr = (uint8_t *)&sess_conf->macsec.sci; 265993ea577SAkhil Goyal uint8_t j; 266993ea577SAkhil Goyal 267993ea577SAkhil Goyal ptr[0] = 0x01; 268993ea577SAkhil Goyal ptr[1] = 0; 269993ea577SAkhil Goyal for (j = 0; j < RTE_ETHER_ADDR_LEN; j++) 270993ea577SAkhil Goyal ptr[2 + j] = smac[RTE_ETHER_ADDR_LEN - 1 - j]; 271993ea577SAkhil Goyal } 272993ea577SAkhil Goyal sess_conf->macsec.sc_id = sc_id; 273993ea577SAkhil Goyal if (dir == RTE_SECURITY_MACSEC_DIR_TX) { 274993ea577SAkhil Goyal sess_conf->macsec.tx_secy.mtu = opts->mtu; 275993ea577SAkhil Goyal sess_conf->macsec.tx_secy.sectag_off = (opts->sectag_insert_mode == 1) ? 276993ea577SAkhil Goyal 2 * RTE_ETHER_ADDR_LEN : 277993ea577SAkhil Goyal RTE_VLAN_HLEN; 278993ea577SAkhil Goyal sess_conf->macsec.tx_secy.sectag_insert_mode = opts->sectag_insert_mode; 279993ea577SAkhil Goyal sess_conf->macsec.tx_secy.ctrl_port_enable = 1; 280993ea577SAkhil Goyal sess_conf->macsec.tx_secy.sectag_version = 0; 281993ea577SAkhil Goyal sess_conf->macsec.tx_secy.end_station = 282993ea577SAkhil Goyal (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_ES) >> 6; 283993ea577SAkhil Goyal sess_conf->macsec.tx_secy.send_sci = 284993ea577SAkhil Goyal (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_SC) >> 5; 285993ea577SAkhil Goyal sess_conf->macsec.tx_secy.scb = 286993ea577SAkhil Goyal (td->secure_pkt.data[tci_off] & RTE_MACSEC_TCI_SCB) >> 4; 287993ea577SAkhil Goyal sess_conf->macsec.tx_secy.encrypt = opts->encrypt; 288993ea577SAkhil Goyal sess_conf->macsec.tx_secy.protect_frames = opts->protect_frames; 289993ea577SAkhil Goyal sess_conf->macsec.tx_secy.icv_include_da_sa = 1; 290993ea577SAkhil Goyal } else { 291993ea577SAkhil Goyal sess_conf->macsec.rx_secy.replay_win_sz = opts->replay_win_sz; 292993ea577SAkhil Goyal sess_conf->macsec.rx_secy.replay_protect = opts->replay_protect; 293993ea577SAkhil Goyal sess_conf->macsec.rx_secy.icv_include_da_sa = 1; 294993ea577SAkhil Goyal sess_conf->macsec.rx_secy.ctrl_port_enable = 1; 295993ea577SAkhil Goyal sess_conf->macsec.rx_secy.preserve_sectag = 0; 296993ea577SAkhil Goyal sess_conf->macsec.rx_secy.preserve_icv = 0; 297993ea577SAkhil Goyal sess_conf->macsec.rx_secy.validate_frames = opts->val_frames; 298993ea577SAkhil Goyal } 299993ea577SAkhil Goyal 300993ea577SAkhil Goyal return 0; 301993ea577SAkhil Goyal } 302993ea577SAkhil Goyal 303993ea577SAkhil Goyal static int 304993ea577SAkhil Goyal create_default_flow(const struct mcs_test_vector *td, uint16_t portid, 305993ea577SAkhil Goyal enum rte_security_macsec_direction dir, void *sess) 306993ea577SAkhil Goyal { 307993ea577SAkhil Goyal struct rte_flow_action action[2]; 308993ea577SAkhil Goyal struct rte_flow_item pattern[2]; 309993ea577SAkhil Goyal struct rte_flow_attr attr = {0}; 310993ea577SAkhil Goyal struct rte_flow_error err; 311993ea577SAkhil Goyal struct rte_flow *flow; 312993ea577SAkhil Goyal struct rte_flow_item_eth eth = { .hdr.ether_type = 0, }; 313993ea577SAkhil Goyal static const struct rte_flow_item_eth eth_mask = { 314993ea577SAkhil Goyal .hdr.dst_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00", 315993ea577SAkhil Goyal .hdr.src_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00", 316993ea577SAkhil Goyal .hdr.ether_type = RTE_BE16(0x0000), 317993ea577SAkhil Goyal }; 318993ea577SAkhil Goyal 319993ea577SAkhil Goyal int ret; 320993ea577SAkhil Goyal 321993ea577SAkhil Goyal eth.has_vlan = 0; 322993ea577SAkhil Goyal if (dir == RTE_SECURITY_MACSEC_DIR_TX) 323993ea577SAkhil Goyal memcpy(ð.hdr, td->plain_pkt.data, RTE_ETHER_HDR_LEN); 324993ea577SAkhil Goyal else 325993ea577SAkhil Goyal memcpy(ð.hdr, td->secure_pkt.data, RTE_ETHER_HDR_LEN); 326993ea577SAkhil Goyal 327993ea577SAkhil Goyal pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH; 328993ea577SAkhil Goyal pattern[0].spec = ð 329993ea577SAkhil Goyal pattern[0].mask = ð_mask; 330993ea577SAkhil Goyal pattern[0].last = NULL; 331993ea577SAkhil Goyal pattern[1].type = RTE_FLOW_ITEM_TYPE_END; 332993ea577SAkhil Goyal 333993ea577SAkhil Goyal action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY; 334993ea577SAkhil Goyal action[0].conf = sess; 335993ea577SAkhil Goyal action[1].type = RTE_FLOW_ACTION_TYPE_END; 336993ea577SAkhil Goyal action[1].conf = NULL; 337993ea577SAkhil Goyal 338993ea577SAkhil Goyal attr.ingress = (dir == RTE_SECURITY_MACSEC_DIR_RX) ? 1 : 0; 339993ea577SAkhil Goyal attr.egress = (dir == RTE_SECURITY_MACSEC_DIR_TX) ? 1 : 0; 340993ea577SAkhil Goyal 341993ea577SAkhil Goyal ret = rte_flow_validate(portid, &attr, pattern, action, &err); 342993ea577SAkhil Goyal if (ret) { 343993ea577SAkhil Goyal printf("\nValidate flow failed, ret = %d\n", ret); 344993ea577SAkhil Goyal return -1; 345993ea577SAkhil Goyal } 346993ea577SAkhil Goyal flow = rte_flow_create(portid, &attr, pattern, action, &err); 347993ea577SAkhil Goyal if (flow == NULL) { 348993ea577SAkhil Goyal printf("\nDefault flow rule create failed\n"); 349993ea577SAkhil Goyal return -1; 350993ea577SAkhil Goyal } 351993ea577SAkhil Goyal 352993ea577SAkhil Goyal if (dir == RTE_SECURITY_MACSEC_DIR_TX) 353993ea577SAkhil Goyal default_tx_flow[portid] = flow; 354993ea577SAkhil Goyal else 355993ea577SAkhil Goyal default_rx_flow[portid] = flow; 356993ea577SAkhil Goyal 357993ea577SAkhil Goyal return 0; 358993ea577SAkhil Goyal } 359993ea577SAkhil Goyal 360993ea577SAkhil Goyal static void 361993ea577SAkhil Goyal destroy_default_flow(uint16_t portid) 362993ea577SAkhil Goyal { 363993ea577SAkhil Goyal struct rte_flow_error err; 364993ea577SAkhil Goyal int ret; 365993ea577SAkhil Goyal 366993ea577SAkhil Goyal if (default_tx_flow[portid]) { 367993ea577SAkhil Goyal ret = rte_flow_destroy(portid, default_tx_flow[portid], &err); 368993ea577SAkhil Goyal if (ret) { 369993ea577SAkhil Goyal printf("\nDefault Tx flow rule destroy failed\n"); 370993ea577SAkhil Goyal return; 371993ea577SAkhil Goyal } 372993ea577SAkhil Goyal default_tx_flow[portid] = NULL; 373993ea577SAkhil Goyal } 374993ea577SAkhil Goyal if (default_rx_flow[portid]) { 375993ea577SAkhil Goyal ret = rte_flow_destroy(portid, default_rx_flow[portid], &err); 376993ea577SAkhil Goyal if (ret) { 377993ea577SAkhil Goyal printf("\nDefault Rx flow rule destroy failed\n"); 378993ea577SAkhil Goyal return; 379993ea577SAkhil Goyal } 380993ea577SAkhil Goyal default_rx_flow[portid] = NULL; 381993ea577SAkhil Goyal } 382993ea577SAkhil Goyal } 383993ea577SAkhil Goyal 384993ea577SAkhil Goyal static void 385993ea577SAkhil Goyal print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) 386993ea577SAkhil Goyal { 387993ea577SAkhil Goyal char buf[RTE_ETHER_ADDR_FMT_SIZE]; 388993ea577SAkhil Goyal rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); 389993ea577SAkhil Goyal printf("%s%s", name, buf); 390993ea577SAkhil Goyal } 391993ea577SAkhil Goyal 392993ea577SAkhil Goyal /* Check the link status of all ports in up to 3s, and print them finally */ 393993ea577SAkhil Goyal static void 394993ea577SAkhil Goyal check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) 395993ea577SAkhil Goyal { 396993ea577SAkhil Goyal #define CHECK_INTERVAL 100 /* 100ms */ 397993ea577SAkhil Goyal #define MAX_CHECK_TIME 30 /* 3s (30 * 100ms) in total */ 398993ea577SAkhil Goyal uint16_t portid; 399993ea577SAkhil Goyal uint8_t count, all_ports_up, print_flag = 0; 400993ea577SAkhil Goyal struct rte_eth_link link; 401993ea577SAkhil Goyal int ret; 402993ea577SAkhil Goyal char link_status[RTE_ETH_LINK_MAX_STR_LEN]; 403993ea577SAkhil Goyal 404993ea577SAkhil Goyal printf("Checking link statuses...\n"); 405993ea577SAkhil Goyal fflush(stdout); 406993ea577SAkhil Goyal for (count = 0; count <= MAX_CHECK_TIME; count++) { 407993ea577SAkhil Goyal all_ports_up = 1; 408993ea577SAkhil Goyal for (portid = 0; portid < port_num; portid++) { 409993ea577SAkhil Goyal if ((port_mask & (1 << portid)) == 0) 410993ea577SAkhil Goyal continue; 411993ea577SAkhil Goyal memset(&link, 0, sizeof(link)); 412993ea577SAkhil Goyal ret = rte_eth_link_get_nowait(portid, &link); 413993ea577SAkhil Goyal if (ret < 0) { 414993ea577SAkhil Goyal all_ports_up = 0; 415993ea577SAkhil Goyal if (print_flag == 1) 416993ea577SAkhil Goyal printf("Port %u link get failed: %s\n", 417993ea577SAkhil Goyal portid, rte_strerror(-ret)); 418993ea577SAkhil Goyal continue; 419993ea577SAkhil Goyal } 420993ea577SAkhil Goyal 421993ea577SAkhil Goyal /* print link status if flag set */ 422993ea577SAkhil Goyal if (print_flag == 1) { 423993ea577SAkhil Goyal if (link.link_status && link_mbps == 0) 424993ea577SAkhil Goyal link_mbps = link.link_speed; 425993ea577SAkhil Goyal 426993ea577SAkhil Goyal rte_eth_link_to_str(link_status, 427993ea577SAkhil Goyal sizeof(link_status), &link); 428993ea577SAkhil Goyal printf("Port %d %s\n", portid, link_status); 429993ea577SAkhil Goyal continue; 430993ea577SAkhil Goyal } 431993ea577SAkhil Goyal /* clear all_ports_up flag if any link down */ 432993ea577SAkhil Goyal if (link.link_status == RTE_ETH_LINK_DOWN) { 433993ea577SAkhil Goyal all_ports_up = 0; 434993ea577SAkhil Goyal break; 435993ea577SAkhil Goyal } 436993ea577SAkhil Goyal } 437993ea577SAkhil Goyal /* after finally printing all link status, get out */ 438993ea577SAkhil Goyal if (print_flag == 1) 439993ea577SAkhil Goyal break; 440993ea577SAkhil Goyal 441993ea577SAkhil Goyal if (all_ports_up == 0) 442993ea577SAkhil Goyal fflush(stdout); 443993ea577SAkhil Goyal 444993ea577SAkhil Goyal /* set the print_flag if all ports up or timeout */ 445993ea577SAkhil Goyal if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) 446993ea577SAkhil Goyal print_flag = 1; 447993ea577SAkhil Goyal } 448993ea577SAkhil Goyal } 449993ea577SAkhil Goyal 450993ea577SAkhil Goyal static int 451993ea577SAkhil Goyal test_macsec_post_process(struct rte_mbuf *m, const struct mcs_test_vector *td, 452993ea577SAkhil Goyal enum mcs_op op, uint8_t check_out_pkts_untagged) 453993ea577SAkhil Goyal { 454993ea577SAkhil Goyal const uint8_t *dptr; 455993ea577SAkhil Goyal uint16_t pkt_len; 456993ea577SAkhil Goyal 457993ea577SAkhil Goyal if (op == MCS_DECAP || op == MCS_ENCAP_DECAP || 458993ea577SAkhil Goyal op == MCS_VERIFY_ONLY || op == MCS_AUTH_VERIFY || 459993ea577SAkhil Goyal check_out_pkts_untagged == 1) { 460993ea577SAkhil Goyal dptr = td->plain_pkt.data; 461993ea577SAkhil Goyal pkt_len = td->plain_pkt.len; 462993ea577SAkhil Goyal } else { 463993ea577SAkhil Goyal dptr = td->secure_pkt.data; 464993ea577SAkhil Goyal pkt_len = td->secure_pkt.len; 465993ea577SAkhil Goyal } 466993ea577SAkhil Goyal 467993ea577SAkhil Goyal if (memcmp(rte_pktmbuf_mtod(m, uint8_t *), dptr, pkt_len)) { 468993ea577SAkhil Goyal printf("\nData comparison failed for td."); 469993ea577SAkhil Goyal rte_pktmbuf_dump(stdout, m, m->pkt_len); 470993ea577SAkhil Goyal rte_hexdump(stdout, "expected_data", dptr, pkt_len); 471993ea577SAkhil Goyal return TEST_FAILED; 472993ea577SAkhil Goyal } 473993ea577SAkhil Goyal 474993ea577SAkhil Goyal return TEST_SUCCESS; 475993ea577SAkhil Goyal } 476993ea577SAkhil Goyal 477993ea577SAkhil Goyal static void 478993ea577SAkhil Goyal mcs_stats_dump(struct rte_security_ctx *ctx, enum mcs_op op, 479993ea577SAkhil Goyal void *rx_sess, void *tx_sess, 480993ea577SAkhil Goyal uint8_t rx_sc_id, uint8_t tx_sc_id, 481993ea577SAkhil Goyal uint16_t rx_sa_id[], uint16_t tx_sa_id[]) 482993ea577SAkhil Goyal { 483993ea577SAkhil Goyal struct rte_security_stats sess_stats = {0}; 484993ea577SAkhil Goyal struct rte_security_macsec_secy_stats *secy_stat; 485993ea577SAkhil Goyal struct rte_security_macsec_sc_stats sc_stat = {0}; 486993ea577SAkhil Goyal struct rte_security_macsec_sa_stats sa_stat = {0}; 487993ea577SAkhil Goyal int i; 488993ea577SAkhil Goyal 489993ea577SAkhil Goyal if (op == MCS_DECAP || op == MCS_ENCAP_DECAP || 490993ea577SAkhil Goyal op == MCS_VERIFY_ONLY || op == MCS_AUTH_VERIFY) { 491993ea577SAkhil Goyal printf("\n********* RX SECY STATS ************\n"); 492993ea577SAkhil Goyal rte_security_session_stats_get(ctx, rx_sess, &sess_stats); 493993ea577SAkhil Goyal secy_stat = &sess_stats.macsec; 494993ea577SAkhil Goyal 495993ea577SAkhil Goyal if (secy_stat->ctl_pkt_bcast_cnt) 496993ea577SAkhil Goyal printf("RX: ctl_pkt_bcast_cnt: 0x%" PRIx64 "\n", 497993ea577SAkhil Goyal secy_stat->ctl_pkt_bcast_cnt); 498993ea577SAkhil Goyal if (secy_stat->ctl_pkt_mcast_cnt) 499993ea577SAkhil Goyal printf("RX: ctl_pkt_mcast_cnt: 0x%" PRIx64 "\n", 500993ea577SAkhil Goyal secy_stat->ctl_pkt_mcast_cnt); 501993ea577SAkhil Goyal if (secy_stat->ctl_pkt_ucast_cnt) 502993ea577SAkhil Goyal printf("RX: ctl_pkt_ucast_cnt: 0x%" PRIx64 "\n", 503993ea577SAkhil Goyal secy_stat->ctl_pkt_ucast_cnt); 504993ea577SAkhil Goyal if (secy_stat->ctl_octet_cnt) 505993ea577SAkhil Goyal printf("RX: ctl_octet_cnt: 0x%" PRIx64 "\n", secy_stat->ctl_octet_cnt); 506993ea577SAkhil Goyal if (secy_stat->unctl_pkt_bcast_cnt) 507993ea577SAkhil Goyal printf("RX: unctl_pkt_bcast_cnt: 0x%" PRIx64 "\n", 508993ea577SAkhil Goyal secy_stat->unctl_pkt_bcast_cnt); 509993ea577SAkhil Goyal if (secy_stat->unctl_pkt_mcast_cnt) 510993ea577SAkhil Goyal printf("RX: unctl_pkt_mcast_cnt: 0x%" PRIx64 "\n", 511993ea577SAkhil Goyal secy_stat->unctl_pkt_mcast_cnt); 512993ea577SAkhil Goyal if (secy_stat->unctl_pkt_ucast_cnt) 513993ea577SAkhil Goyal printf("RX: unctl_pkt_ucast_cnt: 0x%" PRIx64 "\n", 514993ea577SAkhil Goyal secy_stat->unctl_pkt_ucast_cnt); 515993ea577SAkhil Goyal if (secy_stat->unctl_octet_cnt) 516993ea577SAkhil Goyal printf("RX: unctl_octet_cnt: 0x%" PRIx64 "\n", secy_stat->unctl_octet_cnt); 517993ea577SAkhil Goyal /* Valid only for RX */ 518993ea577SAkhil Goyal if (secy_stat->octet_decrypted_cnt) 519993ea577SAkhil Goyal printf("RX: octet_decrypted_cnt: 0x%" PRIx64 "\n", 520993ea577SAkhil Goyal secy_stat->octet_decrypted_cnt); 521993ea577SAkhil Goyal if (secy_stat->octet_validated_cnt) 522993ea577SAkhil Goyal printf("RX: octet_validated_cnt: 0x%" PRIx64 "\n", 523993ea577SAkhil Goyal secy_stat->octet_validated_cnt); 524993ea577SAkhil Goyal if (secy_stat->pkt_port_disabled_cnt) 525993ea577SAkhil Goyal printf("RX: pkt_port_disabled_cnt: 0x%" PRIx64 "\n", 526993ea577SAkhil Goyal secy_stat->pkt_port_disabled_cnt); 527993ea577SAkhil Goyal if (secy_stat->pkt_badtag_cnt) 528993ea577SAkhil Goyal printf("RX: pkt_badtag_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_badtag_cnt); 529993ea577SAkhil Goyal if (secy_stat->pkt_nosa_cnt) 530993ea577SAkhil Goyal printf("RX: pkt_nosa_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_nosa_cnt); 531993ea577SAkhil Goyal if (secy_stat->pkt_nosaerror_cnt) 532993ea577SAkhil Goyal printf("RX: pkt_nosaerror_cnt: 0x%" PRIx64 "\n", 533993ea577SAkhil Goyal secy_stat->pkt_nosaerror_cnt); 534993ea577SAkhil Goyal if (secy_stat->pkt_tagged_ctl_cnt) 535993ea577SAkhil Goyal printf("RX: pkt_tagged_ctl_cnt: 0x%" PRIx64 "\n", 536993ea577SAkhil Goyal secy_stat->pkt_tagged_ctl_cnt); 537993ea577SAkhil Goyal if (secy_stat->pkt_untaged_cnt) 538993ea577SAkhil Goyal printf("RX: pkt_untaged_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_untaged_cnt); 539993ea577SAkhil Goyal if (secy_stat->pkt_ctl_cnt) 540993ea577SAkhil Goyal printf("RX: pkt_ctl_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_ctl_cnt); 541993ea577SAkhil Goyal if (secy_stat->pkt_notag_cnt) 542993ea577SAkhil Goyal printf("RX: pkt_notag_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_notag_cnt); 543993ea577SAkhil Goyal printf("\n"); 544993ea577SAkhil Goyal printf("\n********** RX SC[%u] STATS **************\n", rx_sc_id); 545993ea577SAkhil Goyal 546993ea577SAkhil Goyal rte_security_macsec_sc_stats_get(ctx, rx_sc_id, RTE_SECURITY_MACSEC_DIR_RX, 547993ea577SAkhil Goyal &sc_stat); 548993ea577SAkhil Goyal /* RX */ 549993ea577SAkhil Goyal if (sc_stat.hit_cnt) 550993ea577SAkhil Goyal printf("RX hit_cnt: 0x%" PRIx64 "\n", sc_stat.hit_cnt); 551993ea577SAkhil Goyal if (sc_stat.pkt_invalid_cnt) 552993ea577SAkhil Goyal printf("RX pkt_invalid_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_invalid_cnt); 553993ea577SAkhil Goyal if (sc_stat.pkt_late_cnt) 554993ea577SAkhil Goyal printf("RX pkt_late_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_late_cnt); 555993ea577SAkhil Goyal if (sc_stat.pkt_notvalid_cnt) 556993ea577SAkhil Goyal printf("RX pkt_notvalid_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_notvalid_cnt); 557993ea577SAkhil Goyal if (sc_stat.pkt_unchecked_cnt) 558993ea577SAkhil Goyal printf("RX pkt_unchecked_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_unchecked_cnt); 559993ea577SAkhil Goyal if (sc_stat.pkt_delay_cnt) 560993ea577SAkhil Goyal printf("RX pkt_delay_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_delay_cnt); 561993ea577SAkhil Goyal if (sc_stat.pkt_ok_cnt) 562993ea577SAkhil Goyal printf("RX pkt_ok_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_ok_cnt); 563993ea577SAkhil Goyal if (sc_stat.octet_decrypt_cnt) 564993ea577SAkhil Goyal printf("RX octet_decrypt_cnt: 0x%" PRIx64 "\n", sc_stat.octet_decrypt_cnt); 565993ea577SAkhil Goyal if (sc_stat.octet_validate_cnt) 566993ea577SAkhil Goyal printf("RX octet_validate_cnt: 0x%" PRIx64 "\n", 567993ea577SAkhil Goyal sc_stat.octet_validate_cnt); 568993ea577SAkhil Goyal printf("\n"); 569993ea577SAkhil Goyal for (i = 0; i < RTE_SECURITY_MACSEC_NUM_AN; i++) { 570993ea577SAkhil Goyal printf("\n********** RX SA[%u] STATS ****************\n", rx_sa_id[i]); 571993ea577SAkhil Goyal memset(&sa_stat, 0, sizeof(struct rte_security_macsec_sa_stats)); 572993ea577SAkhil Goyal rte_security_macsec_sa_stats_get(ctx, rx_sa_id[i], 573993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX, &sa_stat); 574993ea577SAkhil Goyal 575993ea577SAkhil Goyal /* RX */ 576993ea577SAkhil Goyal if (sa_stat.pkt_invalid_cnt) 577993ea577SAkhil Goyal printf("RX pkt_invalid_cnt: 0x%" PRIx64 "\n", 578993ea577SAkhil Goyal sa_stat.pkt_invalid_cnt); 579993ea577SAkhil Goyal if (sa_stat.pkt_nosaerror_cnt) 580993ea577SAkhil Goyal printf("RX pkt_nosaerror_cnt: 0x%" PRIx64 "\n", 581993ea577SAkhil Goyal sa_stat.pkt_nosaerror_cnt); 582993ea577SAkhil Goyal if (sa_stat.pkt_notvalid_cnt) 583993ea577SAkhil Goyal printf("RX pkt_notvalid_cnt: 0x%" PRIx64 "\n", 584993ea577SAkhil Goyal sa_stat.pkt_notvalid_cnt); 585993ea577SAkhil Goyal if (sa_stat.pkt_ok_cnt) 586993ea577SAkhil Goyal printf("RX pkt_ok_cnt: 0x%" PRIx64 "\n", sa_stat.pkt_ok_cnt); 587993ea577SAkhil Goyal if (sa_stat.pkt_nosa_cnt) 588993ea577SAkhil Goyal printf("RX pkt_nosa_cnt: 0x%" PRIx64 "\n", sa_stat.pkt_nosa_cnt); 589993ea577SAkhil Goyal printf("\n"); 590993ea577SAkhil Goyal } 591993ea577SAkhil Goyal } 592993ea577SAkhil Goyal 593993ea577SAkhil Goyal if (op == MCS_ENCAP || op == MCS_ENCAP_DECAP || 594993ea577SAkhil Goyal op == MCS_AUTH_ONLY || op == MCS_AUTH_VERIFY) { 595993ea577SAkhil Goyal memset(&sess_stats, 0, sizeof(struct rte_security_stats)); 596993ea577SAkhil Goyal rte_security_session_stats_get(ctx, tx_sess, &sess_stats); 597993ea577SAkhil Goyal secy_stat = &sess_stats.macsec; 598993ea577SAkhil Goyal 599993ea577SAkhil Goyal printf("\n********* TX SECY STATS ************\n"); 600993ea577SAkhil Goyal if (secy_stat->ctl_pkt_bcast_cnt) 601993ea577SAkhil Goyal printf("TX: ctl_pkt_bcast_cnt: 0x%" PRIx64 "\n", 602993ea577SAkhil Goyal secy_stat->ctl_pkt_bcast_cnt); 603993ea577SAkhil Goyal if (secy_stat->ctl_pkt_mcast_cnt) 604993ea577SAkhil Goyal printf("TX: ctl_pkt_mcast_cnt: 0x%" PRIx64 "\n", 605993ea577SAkhil Goyal secy_stat->ctl_pkt_mcast_cnt); 606993ea577SAkhil Goyal if (secy_stat->ctl_pkt_ucast_cnt) 607993ea577SAkhil Goyal printf("TX: ctl_pkt_ucast_cnt: 0x%" PRIx64 "\n", 608993ea577SAkhil Goyal secy_stat->ctl_pkt_ucast_cnt); 609993ea577SAkhil Goyal if (secy_stat->ctl_octet_cnt) 610993ea577SAkhil Goyal printf("TX: ctl_octet_cnt: 0x%" PRIx64 "\n", secy_stat->ctl_octet_cnt); 611993ea577SAkhil Goyal if (secy_stat->unctl_pkt_bcast_cnt) 612993ea577SAkhil Goyal printf("TX: unctl_pkt_bcast_cnt: 0x%" PRIx64 "\n", 613993ea577SAkhil Goyal secy_stat->unctl_pkt_bcast_cnt); 614993ea577SAkhil Goyal if (secy_stat->unctl_pkt_mcast_cnt) 615993ea577SAkhil Goyal printf("TX: unctl_pkt_mcast_cnt: 0x%" PRIx64 "\n", 616993ea577SAkhil Goyal secy_stat->unctl_pkt_mcast_cnt); 617993ea577SAkhil Goyal if (secy_stat->unctl_pkt_ucast_cnt) 618993ea577SAkhil Goyal printf("TX: unctl_pkt_ucast_cnt: 0x%" PRIx64 "\n", 619993ea577SAkhil Goyal secy_stat->unctl_pkt_ucast_cnt); 620993ea577SAkhil Goyal if (secy_stat->unctl_octet_cnt) 621993ea577SAkhil Goyal printf("TX: unctl_octet_cnt: 0x%" PRIx64 "\n", 622993ea577SAkhil Goyal secy_stat->unctl_octet_cnt); 623993ea577SAkhil Goyal /* Valid only for TX */ 624993ea577SAkhil Goyal if (secy_stat->octet_encrypted_cnt) 625993ea577SAkhil Goyal printf("TX: octet_encrypted_cnt: 0x%" PRIx64 "\n", 626993ea577SAkhil Goyal secy_stat->octet_encrypted_cnt); 627993ea577SAkhil Goyal if (secy_stat->octet_protected_cnt) 628993ea577SAkhil Goyal printf("TX: octet_protected_cnt: 0x%" PRIx64 "\n", 629993ea577SAkhil Goyal secy_stat->octet_protected_cnt); 630993ea577SAkhil Goyal if (secy_stat->pkt_noactivesa_cnt) 631993ea577SAkhil Goyal printf("TX: pkt_noactivesa_cnt: 0x%" PRIx64 "\n", 632993ea577SAkhil Goyal secy_stat->pkt_noactivesa_cnt); 633993ea577SAkhil Goyal if (secy_stat->pkt_toolong_cnt) 634993ea577SAkhil Goyal printf("TX: pkt_toolong_cnt: 0x%" PRIx64 "\n", secy_stat->pkt_toolong_cnt); 635993ea577SAkhil Goyal if (secy_stat->pkt_untagged_cnt) 636993ea577SAkhil Goyal printf("TX: pkt_untagged_cnt: 0x%" PRIx64 "\n", 637993ea577SAkhil Goyal secy_stat->pkt_untagged_cnt); 638993ea577SAkhil Goyal 639993ea577SAkhil Goyal 640993ea577SAkhil Goyal memset(&sc_stat, 0, sizeof(struct rte_security_macsec_sc_stats)); 641993ea577SAkhil Goyal rte_security_macsec_sc_stats_get(ctx, tx_sc_id, RTE_SECURITY_MACSEC_DIR_TX, 642993ea577SAkhil Goyal &sc_stat); 643993ea577SAkhil Goyal printf("\n********** TX SC[%u] STATS **************\n", tx_sc_id); 644993ea577SAkhil Goyal if (sc_stat.pkt_encrypt_cnt) 645993ea577SAkhil Goyal printf("TX pkt_encrypt_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_encrypt_cnt); 646993ea577SAkhil Goyal if (sc_stat.pkt_protected_cnt) 647993ea577SAkhil Goyal printf("TX pkt_protected_cnt: 0x%" PRIx64 "\n", sc_stat.pkt_protected_cnt); 648993ea577SAkhil Goyal if (sc_stat.octet_encrypt_cnt) 649993ea577SAkhil Goyal printf("TX octet_encrypt_cnt: 0x%" PRIx64 "\n", sc_stat.octet_encrypt_cnt); 650993ea577SAkhil Goyal 651993ea577SAkhil Goyal memset(&sa_stat, 0, sizeof(struct rte_security_macsec_sa_stats)); 652993ea577SAkhil Goyal rte_security_macsec_sa_stats_get(ctx, tx_sa_id[0], 653993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX, &sa_stat); 654993ea577SAkhil Goyal printf("\n********** TX SA[%u] STATS ****************\n", tx_sa_id[0]); 655993ea577SAkhil Goyal if (sa_stat.pkt_encrypt_cnt) 656993ea577SAkhil Goyal printf("TX pkt_encrypt_cnt: 0x%" PRIx64 "\n", sa_stat.pkt_encrypt_cnt); 657993ea577SAkhil Goyal if (sa_stat.pkt_protected_cnt) 658993ea577SAkhil Goyal printf("TX pkt_protected_cnt: 0x%" PRIx64 "\n", sa_stat.pkt_protected_cnt); 659993ea577SAkhil Goyal } 660993ea577SAkhil Goyal } 661993ea577SAkhil Goyal 662993ea577SAkhil Goyal static int 663993ea577SAkhil Goyal test_macsec(const struct mcs_test_vector *td[], enum mcs_op op, const struct mcs_test_opts *opts) 664993ea577SAkhil Goyal { 665993ea577SAkhil Goyal uint16_t rx_sa_id[MCS_MAX_FLOWS][RTE_SECURITY_MACSEC_NUM_AN] = {{0}}; 666993ea577SAkhil Goyal uint16_t tx_sa_id[MCS_MAX_FLOWS][2] = {{0}}; 667993ea577SAkhil Goyal uint16_t rx_sc_id[MCS_MAX_FLOWS] = {0}; 668993ea577SAkhil Goyal uint16_t tx_sc_id[MCS_MAX_FLOWS] = {0}; 669993ea577SAkhil Goyal void *rx_sess[MCS_MAX_FLOWS] = {0}; 670993ea577SAkhil Goyal void *tx_sess[MCS_MAX_FLOWS] = {0}; 671993ea577SAkhil Goyal struct rte_security_session_conf sess_conf = {0}; 672993ea577SAkhil Goyal struct rte_security_macsec_sa sa_conf = {0}; 673993ea577SAkhil Goyal struct rte_security_macsec_sc sc_conf = {0}; 674993ea577SAkhil Goyal struct rte_security_ctx *ctx; 675993ea577SAkhil Goyal int nb_rx = 0, nb_sent; 676993ea577SAkhil Goyal int i, j = 0, ret, id, an = 0; 677993ea577SAkhil Goyal uint8_t tci_off; 678993ea577SAkhil Goyal 679993ea577SAkhil Goyal memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * opts->nb_td); 680993ea577SAkhil Goyal 681993ea577SAkhil Goyal ctx = (struct rte_security_ctx *)rte_eth_dev_get_sec_ctx(port_id); 682993ea577SAkhil Goyal if (ctx == NULL) { 683993ea577SAkhil Goyal printf("Ethernet device doesn't support security features.\n"); 684993ea577SAkhil Goyal return TEST_SKIPPED; 685993ea577SAkhil Goyal } 686993ea577SAkhil Goyal 687993ea577SAkhil Goyal tci_off = (opts->sectag_insert_mode == 1) ? RTE_ETHER_HDR_LEN : 688993ea577SAkhil Goyal RTE_ETHER_HDR_LEN + (opts->nb_vlan * RTE_VLAN_HLEN); 689993ea577SAkhil Goyal 690993ea577SAkhil Goyal for (i = 0, j = 0; i < opts->nb_td; i++) { 691993ea577SAkhil Goyal if (op == MCS_DECAP || op == MCS_VERIFY_ONLY) 692993ea577SAkhil Goyal tx_pkts_burst[j] = init_packet(mbufpool, td[i]->secure_pkt.data, 693993ea577SAkhil Goyal td[i]->secure_pkt.len); 694993ea577SAkhil Goyal else { 695993ea577SAkhil Goyal tx_pkts_burst[j] = init_packet(mbufpool, td[i]->plain_pkt.data, 696993ea577SAkhil Goyal td[i]->plain_pkt.len); 697993ea577SAkhil Goyal 698993ea577SAkhil Goyal tx_pkts_burst[j]->ol_flags |= RTE_MBUF_F_TX_MACSEC; 699993ea577SAkhil Goyal } 700993ea577SAkhil Goyal if (tx_pkts_burst[j] == NULL) { 701993ea577SAkhil Goyal while (j--) 702993ea577SAkhil Goyal rte_pktmbuf_free(tx_pkts_burst[j]); 703993ea577SAkhil Goyal ret = TEST_FAILED; 704993ea577SAkhil Goyal goto out; 705993ea577SAkhil Goyal } 706993ea577SAkhil Goyal j++; 707993ea577SAkhil Goyal 708993ea577SAkhil Goyal if (op == MCS_DECAP || op == MCS_ENCAP_DECAP || 709993ea577SAkhil Goyal op == MCS_VERIFY_ONLY || op == MCS_AUTH_VERIFY) { 710993ea577SAkhil Goyal for (an = 0; an < RTE_SECURITY_MACSEC_NUM_AN; an++) { 711993ea577SAkhil Goyal /* For simplicity, using same SA conf for all AN */ 712993ea577SAkhil Goyal fill_macsec_sa_conf(td[i], &sa_conf, 713993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX, an, tci_off); 714993ea577SAkhil Goyal id = rte_security_macsec_sa_create(ctx, &sa_conf); 715993ea577SAkhil Goyal if (id < 0) { 716993ea577SAkhil Goyal printf("MACsec SA create failed : %d.\n", id); 717993ea577SAkhil Goyal return TEST_FAILED; 718993ea577SAkhil Goyal } 719993ea577SAkhil Goyal rx_sa_id[i][an] = (uint16_t)id; 720993ea577SAkhil Goyal } 721993ea577SAkhil Goyal fill_macsec_sc_conf(td[i], &sc_conf, opts, 722993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX, rx_sa_id[i], tci_off); 723993ea577SAkhil Goyal id = rte_security_macsec_sc_create(ctx, &sc_conf); 724993ea577SAkhil Goyal if (id < 0) { 725993ea577SAkhil Goyal printf("MACsec SC create failed : %d.\n", id); 726993ea577SAkhil Goyal goto out; 727993ea577SAkhil Goyal } 728993ea577SAkhil Goyal rx_sc_id[i] = (uint16_t)id; 729993ea577SAkhil Goyal 730993ea577SAkhil Goyal /* Create Inline IPsec session. */ 731993ea577SAkhil Goyal ret = fill_session_conf(td[i], port_id, opts, &sess_conf, 732993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX, rx_sc_id[i], tci_off); 733993ea577SAkhil Goyal if (ret) 734993ea577SAkhil Goyal return TEST_FAILED; 735993ea577SAkhil Goyal 736993ea577SAkhil Goyal rx_sess[i] = rte_security_session_create(ctx, &sess_conf, 737993ea577SAkhil Goyal sess_pool); 738993ea577SAkhil Goyal if (rx_sess[i] == NULL) { 739993ea577SAkhil Goyal printf("SEC Session init failed.\n"); 740993ea577SAkhil Goyal return TEST_FAILED; 741993ea577SAkhil Goyal } 742993ea577SAkhil Goyal ret = create_default_flow(td[i], port_id, 743993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX, rx_sess[i]); 744993ea577SAkhil Goyal if (ret) 745993ea577SAkhil Goyal goto out; 746993ea577SAkhil Goyal } 747993ea577SAkhil Goyal if (op == MCS_ENCAP || op == MCS_ENCAP_DECAP || 748993ea577SAkhil Goyal op == MCS_AUTH_ONLY || op == MCS_AUTH_VERIFY) { 749993ea577SAkhil Goyal int id; 750993ea577SAkhil Goyal 751993ea577SAkhil Goyal fill_macsec_sa_conf(td[i], &sa_conf, 752993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX, 753993ea577SAkhil Goyal td[i]->secure_pkt.data[tci_off] & RTE_MACSEC_AN_MASK, 754993ea577SAkhil Goyal tci_off); 755993ea577SAkhil Goyal id = rte_security_macsec_sa_create(ctx, &sa_conf); 756993ea577SAkhil Goyal if (id < 0) { 757993ea577SAkhil Goyal printf("MACsec SA create failed : %d.\n", id); 758993ea577SAkhil Goyal return TEST_FAILED; 759993ea577SAkhil Goyal } 760993ea577SAkhil Goyal tx_sa_id[i][0] = (uint16_t)id; 761993ea577SAkhil Goyal tx_sa_id[i][1] = MCS_INVALID_SA; 762993ea577SAkhil Goyal fill_macsec_sc_conf(td[i], &sc_conf, opts, 763993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX, tx_sa_id[i], tci_off); 764993ea577SAkhil Goyal id = rte_security_macsec_sc_create(ctx, &sc_conf); 765993ea577SAkhil Goyal if (id < 0) { 766993ea577SAkhil Goyal printf("MACsec SC create failed : %d.\n", id); 767993ea577SAkhil Goyal goto out; 768993ea577SAkhil Goyal } 769993ea577SAkhil Goyal tx_sc_id[i] = (uint16_t)id; 770993ea577SAkhil Goyal 771993ea577SAkhil Goyal /* Create Inline IPsec session. */ 772993ea577SAkhil Goyal ret = fill_session_conf(td[i], port_id, opts, &sess_conf, 773993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX, tx_sc_id[i], tci_off); 774993ea577SAkhil Goyal if (ret) 775993ea577SAkhil Goyal return TEST_FAILED; 776993ea577SAkhil Goyal 777993ea577SAkhil Goyal tx_sess[i] = rte_security_session_create(ctx, &sess_conf, 778993ea577SAkhil Goyal sess_pool); 779993ea577SAkhil Goyal if (tx_sess[i] == NULL) { 780993ea577SAkhil Goyal printf("SEC Session init failed.\n"); 781993ea577SAkhil Goyal return TEST_FAILED; 782993ea577SAkhil Goyal } 783993ea577SAkhil Goyal ret = create_default_flow(td[i], port_id, 784993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX, tx_sess[i]); 785993ea577SAkhil Goyal if (ret) 786993ea577SAkhil Goyal goto out; 787993ea577SAkhil Goyal } 788993ea577SAkhil Goyal } 789993ea577SAkhil Goyal 790993ea577SAkhil Goyal /* Send packet to ethdev for inline MACsec processing. */ 791993ea577SAkhil Goyal nb_sent = rte_eth_tx_burst(port_id, 0, tx_pkts_burst, j); 792993ea577SAkhil Goyal 793993ea577SAkhil Goyal if (nb_sent != j) { 794993ea577SAkhil Goyal printf("\nUnable to TX %d packets, sent: %i", j, nb_sent); 795993ea577SAkhil Goyal for ( ; nb_sent < j; nb_sent++) 796993ea577SAkhil Goyal rte_pktmbuf_free(tx_pkts_burst[nb_sent]); 797993ea577SAkhil Goyal ret = TEST_FAILED; 798993ea577SAkhil Goyal goto out; 799993ea577SAkhil Goyal } 800993ea577SAkhil Goyal 801993ea577SAkhil Goyal rte_pause(); 802993ea577SAkhil Goyal 803993ea577SAkhil Goyal /* Receive back packet on loopback interface. */ 804993ea577SAkhil Goyal do { 805993ea577SAkhil Goyal nb_rx += rte_eth_rx_burst(port_id, 0, 806993ea577SAkhil Goyal &rx_pkts_burst[nb_rx], 807993ea577SAkhil Goyal nb_sent - nb_rx); 808993ea577SAkhil Goyal if (nb_rx >= nb_sent) 809993ea577SAkhil Goyal break; 810993ea577SAkhil Goyal rte_delay_ms(1); 811993ea577SAkhil Goyal } while (j++ < 5 && nb_rx == 0); 812993ea577SAkhil Goyal 813993ea577SAkhil Goyal if (nb_rx != nb_sent) { 814993ea577SAkhil Goyal printf("\nUnable to RX all %d packets, received(%i)", 815993ea577SAkhil Goyal nb_sent, nb_rx); 816993ea577SAkhil Goyal while (--nb_rx >= 0) 817993ea577SAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[nb_rx]); 818993ea577SAkhil Goyal ret = TEST_FAILED; 819993ea577SAkhil Goyal goto out; 820993ea577SAkhil Goyal } 821993ea577SAkhil Goyal 822993ea577SAkhil Goyal for (i = 0; i < nb_rx; i++) { 823993ea577SAkhil Goyal ret = test_macsec_post_process(rx_pkts_burst[i], td[i], op, 824993ea577SAkhil Goyal opts->check_out_pkts_untagged); 825993ea577SAkhil Goyal if (ret != TEST_SUCCESS) { 826993ea577SAkhil Goyal for ( ; i < nb_rx; i++) 827993ea577SAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[i]); 828993ea577SAkhil Goyal goto out; 829993ea577SAkhil Goyal } 830993ea577SAkhil Goyal 831993ea577SAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[i]); 832993ea577SAkhil Goyal rx_pkts_burst[i] = NULL; 833993ea577SAkhil Goyal } 834993ea577SAkhil Goyal out: 835993ea577SAkhil Goyal for (i = 0; i < opts->nb_td; i++) { 836993ea577SAkhil Goyal if (opts->dump_all_stats) { 837993ea577SAkhil Goyal mcs_stats_dump(ctx, op, 838993ea577SAkhil Goyal rx_sess[i], tx_sess[i], 839993ea577SAkhil Goyal rx_sc_id[i], tx_sc_id[i], 840993ea577SAkhil Goyal rx_sa_id[i], tx_sa_id[i]); 841993ea577SAkhil Goyal } 842993ea577SAkhil Goyal } 843993ea577SAkhil Goyal 844993ea577SAkhil Goyal destroy_default_flow(port_id); 845993ea577SAkhil Goyal 846993ea577SAkhil Goyal /* Destroy session so that other cases can create the session again */ 847993ea577SAkhil Goyal for (i = 0; i < opts->nb_td; i++) { 848993ea577SAkhil Goyal if (op == MCS_ENCAP || op == MCS_ENCAP_DECAP || 849993ea577SAkhil Goyal op == MCS_AUTH_ONLY || op == MCS_AUTH_VERIFY) { 850993ea577SAkhil Goyal rte_security_session_destroy(ctx, tx_sess[i]); 851993ea577SAkhil Goyal tx_sess[i] = NULL; 852993ea577SAkhil Goyal rte_security_macsec_sc_destroy(ctx, tx_sc_id[i], 853993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX); 854993ea577SAkhil Goyal rte_security_macsec_sa_destroy(ctx, tx_sa_id[i][0], 855993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_TX); 856993ea577SAkhil Goyal } 857993ea577SAkhil Goyal if (op == MCS_DECAP || op == MCS_ENCAP_DECAP || 858993ea577SAkhil Goyal op == MCS_VERIFY_ONLY || op == MCS_AUTH_VERIFY) { 859993ea577SAkhil Goyal rte_security_session_destroy(ctx, rx_sess[i]); 860993ea577SAkhil Goyal rx_sess[i] = NULL; 861993ea577SAkhil Goyal rte_security_macsec_sc_destroy(ctx, rx_sc_id[i], 862993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX); 863993ea577SAkhil Goyal for (j = 0; j < RTE_SECURITY_MACSEC_NUM_AN; j++) { 864993ea577SAkhil Goyal rte_security_macsec_sa_destroy(ctx, rx_sa_id[i][j], 865993ea577SAkhil Goyal RTE_SECURITY_MACSEC_DIR_RX); 866993ea577SAkhil Goyal } 867993ea577SAkhil Goyal } 868993ea577SAkhil Goyal } 869993ea577SAkhil Goyal 870993ea577SAkhil Goyal return ret; 871993ea577SAkhil Goyal } 872993ea577SAkhil Goyal 873993ea577SAkhil Goyal static int 874993ea577SAkhil Goyal test_inline_macsec_encap_all(const void *data __rte_unused) 875993ea577SAkhil Goyal { 876993ea577SAkhil Goyal const struct mcs_test_vector *cur_td; 877993ea577SAkhil Goyal struct mcs_test_opts opts = {0}; 878993ea577SAkhil Goyal int err, all_err = 0; 879993ea577SAkhil Goyal int i, size; 880993ea577SAkhil Goyal 881993ea577SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 882993ea577SAkhil Goyal opts.encrypt = true; 883993ea577SAkhil Goyal opts.protect_frames = true; 884993ea577SAkhil Goyal opts.sa_in_use = 1; 885993ea577SAkhil Goyal opts.nb_td = 1; 886993ea577SAkhil Goyal opts.sectag_insert_mode = 1; 887993ea577SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 888993ea577SAkhil Goyal 889993ea577SAkhil Goyal size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); 890993ea577SAkhil Goyal for (i = 0; i < size; i++) { 891993ea577SAkhil Goyal cur_td = &list_mcs_cipher_vectors[i]; 892993ea577SAkhil Goyal err = test_macsec(&cur_td, MCS_ENCAP, &opts); 893993ea577SAkhil Goyal if (err) { 894993ea577SAkhil Goyal printf("\nCipher Auth Encryption case %d failed", cur_td->test_idx); 895993ea577SAkhil Goyal err = -1; 896993ea577SAkhil Goyal } else { 897993ea577SAkhil Goyal printf("\nCipher Auth Encryption case %d Passed", cur_td->test_idx); 898993ea577SAkhil Goyal err = 0; 899993ea577SAkhil Goyal } 900993ea577SAkhil Goyal all_err += err; 901993ea577SAkhil Goyal } 902993ea577SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 903993ea577SAkhil Goyal 904993ea577SAkhil Goyal return all_err; 905993ea577SAkhil Goyal } 906993ea577SAkhil Goyal 907993ea577SAkhil Goyal static int 908993ea577SAkhil Goyal test_inline_macsec_decap_all(const void *data __rte_unused) 909993ea577SAkhil Goyal { 910993ea577SAkhil Goyal const struct mcs_test_vector *cur_td; 911993ea577SAkhil Goyal struct mcs_test_opts opts = {0}; 912993ea577SAkhil Goyal int err, all_err = 0; 913993ea577SAkhil Goyal int i, size; 914993ea577SAkhil Goyal 915993ea577SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 916993ea577SAkhil Goyal opts.sa_in_use = 1; 917993ea577SAkhil Goyal opts.nb_td = 1; 918993ea577SAkhil Goyal opts.sectag_insert_mode = 1; 919993ea577SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 920993ea577SAkhil Goyal 921993ea577SAkhil Goyal size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); 922993ea577SAkhil Goyal for (i = 0; i < size; i++) { 923993ea577SAkhil Goyal cur_td = &list_mcs_cipher_vectors[i]; 924993ea577SAkhil Goyal err = test_macsec(&cur_td, MCS_DECAP, &opts); 925993ea577SAkhil Goyal if (err) { 926993ea577SAkhil Goyal printf("\nCipher Auth Decryption case %d failed", cur_td->test_idx); 927993ea577SAkhil Goyal err = -1; 928993ea577SAkhil Goyal } else { 929993ea577SAkhil Goyal printf("\nCipher Auth Decryption case %d Passed", cur_td->test_idx); 930993ea577SAkhil Goyal err = 0; 931993ea577SAkhil Goyal } 932993ea577SAkhil Goyal all_err += err; 933993ea577SAkhil Goyal } 934993ea577SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 935993ea577SAkhil Goyal 936993ea577SAkhil Goyal return all_err; 937993ea577SAkhil Goyal } 938993ea577SAkhil Goyal 939993ea577SAkhil Goyal static int 9402da0c0a7SAkhil Goyal test_inline_macsec_auth_only_all(const void *data __rte_unused) 9412da0c0a7SAkhil Goyal { 9422da0c0a7SAkhil Goyal const struct mcs_test_vector *cur_td; 9432da0c0a7SAkhil Goyal struct mcs_test_opts opts = {0}; 9442da0c0a7SAkhil Goyal int err, all_err = 0; 9452da0c0a7SAkhil Goyal int i, size; 9462da0c0a7SAkhil Goyal 9472da0c0a7SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 9482da0c0a7SAkhil Goyal opts.protect_frames = true; 9492da0c0a7SAkhil Goyal opts.sa_in_use = 1; 9502da0c0a7SAkhil Goyal opts.nb_td = 1; 9512da0c0a7SAkhil Goyal opts.sectag_insert_mode = 1; 9522da0c0a7SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 9532da0c0a7SAkhil Goyal 9542da0c0a7SAkhil Goyal size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); 9552da0c0a7SAkhil Goyal 9562da0c0a7SAkhil Goyal for (i = 0; i < size; i++) { 9572da0c0a7SAkhil Goyal cur_td = &list_mcs_integrity_vectors[i]; 9582da0c0a7SAkhil Goyal err = test_macsec(&cur_td, MCS_AUTH_ONLY, &opts); 9592da0c0a7SAkhil Goyal if (err) { 9602da0c0a7SAkhil Goyal printf("\nAuth Generate case %d failed", cur_td->test_idx); 9612da0c0a7SAkhil Goyal err = -1; 9622da0c0a7SAkhil Goyal } else { 9632da0c0a7SAkhil Goyal printf("\nAuth Generate case %d Passed", cur_td->test_idx); 9642da0c0a7SAkhil Goyal err = 0; 9652da0c0a7SAkhil Goyal } 9662da0c0a7SAkhil Goyal all_err += err; 9672da0c0a7SAkhil Goyal } 9682da0c0a7SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 9692da0c0a7SAkhil Goyal 9702da0c0a7SAkhil Goyal return all_err; 9712da0c0a7SAkhil Goyal } 9722da0c0a7SAkhil Goyal 9732da0c0a7SAkhil Goyal static int 9742da0c0a7SAkhil Goyal test_inline_macsec_verify_only_all(const void *data __rte_unused) 9752da0c0a7SAkhil Goyal { 9762da0c0a7SAkhil Goyal const struct mcs_test_vector *cur_td; 9772da0c0a7SAkhil Goyal struct mcs_test_opts opts = {0}; 9782da0c0a7SAkhil Goyal int err, all_err = 0; 9792da0c0a7SAkhil Goyal int i, size; 9802da0c0a7SAkhil Goyal 9812da0c0a7SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 9822da0c0a7SAkhil Goyal opts.sa_in_use = 1; 9832da0c0a7SAkhil Goyal opts.nb_td = 1; 9842da0c0a7SAkhil Goyal opts.sectag_insert_mode = 1; 9852da0c0a7SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 9862da0c0a7SAkhil Goyal 9872da0c0a7SAkhil Goyal size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); 9882da0c0a7SAkhil Goyal 9892da0c0a7SAkhil Goyal for (i = 0; i < size; i++) { 9902da0c0a7SAkhil Goyal cur_td = &list_mcs_integrity_vectors[i]; 9912da0c0a7SAkhil Goyal err = test_macsec(&cur_td, MCS_VERIFY_ONLY, &opts); 9922da0c0a7SAkhil Goyal if (err) { 9932da0c0a7SAkhil Goyal printf("\nAuth Verify case %d failed", cur_td->test_idx); 9942da0c0a7SAkhil Goyal err = -1; 9952da0c0a7SAkhil Goyal } else { 9962da0c0a7SAkhil Goyal printf("\nAuth Verify case %d Passed", cur_td->test_idx); 9972da0c0a7SAkhil Goyal err = 0; 9982da0c0a7SAkhil Goyal } 9992da0c0a7SAkhil Goyal all_err += err; 10002da0c0a7SAkhil Goyal } 10012da0c0a7SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 10022da0c0a7SAkhil Goyal 10032da0c0a7SAkhil Goyal return all_err; 10042da0c0a7SAkhil Goyal } 10052da0c0a7SAkhil Goyal 10062da0c0a7SAkhil Goyal static int 10072da0c0a7SAkhil Goyal test_inline_macsec_encap_decap_all(const void *data __rte_unused) 10082da0c0a7SAkhil Goyal { 10092da0c0a7SAkhil Goyal const struct mcs_test_vector *cur_td; 10102da0c0a7SAkhil Goyal struct mcs_test_opts opts = {0}; 10112da0c0a7SAkhil Goyal int err, all_err = 0; 10122da0c0a7SAkhil Goyal int i, size; 10132da0c0a7SAkhil Goyal 10142da0c0a7SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 10152da0c0a7SAkhil Goyal opts.encrypt = true; 10162da0c0a7SAkhil Goyal opts.protect_frames = true; 10172da0c0a7SAkhil Goyal opts.sa_in_use = 1; 10182da0c0a7SAkhil Goyal opts.nb_td = 1; 10192da0c0a7SAkhil Goyal opts.sectag_insert_mode = 1; 10202da0c0a7SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 10212da0c0a7SAkhil Goyal 10222da0c0a7SAkhil Goyal size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); 10232da0c0a7SAkhil Goyal 10242da0c0a7SAkhil Goyal for (i = 0; i < size; i++) { 10252da0c0a7SAkhil Goyal cur_td = &list_mcs_cipher_vectors[i]; 10262da0c0a7SAkhil Goyal err = test_macsec(&cur_td, MCS_ENCAP_DECAP, &opts); 10272da0c0a7SAkhil Goyal if (err) { 10282da0c0a7SAkhil Goyal printf("\nCipher Auth Encap-decap case %d failed", cur_td->test_idx); 10292da0c0a7SAkhil Goyal err = -1; 10302da0c0a7SAkhil Goyal } else { 10312da0c0a7SAkhil Goyal printf("\nCipher Auth Encap-decap case %d Passed", cur_td->test_idx); 10322da0c0a7SAkhil Goyal err = 0; 10332da0c0a7SAkhil Goyal } 10342da0c0a7SAkhil Goyal all_err += err; 10352da0c0a7SAkhil Goyal } 10362da0c0a7SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 10372da0c0a7SAkhil Goyal 10382da0c0a7SAkhil Goyal return all_err; 10392da0c0a7SAkhil Goyal } 10402da0c0a7SAkhil Goyal 10412da0c0a7SAkhil Goyal 10422da0c0a7SAkhil Goyal static int 10432da0c0a7SAkhil Goyal test_inline_macsec_auth_verify_all(const void *data __rte_unused) 10442da0c0a7SAkhil Goyal { 10452da0c0a7SAkhil Goyal const struct mcs_test_vector *cur_td; 10462da0c0a7SAkhil Goyal struct mcs_test_opts opts = {0}; 10472da0c0a7SAkhil Goyal int err, all_err = 0; 10482da0c0a7SAkhil Goyal int i, size; 10492da0c0a7SAkhil Goyal 10502da0c0a7SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 10512da0c0a7SAkhil Goyal opts.protect_frames = true; 10522da0c0a7SAkhil Goyal opts.sa_in_use = 1; 10532da0c0a7SAkhil Goyal opts.nb_td = 1; 10542da0c0a7SAkhil Goyal opts.sectag_insert_mode = 1; 10552da0c0a7SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 10562da0c0a7SAkhil Goyal 10572da0c0a7SAkhil Goyal size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); 10582da0c0a7SAkhil Goyal 10592da0c0a7SAkhil Goyal for (i = 0; i < size; i++) { 10602da0c0a7SAkhil Goyal cur_td = &list_mcs_integrity_vectors[i]; 10612da0c0a7SAkhil Goyal err = test_macsec(&cur_td, MCS_AUTH_VERIFY, &opts); 10622da0c0a7SAkhil Goyal if (err) { 10632da0c0a7SAkhil Goyal printf("\nAuth Generate + Verify case %d failed", cur_td->test_idx); 10642da0c0a7SAkhil Goyal err = -1; 10652da0c0a7SAkhil Goyal } else { 10662da0c0a7SAkhil Goyal printf("\nAuth Generate + Verify case %d Passed", cur_td->test_idx); 10672da0c0a7SAkhil Goyal err = 0; 10682da0c0a7SAkhil Goyal } 10692da0c0a7SAkhil Goyal all_err += err; 10702da0c0a7SAkhil Goyal } 10712da0c0a7SAkhil Goyal printf("\n%s: Success: %d, Failure: %d\n", __func__, size + all_err, -all_err); 10722da0c0a7SAkhil Goyal 10732da0c0a7SAkhil Goyal return all_err; 10742da0c0a7SAkhil Goyal } 10752da0c0a7SAkhil Goyal 10762da0c0a7SAkhil Goyal static int 1077*e3d83ea4SAkhil Goyal test_inline_macsec_multi_flow(const void *data __rte_unused) 1078*e3d83ea4SAkhil Goyal { 1079*e3d83ea4SAkhil Goyal const struct mcs_test_vector *tv[MCS_MAX_FLOWS]; 1080*e3d83ea4SAkhil Goyal struct mcs_test_vector iter[MCS_MAX_FLOWS]; 1081*e3d83ea4SAkhil Goyal struct mcs_test_opts opts = {0}; 1082*e3d83ea4SAkhil Goyal int i, err; 1083*e3d83ea4SAkhil Goyal 1084*e3d83ea4SAkhil Goyal opts.val_frames = RTE_SECURITY_MACSEC_VALIDATE_STRICT; 1085*e3d83ea4SAkhil Goyal opts.encrypt = true; 1086*e3d83ea4SAkhil Goyal opts.protect_frames = true; 1087*e3d83ea4SAkhil Goyal opts.sa_in_use = 1; 1088*e3d83ea4SAkhil Goyal opts.nb_td = MCS_MAX_FLOWS; 1089*e3d83ea4SAkhil Goyal opts.sectag_insert_mode = 1; 1090*e3d83ea4SAkhil Goyal opts.mtu = RTE_ETHER_MTU; 1091*e3d83ea4SAkhil Goyal 1092*e3d83ea4SAkhil Goyal for (i = 0; i < MCS_MAX_FLOWS; i++) { 1093*e3d83ea4SAkhil Goyal memcpy(&iter[i].sa_key.data, sa_key, MCS_MULTI_FLOW_TD_KEY_SZ); 1094*e3d83ea4SAkhil Goyal memcpy(&iter[i].plain_pkt.data, eth_addrs[i], 2 * RTE_ETHER_ADDR_LEN); 1095*e3d83ea4SAkhil Goyal memcpy(&iter[i].plain_pkt.data[2 * RTE_ETHER_ADDR_LEN], plain_user_data, 1096*e3d83ea4SAkhil Goyal MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ); 1097*e3d83ea4SAkhil Goyal memcpy(&iter[i].secure_pkt.data, eth_addrs[i], 2 * RTE_ETHER_ADDR_LEN); 1098*e3d83ea4SAkhil Goyal memcpy(&iter[i].secure_pkt.data[2 * RTE_ETHER_ADDR_LEN], secure_user_data, 1099*e3d83ea4SAkhil Goyal MCS_MULTI_FLOW_TD_SECURE_DATA_SZ); 1100*e3d83ea4SAkhil Goyal iter[i].sa_key.len = MCS_MULTI_FLOW_TD_KEY_SZ; 1101*e3d83ea4SAkhil Goyal iter[i].plain_pkt.len = MCS_MULTI_FLOW_TD_PLAIN_DATA_SZ + 1102*e3d83ea4SAkhil Goyal (2 * RTE_ETHER_ADDR_LEN); 1103*e3d83ea4SAkhil Goyal iter[i].secure_pkt.len = MCS_MULTI_FLOW_TD_SECURE_DATA_SZ + 1104*e3d83ea4SAkhil Goyal (2 * RTE_ETHER_ADDR_LEN); 1105*e3d83ea4SAkhil Goyal iter[i].alg = RTE_SECURITY_MACSEC_ALG_GCM_128; 1106*e3d83ea4SAkhil Goyal iter[i].ssci = 0x0; 1107*e3d83ea4SAkhil Goyal iter[i].xpn = 0x0; 1108*e3d83ea4SAkhil Goyal tv[i] = (const struct mcs_test_vector *)&iter[i]; 1109*e3d83ea4SAkhil Goyal } 1110*e3d83ea4SAkhil Goyal err = test_macsec(tv, MCS_ENCAP_DECAP, &opts); 1111*e3d83ea4SAkhil Goyal if (err) { 1112*e3d83ea4SAkhil Goyal printf("\nCipher Auth Encryption multi flow failed"); 1113*e3d83ea4SAkhil Goyal err = -1; 1114*e3d83ea4SAkhil Goyal } else { 1115*e3d83ea4SAkhil Goyal printf("\nCipher Auth Encryption multi flow Passed"); 1116*e3d83ea4SAkhil Goyal err = 0; 1117*e3d83ea4SAkhil Goyal } 1118*e3d83ea4SAkhil Goyal return err; 1119*e3d83ea4SAkhil Goyal } 1120*e3d83ea4SAkhil Goyal 1121*e3d83ea4SAkhil Goyal static int 1122993ea577SAkhil Goyal ut_setup_inline_macsec(void) 1123993ea577SAkhil Goyal { 1124993ea577SAkhil Goyal int ret; 1125993ea577SAkhil Goyal 1126993ea577SAkhil Goyal /* Start device */ 1127993ea577SAkhil Goyal ret = rte_eth_dev_start(port_id); 1128993ea577SAkhil Goyal if (ret < 0) { 1129993ea577SAkhil Goyal printf("rte_eth_dev_start: err=%d, port=%d\n", 1130993ea577SAkhil Goyal ret, port_id); 1131993ea577SAkhil Goyal return ret; 1132993ea577SAkhil Goyal } 1133993ea577SAkhil Goyal /* always enable promiscuous */ 1134993ea577SAkhil Goyal ret = rte_eth_promiscuous_enable(port_id); 1135993ea577SAkhil Goyal if (ret != 0) { 1136993ea577SAkhil Goyal printf("rte_eth_promiscuous_enable: err=%s, port=%d\n", 1137993ea577SAkhil Goyal rte_strerror(-ret), port_id); 1138993ea577SAkhil Goyal return ret; 1139993ea577SAkhil Goyal } 1140993ea577SAkhil Goyal 1141993ea577SAkhil Goyal check_all_ports_link_status(1, RTE_PORT_ALL); 1142993ea577SAkhil Goyal 1143993ea577SAkhil Goyal return 0; 1144993ea577SAkhil Goyal } 1145993ea577SAkhil Goyal 1146993ea577SAkhil Goyal static void 1147993ea577SAkhil Goyal ut_teardown_inline_macsec(void) 1148993ea577SAkhil Goyal { 1149993ea577SAkhil Goyal uint16_t portid; 1150993ea577SAkhil Goyal int ret; 1151993ea577SAkhil Goyal 1152993ea577SAkhil Goyal /* port tear down */ 1153993ea577SAkhil Goyal RTE_ETH_FOREACH_DEV(portid) { 1154993ea577SAkhil Goyal ret = rte_eth_dev_stop(portid); 1155993ea577SAkhil Goyal if (ret != 0) 1156993ea577SAkhil Goyal printf("rte_eth_dev_stop: err=%s, port=%u\n", 1157993ea577SAkhil Goyal rte_strerror(-ret), portid); 1158993ea577SAkhil Goyal 1159993ea577SAkhil Goyal } 1160993ea577SAkhil Goyal } 1161993ea577SAkhil Goyal 1162993ea577SAkhil Goyal static int 1163993ea577SAkhil Goyal inline_macsec_testsuite_setup(void) 1164993ea577SAkhil Goyal { 1165993ea577SAkhil Goyal uint16_t nb_rxd; 1166993ea577SAkhil Goyal uint16_t nb_txd; 1167993ea577SAkhil Goyal uint16_t nb_ports; 1168993ea577SAkhil Goyal int ret; 1169993ea577SAkhil Goyal uint16_t nb_rx_queue = 1, nb_tx_queue = 1; 1170993ea577SAkhil Goyal 1171993ea577SAkhil Goyal printf("Start inline MACsec test.\n"); 1172993ea577SAkhil Goyal 1173993ea577SAkhil Goyal nb_ports = rte_eth_dev_count_avail(); 1174993ea577SAkhil Goyal if (nb_ports < NB_ETHPORTS_USED) { 1175993ea577SAkhil Goyal printf("At least %u port(s) used for test\n", 1176993ea577SAkhil Goyal NB_ETHPORTS_USED); 1177993ea577SAkhil Goyal return TEST_SKIPPED; 1178993ea577SAkhil Goyal } 1179993ea577SAkhil Goyal 1180993ea577SAkhil Goyal ret = init_mempools(NB_MBUF); 1181993ea577SAkhil Goyal if (ret) 1182993ea577SAkhil Goyal return ret; 1183993ea577SAkhil Goyal 1184993ea577SAkhil Goyal if (tx_pkts_burst == NULL) { 1185993ea577SAkhil Goyal tx_pkts_burst = (struct rte_mbuf **)rte_calloc("tx_buff", 1186993ea577SAkhil Goyal MAX_TRAFFIC_BURST, 1187993ea577SAkhil Goyal sizeof(void *), 1188993ea577SAkhil Goyal RTE_CACHE_LINE_SIZE); 1189993ea577SAkhil Goyal if (!tx_pkts_burst) 1190993ea577SAkhil Goyal return TEST_FAILED; 1191993ea577SAkhil Goyal 1192993ea577SAkhil Goyal rx_pkts_burst = (struct rte_mbuf **)rte_calloc("rx_buff", 1193993ea577SAkhil Goyal MAX_TRAFFIC_BURST, 1194993ea577SAkhil Goyal sizeof(void *), 1195993ea577SAkhil Goyal RTE_CACHE_LINE_SIZE); 1196993ea577SAkhil Goyal if (!rx_pkts_burst) 1197993ea577SAkhil Goyal return TEST_FAILED; 1198993ea577SAkhil Goyal } 1199993ea577SAkhil Goyal 1200993ea577SAkhil Goyal printf("Generate %d packets\n", MAX_TRAFFIC_BURST); 1201993ea577SAkhil Goyal 1202993ea577SAkhil Goyal nb_rxd = RTE_TEST_RX_DESC_DEFAULT; 1203993ea577SAkhil Goyal nb_txd = RTE_TEST_TX_DESC_DEFAULT; 1204993ea577SAkhil Goyal 1205993ea577SAkhil Goyal /* configuring port 0 for the test is enough */ 1206993ea577SAkhil Goyal port_id = 0; 1207993ea577SAkhil Goyal /* port configure */ 1208993ea577SAkhil Goyal ret = rte_eth_dev_configure(port_id, nb_rx_queue, 1209993ea577SAkhil Goyal nb_tx_queue, &port_conf); 1210993ea577SAkhil Goyal if (ret < 0) { 1211993ea577SAkhil Goyal printf("Cannot configure device: err=%d, port=%d\n", 1212993ea577SAkhil Goyal ret, port_id); 1213993ea577SAkhil Goyal return ret; 1214993ea577SAkhil Goyal } 1215993ea577SAkhil Goyal ret = rte_eth_macaddr_get(port_id, &ports_eth_addr[port_id]); 1216993ea577SAkhil Goyal if (ret < 0) { 1217993ea577SAkhil Goyal printf("Cannot get mac address: err=%d, port=%d\n", 1218993ea577SAkhil Goyal ret, port_id); 1219993ea577SAkhil Goyal return ret; 1220993ea577SAkhil Goyal } 1221993ea577SAkhil Goyal printf("Port %u ", port_id); 1222993ea577SAkhil Goyal print_ethaddr("Address:", &ports_eth_addr[port_id]); 1223993ea577SAkhil Goyal printf("\n"); 1224993ea577SAkhil Goyal 1225993ea577SAkhil Goyal /* tx queue setup */ 1226993ea577SAkhil Goyal ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd, 1227993ea577SAkhil Goyal SOCKET_ID_ANY, &tx_conf); 1228993ea577SAkhil Goyal if (ret < 0) { 1229993ea577SAkhil Goyal printf("rte_eth_tx_queue_setup: err=%d, port=%d\n", 1230993ea577SAkhil Goyal ret, port_id); 1231993ea577SAkhil Goyal return ret; 1232993ea577SAkhil Goyal } 1233993ea577SAkhil Goyal /* rx queue steup */ 1234993ea577SAkhil Goyal ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, SOCKET_ID_ANY, 1235993ea577SAkhil Goyal &rx_conf, mbufpool); 1236993ea577SAkhil Goyal if (ret < 0) { 1237993ea577SAkhil Goyal printf("rte_eth_rx_queue_setup: err=%d, port=%d\n", 1238993ea577SAkhil Goyal ret, port_id); 1239993ea577SAkhil Goyal return ret; 1240993ea577SAkhil Goyal } 1241993ea577SAkhil Goyal 1242993ea577SAkhil Goyal return 0; 1243993ea577SAkhil Goyal } 1244993ea577SAkhil Goyal 1245993ea577SAkhil Goyal static void 1246993ea577SAkhil Goyal inline_macsec_testsuite_teardown(void) 1247993ea577SAkhil Goyal { 1248993ea577SAkhil Goyal uint16_t portid; 1249993ea577SAkhil Goyal int ret; 1250993ea577SAkhil Goyal 1251993ea577SAkhil Goyal /* port tear down */ 1252993ea577SAkhil Goyal RTE_ETH_FOREACH_DEV(portid) { 1253993ea577SAkhil Goyal ret = rte_eth_dev_reset(portid); 1254993ea577SAkhil Goyal if (ret != 0) 1255993ea577SAkhil Goyal printf("rte_eth_dev_reset: err=%s, port=%u\n", 1256993ea577SAkhil Goyal rte_strerror(-ret), port_id); 1257993ea577SAkhil Goyal } 1258993ea577SAkhil Goyal rte_free(tx_pkts_burst); 1259993ea577SAkhil Goyal rte_free(rx_pkts_burst); 1260993ea577SAkhil Goyal } 1261993ea577SAkhil Goyal 1262993ea577SAkhil Goyal 1263993ea577SAkhil Goyal static struct unit_test_suite inline_macsec_testsuite = { 1264993ea577SAkhil Goyal .suite_name = "Inline MACsec Ethernet Device Unit Test Suite", 1265993ea577SAkhil Goyal .unit_test_cases = { 1266993ea577SAkhil Goyal TEST_CASE_NAMED_ST( 1267*e3d83ea4SAkhil Goyal "MACsec Encap + decap Multi flow", 1268*e3d83ea4SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 1269*e3d83ea4SAkhil Goyal test_inline_macsec_multi_flow), 1270*e3d83ea4SAkhil Goyal TEST_CASE_NAMED_ST( 1271993ea577SAkhil Goyal "MACsec encap(Cipher+Auth) known vector", 1272993ea577SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 1273993ea577SAkhil Goyal test_inline_macsec_encap_all), 1274993ea577SAkhil Goyal TEST_CASE_NAMED_ST( 1275993ea577SAkhil Goyal "MACsec decap(De-cipher+verify) known vector", 1276993ea577SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 1277993ea577SAkhil Goyal test_inline_macsec_decap_all), 12782da0c0a7SAkhil Goyal TEST_CASE_NAMED_ST( 12792da0c0a7SAkhil Goyal "MACsec auth only known vector", 12802da0c0a7SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 12812da0c0a7SAkhil Goyal test_inline_macsec_auth_only_all), 12822da0c0a7SAkhil Goyal TEST_CASE_NAMED_ST( 12832da0c0a7SAkhil Goyal "MACsec verify only known vector", 12842da0c0a7SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 12852da0c0a7SAkhil Goyal test_inline_macsec_verify_only_all), 12862da0c0a7SAkhil Goyal TEST_CASE_NAMED_ST( 12872da0c0a7SAkhil Goyal "MACsec encap + decap known vector", 12882da0c0a7SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 12892da0c0a7SAkhil Goyal test_inline_macsec_encap_decap_all), 12902da0c0a7SAkhil Goyal TEST_CASE_NAMED_ST( 12912da0c0a7SAkhil Goyal "MACsec auth + verify known vector", 12922da0c0a7SAkhil Goyal ut_setup_inline_macsec, ut_teardown_inline_macsec, 12932da0c0a7SAkhil Goyal test_inline_macsec_auth_verify_all), 1294993ea577SAkhil Goyal 1295993ea577SAkhil Goyal TEST_CASES_END() /**< NULL terminate unit test array */ 1296993ea577SAkhil Goyal }, 1297993ea577SAkhil Goyal }; 1298993ea577SAkhil Goyal 1299993ea577SAkhil Goyal static int 1300993ea577SAkhil Goyal test_inline_macsec(void) 1301993ea577SAkhil Goyal { 1302993ea577SAkhil Goyal inline_macsec_testsuite.setup = inline_macsec_testsuite_setup; 1303993ea577SAkhil Goyal inline_macsec_testsuite.teardown = inline_macsec_testsuite_teardown; 1304993ea577SAkhil Goyal return unit_test_suite_runner(&inline_macsec_testsuite); 1305993ea577SAkhil Goyal } 1306993ea577SAkhil Goyal 1307993ea577SAkhil Goyal #endif /* !RTE_EXEC_ENV_WINDOWS */ 1308993ea577SAkhil Goyal 1309993ea577SAkhil Goyal REGISTER_TEST_COMMAND(inline_macsec_autotest, test_inline_macsec); 1310