diff --git a/dpdk/app/test/has_hugepage.py b/dpdk/app/test/has_hugepage.py deleted file mode 100644 index c0dd005f9..000000000 --- a/dpdk/app/test/has_hugepage.py +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2021 Microsoft Corporation -"""This script checks if the system supports huge pages""" - -import platform -import ctypes - -os_name = platform.system() -if os_name == "Linux": - try: - with open("/proc/sys/vm/nr_hugepages") as file_o: - content = file_o.read() - print(content) - except: - print("0") - -elif os_name == "FreeBSD": - # Assume FreeBSD always has hugepages enabled - print("1") -elif os_name == "Windows": - if ctypes.windll.kernel32.GetLargePageMinimum() > 0: - print("1") - else: - print("0") -else: - print("0") diff --git a/dpdk/app/test/test_flow_classify.c b/dpdk/app/test/test_flow_classify.c deleted file mode 100644 index 6e274d88e..000000000 --- a/dpdk/app/test/test_flow_classify.c +++ /dev/null @@ -1,895 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#include -#include - -#include "test.h" - -#include -#include -#include -#include - -#ifdef RTE_EXEC_ENV_WINDOWS -static int -test_flow_classify(void) -{ - printf("flow_classify not supported on Windows, skipping test\n"); - return TEST_SKIPPED; -} - -#else - -#include -#include -#include -#include -#include - -#include "packet_burst_generator.h" -#include "test_flow_classify.h" - - -#define FLOW_CLASSIFY_MAX_RULE_NUM 100 -#define MAX_PKT_BURST 32 -#define NB_SOCKETS 4 -#define MEMPOOL_CACHE_SIZE 256 -#define MBUF_SIZE 512 -#define NB_MBUF 512 - -/* test UDP, TCP and SCTP packets */ -static struct rte_mempool *mbufpool[NB_SOCKETS]; -static struct rte_mbuf *bufs[MAX_PKT_BURST]; - -static struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = { - /* first input field - always one byte long. */ - { - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint8_t), - .field_index = PROTO_FIELD_IPV4, - .input_index = PROTO_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, next_proto_id), - }, - /* next input field (IPv4 source address) - 4 consecutive bytes. */ - { - /* rte_flow uses a bit mask for IPv4 addresses */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint32_t), - .field_index = SRC_FIELD_IPV4, - .input_index = SRC_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, src_addr), - }, - /* next input field (IPv4 destination address) - 4 consecutive bytes. */ - { - /* rte_flow uses a bit mask for IPv4 addresses */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint32_t), - .field_index = DST_FIELD_IPV4, - .input_index = DST_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, dst_addr), - }, - /* - * Next 2 fields (src & dst ports) form 4 consecutive bytes. - * They share the same input index. - */ - { - /* rte_flow uses a bit mask for protocol ports */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint16_t), - .field_index = SRCP_FIELD_IPV4, - .input_index = SRCP_DESTP_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - sizeof(struct rte_ipv4_hdr) + - offsetof(struct rte_tcp_hdr, src_port), - }, - { - /* rte_flow uses a bit mask for protocol ports */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint16_t), - .field_index = DSTP_FIELD_IPV4, - .input_index = SRCP_DESTP_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - sizeof(struct rte_ipv4_hdr) + - offsetof(struct rte_tcp_hdr, dst_port), - }, -}; - -/* parameters for rte_flow_classify_validate and rte_flow_classify_create */ - -/* test UDP pattern: - * "eth / ipv4 src spec 2.2.2.3 src mask 255.255.255.00 dst spec 2.2.2.7 - * dst mask 255.255.255.00 / udp src is 32 dst is 33 / end" - */ -static struct rte_flow_item_ipv4 ipv4_udp_spec_1 = { - { { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_UDP, 0, - RTE_IPV4(2, 2, 2, 3), RTE_IPV4(2, 2, 2, 7)} -}; -static const struct rte_flow_item_ipv4 ipv4_mask_24 = { - .hdr = { - .next_proto_id = 0xff, - .src_addr = 0xffffff00, - .dst_addr = 0xffffff00, - }, -}; -static struct rte_flow_item_udp udp_spec_1 = { - { 32, 33, 0, 0 } -}; - -static struct rte_flow_item eth_item = { RTE_FLOW_ITEM_TYPE_ETH, - 0, 0, 0 }; -static struct rte_flow_item eth_item_bad = { -1, 0, 0, 0 }; - -static struct rte_flow_item ipv4_udp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4, - &ipv4_udp_spec_1, 0, &ipv4_mask_24}; -static struct rte_flow_item ipv4_udp_item_bad = { RTE_FLOW_ITEM_TYPE_IPV4, - NULL, 0, NULL}; - -static struct rte_flow_item udp_item_1 = { RTE_FLOW_ITEM_TYPE_UDP, - &udp_spec_1, 0, &rte_flow_item_udp_mask}; -static struct rte_flow_item udp_item_bad = { RTE_FLOW_ITEM_TYPE_UDP, - NULL, 0, NULL}; - -static struct rte_flow_item end_item = { RTE_FLOW_ITEM_TYPE_END, - 0, 0, 0 }; - -/* test TCP pattern: - * "eth / ipv4 src spec 1.2.3.4 src mask 255.255.255.00 dst spec 5.6.7.8 - * dst mask 255.255.255.00 / tcp src is 16 dst is 17 / end" - */ -static struct rte_flow_item_ipv4 ipv4_tcp_spec_1 = { - { { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_TCP, 0, - RTE_IPV4(1, 2, 3, 4), RTE_IPV4(5, 6, 7, 8)} -}; - -static struct rte_flow_item_tcp tcp_spec_1 = { - { 16, 17, 0, 0, 0, 0, 0, 0, 0} -}; - -static struct rte_flow_item ipv4_tcp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4, - &ipv4_tcp_spec_1, 0, &ipv4_mask_24}; - -static struct rte_flow_item tcp_item_1 = { RTE_FLOW_ITEM_TYPE_TCP, - &tcp_spec_1, 0, &rte_flow_item_tcp_mask}; - -/* test SCTP pattern: - * "eth / ipv4 src spec 1.2.3.4 src mask 255.255.255.00 dst spec 5.6.7.8 - * dst mask 255.255.255.00 / sctp src is 16 dst is 17/ end" - */ -static struct rte_flow_item_ipv4 ipv4_sctp_spec_1 = { - { { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_SCTP, 0, - RTE_IPV4(11, 12, 13, 14), RTE_IPV4(15, 16, 17, 18)} -}; - -static struct rte_flow_item_sctp sctp_spec_1 = { - { 10, 11, 0, 0} -}; - -static struct rte_flow_item ipv4_sctp_item_1 = { RTE_FLOW_ITEM_TYPE_IPV4, - &ipv4_sctp_spec_1, 0, &ipv4_mask_24}; - -static struct rte_flow_item sctp_item_1 = { RTE_FLOW_ITEM_TYPE_SCTP, - &sctp_spec_1, 0, &rte_flow_item_sctp_mask}; - - -/* test actions: - * "actions count / end" - */ -static struct rte_flow_query_count count = { - .reset = 1, - .hits_set = 1, - .bytes_set = 1, - .hits = 0, - .bytes = 0, -}; -static struct rte_flow_action count_action = { RTE_FLOW_ACTION_TYPE_COUNT, - &count}; -static struct rte_flow_action count_action_bad = { -1, 0}; - -static struct rte_flow_action end_action = { RTE_FLOW_ACTION_TYPE_END, 0}; - -static struct rte_flow_action actions[2]; - -/* test attributes */ -static struct rte_flow_attr attr; - -/* test error */ -static struct rte_flow_error error; - -/* test pattern */ -static struct rte_flow_item pattern[4]; - -/* flow classify data for UDP burst */ -static struct rte_flow_classify_ipv4_5tuple_stats udp_ntuple_stats; -static struct rte_flow_classify_stats udp_classify_stats = { - .stats = (void *)&udp_ntuple_stats -}; - -/* flow classify data for TCP burst */ -static struct rte_flow_classify_ipv4_5tuple_stats tcp_ntuple_stats; -static struct rte_flow_classify_stats tcp_classify_stats = { - .stats = (void *)&tcp_ntuple_stats -}; - -/* flow classify data for SCTP burst */ -static struct rte_flow_classify_ipv4_5tuple_stats sctp_ntuple_stats; -static struct rte_flow_classify_stats sctp_classify_stats = { - .stats = (void *)&sctp_ntuple_stats -}; - -struct flow_classifier_acl *cls; - -struct flow_classifier_acl { - struct rte_flow_classifier *cls; -} __rte_cache_aligned; - -/* - * test functions by passing invalid or - * non-workable parameters. - */ -static int -test_invalid_parameters(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - - ret = rte_flow_classify_validate(NULL, NULL, NULL, NULL, NULL); - if (!ret) { - printf("Line %i: rte_flow_classify_validate", - __LINE__); - printf(" with NULL param should have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL, - NULL, NULL); - if (rule) { - printf("Line %i: flow_classifier_table_entry_add", __LINE__); - printf(" with NULL param should have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(NULL, NULL); - if (!ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" with NULL param should have failed!\n"); - return -1; - } - - ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL); - if (!ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" with NULL param should have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL, - NULL, &error); - if (rule) { - printf("Line %i: flow_classify_table_entry_add ", __LINE__); - printf("with NULL param should have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(NULL, NULL); - if (!ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf("with NULL param should have failed!\n"); - return -1; - } - - ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL); - if (!ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" with NULL param should have failed!\n"); - return -1; - } - return 0; -} - -static int -test_valid_parameters(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - int key_found; - - /* - * set up parameters for rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item; - pattern[1] = ipv4_udp_item_1; - pattern[2] = udp_item_1; - pattern[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (ret) { - printf("Line %i: rte_flow_classify_validate", - __LINE__); - printf(" should not have failed!\n"); - return -1; - } - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - - if (!rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should not have failed!\n"); - return -1; - } - return 0; -} - -static int -test_invalid_patterns(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - int key_found; - - /* - * set up parameters for rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item_bad; - pattern[1] = ipv4_udp_item_1; - pattern[2] = udp_item_1; - pattern[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - pattern[0] = eth_item; - pattern[1] = ipv4_udp_item_bad; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (!ret) { - printf("Line %i: rte_flow_classify_validate", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (!ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should have failed!\n"); - return -1; - } - - pattern[1] = ipv4_udp_item_1; - pattern[2] = udp_item_bad; - pattern[3] = end_item; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (!ret) { - printf("Line %i: rte_flow_classify_validate", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (!ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should have failed!\n"); - return -1; - } - return 0; -} - -static int -test_invalid_actions(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - int key_found; - - /* - * set up parameters for rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item; - pattern[1] = ipv4_udp_item_1; - pattern[2] = udp_item_1; - pattern[3] = end_item; - actions[0] = count_action_bad; - actions[1] = end_action; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (!ret) { - printf("Line %i: rte_flow_classify_validate", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (!ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should have failed!\n"); - return -1; - } - - return 0; -} - -static int -init_ipv4_udp_traffic(struct rte_mempool *mp, - struct rte_mbuf **pkts_burst, uint32_t burst_size) -{ - struct rte_ether_hdr pkt_eth_hdr; - struct rte_ipv4_hdr pkt_ipv4_hdr; - struct rte_udp_hdr pkt_udp_hdr; - uint32_t src_addr = IPV4_ADDR(2, 2, 2, 3); - uint32_t dst_addr = IPV4_ADDR(2, 2, 2, 7); - uint16_t src_port = 32; - uint16_t dst_port = 33; - uint16_t pktlen; - - static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF }; - static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA }; - - printf("Set up IPv4 UDP traffic\n"); - initialize_eth_header(&pkt_eth_hdr, - (struct rte_ether_addr *)src_mac, - (struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0); - pktlen = (uint16_t)(sizeof(struct rte_ether_hdr)); - printf("ETH pktlen %u\n", pktlen); - - pktlen = initialize_ipv4_header(&pkt_ipv4_hdr, src_addr, dst_addr, - pktlen); - printf("ETH + IPv4 pktlen %u\n", pktlen); - - pktlen = initialize_udp_header(&pkt_udp_hdr, src_port, dst_port, - pktlen); - printf("ETH + IPv4 + UDP pktlen %u\n\n", pktlen); - - return generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr, - 0, &pkt_ipv4_hdr, 1, - &pkt_udp_hdr, burst_size, - PACKET_BURST_GEN_PKT_LEN, 1); -} - -static int -init_ipv4_tcp_traffic(struct rte_mempool *mp, - struct rte_mbuf **pkts_burst, uint32_t burst_size) -{ - struct rte_ether_hdr pkt_eth_hdr; - struct rte_ipv4_hdr pkt_ipv4_hdr; - struct rte_tcp_hdr pkt_tcp_hdr; - uint32_t src_addr = IPV4_ADDR(1, 2, 3, 4); - uint32_t dst_addr = IPV4_ADDR(5, 6, 7, 8); - uint16_t src_port = 16; - uint16_t dst_port = 17; - uint16_t pktlen; - - static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF }; - static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA }; - - printf("Set up IPv4 TCP traffic\n"); - initialize_eth_header(&pkt_eth_hdr, - (struct rte_ether_addr *)src_mac, - (struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0); - pktlen = (uint16_t)(sizeof(struct rte_ether_hdr)); - printf("ETH pktlen %u\n", pktlen); - - pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr, - dst_addr, pktlen, IPPROTO_TCP); - printf("ETH + IPv4 pktlen %u\n", pktlen); - - pktlen = initialize_tcp_header(&pkt_tcp_hdr, src_port, dst_port, - pktlen); - printf("ETH + IPv4 + TCP pktlen %u\n\n", pktlen); - - return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr, - 0, &pkt_ipv4_hdr, 1, IPPROTO_TCP, - &pkt_tcp_hdr, burst_size, - PACKET_BURST_GEN_PKT_LEN, 1); -} - -static int -init_ipv4_sctp_traffic(struct rte_mempool *mp, - struct rte_mbuf **pkts_burst, uint32_t burst_size) -{ - struct rte_ether_hdr pkt_eth_hdr; - struct rte_ipv4_hdr pkt_ipv4_hdr; - struct rte_sctp_hdr pkt_sctp_hdr; - uint32_t src_addr = IPV4_ADDR(11, 12, 13, 14); - uint32_t dst_addr = IPV4_ADDR(15, 16, 17, 18); - uint16_t src_port = 10; - uint16_t dst_port = 11; - uint16_t pktlen; - - static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF }; - static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA }; - - printf("Set up IPv4 SCTP traffic\n"); - initialize_eth_header(&pkt_eth_hdr, - (struct rte_ether_addr *)src_mac, - (struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0); - pktlen = (uint16_t)(sizeof(struct rte_ether_hdr)); - printf("ETH pktlen %u\n", pktlen); - - pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr, - dst_addr, pktlen, IPPROTO_SCTP); - printf("ETH + IPv4 pktlen %u\n", pktlen); - - pktlen = initialize_sctp_header(&pkt_sctp_hdr, src_port, dst_port, - pktlen); - printf("ETH + IPv4 + SCTP pktlen %u\n\n", pktlen); - - return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr, - 0, &pkt_ipv4_hdr, 1, IPPROTO_SCTP, - &pkt_sctp_hdr, burst_size, - PACKET_BURST_GEN_PKT_LEN, 1); -} - -static int -init_mbufpool(void) -{ - int socketid; - int ret = 0; - unsigned int lcore_id; - char s[64]; - - for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { - if (rte_lcore_is_enabled(lcore_id) == 0) - continue; - - socketid = rte_lcore_to_socket_id(lcore_id); - if (socketid >= NB_SOCKETS) { - printf( - "Socket %d of lcore %u is out of range %d\n", - socketid, lcore_id, NB_SOCKETS); - ret = -1; - break; - } - if (mbufpool[socketid] == NULL) { - snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); - mbufpool[socketid] = - rte_pktmbuf_pool_create(s, NB_MBUF, - MEMPOOL_CACHE_SIZE, 0, MBUF_SIZE, - socketid); - if (mbufpool[socketid]) { - printf("Allocated mbuf pool on socket %d\n", - socketid); - } else { - printf("Cannot init mbuf pool on socket %d\n", - socketid); - ret = -ENOMEM; - break; - } - } - } - return ret; -} - -static int -test_query_udp(void) -{ - struct rte_flow_error error; - struct rte_flow_classify_rule *rule; - int ret; - int i; - int key_found; - - ret = init_ipv4_udp_traffic(mbufpool[0], bufs, MAX_PKT_BURST); - if (ret != MAX_PKT_BURST) { - printf("Line %i: init_udp_ipv4_traffic has failed!\n", - __LINE__); - return -1; - } - - for (i = 0; i < MAX_PKT_BURST; i++) - bufs[i]->packet_type = RTE_PTYPE_L3_IPV4; - - /* - * set up parameters for rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item; - pattern[1] = ipv4_udp_item_1; - pattern[2] = udp_item_1; - pattern[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (ret) { - printf("Line %i: rte_flow_classify_validate", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (!rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST, - rule, &udp_classify_stats); - if (ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should not have failed!\n"); - return -1; - } - return 0; -} - -static int -test_query_tcp(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - int i; - int key_found; - - ret = init_ipv4_tcp_traffic(mbufpool[0], bufs, MAX_PKT_BURST); - if (ret != MAX_PKT_BURST) { - printf("Line %i: init_ipv4_tcp_traffic has failed!\n", - __LINE__); - return -1; - } - - for (i = 0; i < MAX_PKT_BURST; i++) - bufs[i]->packet_type = RTE_PTYPE_L3_IPV4; - - /* - * set up parameters for rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item; - pattern[1] = ipv4_tcp_item_1; - pattern[2] = tcp_item_1; - pattern[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (!rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST, - rule, &tcp_classify_stats); - if (ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should not have failed!\n"); - return -1; - } - return 0; -} - -static int -test_query_sctp(void) -{ - struct rte_flow_classify_rule *rule; - int ret; - int i; - int key_found; - - ret = init_ipv4_sctp_traffic(mbufpool[0], bufs, MAX_PKT_BURST); - if (ret != MAX_PKT_BURST) { - printf("Line %i: init_ipv4_tcp_traffic has failed!\n", - __LINE__); - return -1; - } - - for (i = 0; i < MAX_PKT_BURST; i++) - bufs[i]->packet_type = RTE_PTYPE_L3_IPV4; - - /* - * set up parameters rte_flow_classify_validate, - * rte_flow_classify_table_entry_add and - * rte_flow_classify_table_entry_delete - */ - - attr.ingress = 1; - attr.priority = 1; - pattern[0] = eth_item; - pattern[1] = ipv4_sctp_item_1; - pattern[2] = sctp_item_1; - pattern[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - ret = rte_flow_classify_validate(cls->cls, &attr, pattern, - actions, &error); - if (ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern, - actions, &key_found, &error); - if (!rule) { - printf("Line %i: flow_classify_table_entry_add", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST, - rule, &sctp_classify_stats); - if (ret) { - printf("Line %i: flow_classifier_query", __LINE__); - printf(" should not have failed!\n"); - return -1; - } - - ret = rte_flow_classify_table_entry_delete(cls->cls, rule); - if (ret) { - printf("Line %i: rte_flow_classify_table_entry_delete", - __LINE__); - printf(" should not have failed!\n"); - return -1; - } - return 0; -} - -static int -test_flow_classify(void) -{ - struct rte_table_acl_params table_acl_params; - struct rte_flow_classify_table_params cls_table_params; - struct rte_flow_classifier_params cls_params; - int ret; - uint32_t size; - - /* Memory allocation */ - size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct flow_classifier_acl)); - cls = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE); - - cls_params.name = "flow_classifier"; - cls_params.socket_id = 0; - cls->cls = rte_flow_classifier_create(&cls_params); - if (cls->cls == NULL) { - printf("Line %i: flow classifier create has failed!\n", - __LINE__); - rte_free(cls); - return TEST_FAILED; - } - - /* initialise ACL table params */ - table_acl_params.n_rule_fields = RTE_DIM(ipv4_defs); - table_acl_params.name = "table_acl_ipv4_5tuple"; - table_acl_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM; - memcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs)); - - /* initialise table create params */ - cls_table_params.ops = &rte_table_acl_ops; - cls_table_params.arg_create = &table_acl_params; - cls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE; - - ret = rte_flow_classify_table_create(cls->cls, &cls_table_params); - if (ret) { - printf("Line %i: f_create has failed!\n", __LINE__); - rte_flow_classifier_free(cls->cls); - rte_free(cls); - return TEST_FAILED; - } - printf("Created table_acl for for IPv4 five tuple packets\n"); - - ret = init_mbufpool(); - if (ret) { - printf("Line %i: init_mbufpool has failed!\n", __LINE__); - return TEST_FAILED; - } - - if (test_invalid_parameters() < 0) - return TEST_FAILED; - if (test_valid_parameters() < 0) - return TEST_FAILED; - if (test_invalid_patterns() < 0) - return TEST_FAILED; - if (test_invalid_actions() < 0) - return TEST_FAILED; - if (test_query_udp() < 0) - return TEST_FAILED; - if (test_query_tcp() < 0) - return TEST_FAILED; - if (test_query_sctp() < 0) - return TEST_FAILED; - - return TEST_SUCCESS; -} - -#endif /* !RTE_EXEC_ENV_WINDOWS */ - -REGISTER_TEST_COMMAND(flow_classify_autotest, test_flow_classify); diff --git a/dpdk/app/test/test_flow_classify.h b/dpdk/app/test/test_flow_classify.h deleted file mode 100644 index 6bd10ec97..000000000 --- a/dpdk/app/test/test_flow_classify.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#ifndef TEST_FLOW_CLASSIFY_H_ -#define TEST_FLOW_CLASSIFY_H_ - -/* ACL field definitions for IPv4 5 tuple rule */ - -enum { - PROTO_FIELD_IPV4, - SRC_FIELD_IPV4, - DST_FIELD_IPV4, - SRCP_FIELD_IPV4, - DSTP_FIELD_IPV4, - NUM_FIELDS_IPV4 -}; - -enum { - PROTO_INPUT_IPV4, - SRC_INPUT_IPV4, - DST_INPUT_IPV4, - SRCP_DESTP_INPUT_IPV4 -}; - -#endif /* TEST_FLOW_CLASSIFY_H_ */ diff --git a/dpdk/app/test/test_kni.c b/dpdk/app/test/test_kni.c deleted file mode 100644 index 4039da0b0..000000000 --- a/dpdk/app/test/test_kni.c +++ /dev/null @@ -1,740 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#include "test.h" - -#include -#include -#include -#include -#if !defined(RTE_EXEC_ENV_LINUX) || !defined(RTE_LIB_KNI) - -static int -test_kni(void) -{ - printf("KNI not supported, skipping test\n"); - return TEST_SKIPPED; -} - -#else - -#include -#include - -#include -#include -#include -#include -#include - -#define NB_MBUF 8192 -#define MAX_PACKET_SZ 2048 -#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM) -#define PKT_BURST_SZ 32 -#define MEMPOOL_CACHE_SZ PKT_BURST_SZ -#define SOCKET 0 -#define NB_RXD 1024 -#define NB_TXD 1024 -#define KNI_TIMEOUT_MS 5000 /* ms */ - -#define IFCONFIG "/sbin/ifconfig " -#define TEST_KNI_PORT "test_kni_port" -#define KNI_MODULE_PATH "/sys/module/rte_kni" -#define KNI_MODULE_PARAM_LO KNI_MODULE_PATH"/parameters/lo_mode" -#define KNI_TEST_MAX_PORTS 4 -/* The threshold number of mbufs to be transmitted or received. */ -#define KNI_NUM_MBUF_THRESHOLD 100 -static int kni_pkt_mtu = 0; - -struct test_kni_stats { - volatile uint64_t ingress; - volatile uint64_t egress; -}; - -static const struct rte_eth_rxconf rx_conf = { - .rx_thresh = { - .pthresh = 8, - .hthresh = 8, - .wthresh = 4, - }, - .rx_free_thresh = 0, -}; - -static const struct rte_eth_txconf tx_conf = { - .tx_thresh = { - .pthresh = 36, - .hthresh = 0, - .wthresh = 0, - }, - .tx_free_thresh = 0, - .tx_rs_thresh = 0, -}; - -static const struct rte_eth_conf port_conf = { - .txmode = { - .mq_mode = RTE_ETH_MQ_TX_NONE, - }, -}; - -static struct rte_kni_ops kni_ops = { - .change_mtu = NULL, - .config_network_if = NULL, - .config_mac_address = NULL, - .config_promiscusity = NULL, -}; - -static unsigned int lcore_main, lcore_ingress, lcore_egress; -static struct rte_kni *test_kni_ctx; -static struct test_kni_stats stats; - -static volatile uint32_t test_kni_processing_flag; - -static struct rte_mempool * -test_kni_create_mempool(void) -{ - struct rte_mempool * mp; - - mp = rte_mempool_lookup("kni_mempool"); - if (!mp) - mp = rte_pktmbuf_pool_create("kni_mempool", - NB_MBUF, - MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ, - SOCKET); - - return mp; -} - -static struct rte_mempool * -test_kni_lookup_mempool(void) -{ - return rte_mempool_lookup("kni_mempool"); -} -/* Callback for request of changing MTU */ -static int -kni_change_mtu(uint16_t port_id, unsigned int new_mtu) -{ - printf("Change MTU of port %d to %u\n", port_id, new_mtu); - kni_pkt_mtu = new_mtu; - printf("Change MTU of port %d to %i successfully.\n", - port_id, kni_pkt_mtu); - return 0; -} - -static int -test_kni_link_change(void) -{ - int ret; - int pid; - - pid = fork(); - if (pid < 0) { - printf("Error: Failed to fork a process\n"); - return -1; - } - - if (pid == 0) { - printf("Starting KNI Link status change tests.\n"); - if (system(IFCONFIG TEST_KNI_PORT" up") == -1) { - ret = -1; - goto error; - } - - ret = rte_kni_update_link(test_kni_ctx, 1); - if (ret < 0) { - printf("Failed to change link state to Up ret=%d.\n", - ret); - goto error; - } - rte_delay_ms(1000); - printf("KNI: Set LINKUP, previous state=%d\n", ret); - - ret = rte_kni_update_link(test_kni_ctx, 0); - if (ret != 1) { - printf( - "Failed! Previous link state should be 1, returned %d.\n", - ret); - goto error; - } - rte_delay_ms(1000); - printf("KNI: Set LINKDOWN, previous state=%d\n", ret); - - ret = rte_kni_update_link(test_kni_ctx, 1); - if (ret != 0) { - printf( - "Failed! Previous link state should be 0, returned %d.\n", - ret); - goto error; - } - printf("KNI: Set LINKUP, previous state=%d\n", ret); - - ret = 0; - rte_delay_ms(1000); - -error: - if (system(IFCONFIG TEST_KNI_PORT" down") == -1) - ret = -1; - - printf("KNI: Link status change tests: %s.\n", - (ret == 0) ? "Passed" : "Failed"); - exit(ret); - } else { - int p_ret, status; - - while (1) { - p_ret = waitpid(pid, &status, WNOHANG); - if (p_ret != 0) { - if (WIFEXITED(status)) - return WEXITSTATUS(status); - return -1; - } - rte_delay_ms(10); - rte_kni_handle_request(test_kni_ctx); - } - } -} -/** - * This loop fully tests the basic functions of KNI. e.g. transmitting, - * receiving to, from kernel space, and kernel requests. - * - * This is the loop to transmit/receive mbufs to/from kernel interface with - * supported by KNI kernel module. The ingress lcore will allocate mbufs and - * transmit them to kernel space; while the egress lcore will receive the mbufs - * from kernel space and free them. - * On the main lcore, several commands will be run to check handling the - * kernel requests. And it will finally set the flag to exit the KNI - * transmitting/receiving to/from the kernel space. - * - * Note: To support this testing, the KNI kernel module needs to be insmodded - * in one of its loopback modes. - */ -static int -test_kni_loop(__rte_unused void *arg) -{ - int ret = 0; - unsigned nb_rx, nb_tx, num, i; - const unsigned lcore_id = rte_lcore_id(); - struct rte_mbuf *pkts_burst[PKT_BURST_SZ]; - - if (lcore_id == lcore_main) { - rte_delay_ms(KNI_TIMEOUT_MS); - /* tests of handling kernel request */ - if (system(IFCONFIG TEST_KNI_PORT" up") == -1) - ret = -1; - if (system(IFCONFIG TEST_KNI_PORT" mtu 1400") == -1) - ret = -1; - if (system(IFCONFIG TEST_KNI_PORT" down") == -1) - ret = -1; - rte_delay_ms(KNI_TIMEOUT_MS); - test_kni_processing_flag = 1; - } else if (lcore_id == lcore_ingress) { - struct rte_mempool *mp = test_kni_lookup_mempool(); - - if (mp == NULL) - return -1; - - while (1) { - if (test_kni_processing_flag) - break; - - for (nb_rx = 0; nb_rx < PKT_BURST_SZ; nb_rx++) { - pkts_burst[nb_rx] = rte_pktmbuf_alloc(mp); - if (!pkts_burst[nb_rx]) - break; - } - - num = rte_kni_tx_burst(test_kni_ctx, pkts_burst, - nb_rx); - stats.ingress += num; - rte_kni_handle_request(test_kni_ctx); - if (num < nb_rx) { - for (i = num; i < nb_rx; i++) { - rte_pktmbuf_free(pkts_burst[i]); - } - } - rte_delay_ms(10); - } - } else if (lcore_id == lcore_egress) { - while (1) { - if (test_kni_processing_flag) - break; - num = rte_kni_rx_burst(test_kni_ctx, pkts_burst, - PKT_BURST_SZ); - stats.egress += num; - for (nb_tx = 0; nb_tx < num; nb_tx++) - rte_pktmbuf_free(pkts_burst[nb_tx]); - rte_delay_ms(10); - } - } - - return ret; -} - -static int -test_kni_allocate_lcores(void) -{ - unsigned i, count = 0; - - lcore_main = rte_get_main_lcore(); - printf("main lcore: %u\n", lcore_main); - for (i = 0; i < RTE_MAX_LCORE; i++) { - if (count >=2 ) - break; - if (rte_lcore_is_enabled(i) && i != lcore_main) { - count ++; - if (count == 1) - lcore_ingress = i; - else if (count == 2) - lcore_egress = i; - } - } - printf("count: %u\n", count); - - return count == 2 ? 0 : -1; -} - -static int -test_kni_register_handler_mp(void) -{ -#define TEST_KNI_HANDLE_REQ_COUNT 10 /* 5s */ -#define TEST_KNI_HANDLE_REQ_INTERVAL 500 /* ms */ -#define TEST_KNI_MTU 1450 -#define TEST_KNI_MTU_STR " 1450" - int pid; - - pid = fork(); - if (pid < 0) { - printf("Failed to fork a process\n"); - return -1; - } else if (pid == 0) { - int i; - struct rte_kni *kni = rte_kni_get(TEST_KNI_PORT); - struct rte_kni_ops ops = { - .change_mtu = kni_change_mtu, - .config_network_if = NULL, - .config_mac_address = NULL, - .config_promiscusity = NULL, - }; - - if (!kni) { - printf("Failed to get KNI named %s\n", TEST_KNI_PORT); - exit(-1); - } - - kni_pkt_mtu = 0; - - /* Check with the invalid parameters */ - if (rte_kni_register_handlers(kni, NULL) == 0) { - printf("Unexpectedly register successfully " - "with NULL ops pointer\n"); - exit(-1); - } - if (rte_kni_register_handlers(NULL, &ops) == 0) { - printf("Unexpectedly register successfully " - "to NULL KNI device pointer\n"); - exit(-1); - } - - if (rte_kni_register_handlers(kni, &ops)) { - printf("Fail to register ops\n"); - exit(-1); - } - - /* Check registering again after it has been registered */ - if (rte_kni_register_handlers(kni, &ops) == 0) { - printf("Unexpectedly register successfully after " - "it has already been registered\n"); - exit(-1); - } - - /** - * Handle the request of setting MTU, - * with registered handlers. - */ - for (i = 0; i < TEST_KNI_HANDLE_REQ_COUNT; i++) { - rte_kni_handle_request(kni); - if (kni_pkt_mtu == TEST_KNI_MTU) - break; - rte_delay_ms(TEST_KNI_HANDLE_REQ_INTERVAL); - } - if (i >= TEST_KNI_HANDLE_REQ_COUNT) { - printf("MTU has not been set\n"); - exit(-1); - } - - kni_pkt_mtu = 0; - if (rte_kni_unregister_handlers(kni) < 0) { - printf("Fail to unregister ops\n"); - exit(-1); - } - - /* Check with invalid parameter */ - if (rte_kni_unregister_handlers(NULL) == 0) { - exit(-1); - } - - /** - * Handle the request of setting MTU, - * without registered handlers. - */ - for (i = 0; i < TEST_KNI_HANDLE_REQ_COUNT; i++) { - rte_kni_handle_request(kni); - if (kni_pkt_mtu != 0) - break; - rte_delay_ms(TEST_KNI_HANDLE_REQ_INTERVAL); - } - if (kni_pkt_mtu != 0) { - printf("MTU shouldn't be set\n"); - exit(-1); - } - - exit(0); - } else { - int p_ret, status; - - rte_delay_ms(1000); - if (system(IFCONFIG TEST_KNI_PORT " mtu" TEST_KNI_MTU_STR) - == -1) - return -1; - - rte_delay_ms(1000); - if (system(IFCONFIG TEST_KNI_PORT " mtu" TEST_KNI_MTU_STR) - == -1) - return -1; - - p_ret = wait(&status); - if (!WIFEXITED(status)) { - printf("Child process (%d) exit abnormally\n", p_ret); - return -1; - } - if (WEXITSTATUS(status) != 0) { - printf("Child process exit with failure\n"); - return -1; - } - } - - return 0; -} - -static int -test_kni_processing(uint16_t port_id, struct rte_mempool *mp) -{ - int ret = 0; - unsigned i; - struct rte_kni *kni; - struct rte_kni_conf conf; - struct rte_eth_dev_info info; - struct rte_kni_ops ops; - - if (!mp) - return -1; - - memset(&conf, 0, sizeof(conf)); - memset(&info, 0, sizeof(info)); - memset(&ops, 0, sizeof(ops)); - - ret = rte_eth_dev_info_get(port_id, &info); - if (ret != 0) { - printf("Error during getting device (port %u) info: %s\n", - port_id, strerror(-ret)); - return -1; - } - - snprintf(conf.name, sizeof(conf.name), TEST_KNI_PORT); - - /* core id 1 configured for kernel thread */ - conf.core_id = 1; - conf.force_bind = 1; - conf.mbuf_size = MAX_PACKET_SZ; - conf.group_id = port_id; - - ops = kni_ops; - ops.port_id = port_id; - - /* basic test of kni processing */ - kni = rte_kni_alloc(mp, &conf, &ops); - if (!kni) { - printf("fail to create kni\n"); - return -1; - } - - test_kni_ctx = kni; - test_kni_processing_flag = 0; - stats.ingress = 0; - stats.egress = 0; - - /** - * Check multiple processes support on - * registering/unregistering handlers. - */ - if (test_kni_register_handler_mp() < 0) { - printf("fail to check multiple process support\n"); - ret = -1; - goto fail_kni; - } - - ret = test_kni_link_change(); - if (ret != 0) - goto fail_kni; - - rte_eal_mp_remote_launch(test_kni_loop, NULL, CALL_MAIN); - RTE_LCORE_FOREACH_WORKER(i) { - if (rte_eal_wait_lcore(i) < 0) { - ret = -1; - goto fail_kni; - } - } - /** - * Check if the number of mbufs received from kernel space is equal - * to that of transmitted to kernel space - */ - if (stats.ingress < KNI_NUM_MBUF_THRESHOLD || - stats.egress < KNI_NUM_MBUF_THRESHOLD) { - printf("The ingress/egress number should not be " - "less than %u\n", (unsigned)KNI_NUM_MBUF_THRESHOLD); - ret = -1; - goto fail_kni; - } - - if (rte_kni_release(kni) < 0) { - printf("fail to release kni\n"); - return -1; - } - test_kni_ctx = NULL; - - /* test of reusing memzone */ - kni = rte_kni_alloc(mp, &conf, &ops); - if (!kni) { - printf("fail to create kni\n"); - return -1; - } - - /* Release the kni for following testing */ - if (rte_kni_release(kni) < 0) { - printf("fail to release kni\n"); - return -1; - } - - return ret; -fail_kni: - if (rte_kni_release(kni) < 0) { - printf("fail to release kni\n"); - ret = -1; - } - - return ret; -} - -static int -test_kni(void) -{ - int ret = -1; - uint16_t port_id; - struct rte_kni *kni; - struct rte_mempool *mp; - struct rte_kni_conf conf; - struct rte_eth_dev_info info; - struct rte_kni_ops ops; - FILE *fd; - DIR *dir; - char buf[16]; - - dir = opendir(KNI_MODULE_PATH); - if (!dir) { - if (errno == ENOENT) { - printf("Cannot run UT due to missing rte_kni module\n"); - return TEST_SKIPPED; - } - printf("opendir: %s", strerror(errno)); - return -1; - } - closedir(dir); - - /* Initialize KNI subsystem */ - ret = rte_kni_init(KNI_TEST_MAX_PORTS); - if (ret < 0) { - printf("fail to initialize KNI subsystem\n"); - return -1; - } - - if (test_kni_allocate_lcores() < 0) { - printf("No enough lcores for kni processing\n"); - return -1; - } - - mp = test_kni_create_mempool(); - if (!mp) { - printf("fail to create mempool for kni\n"); - return -1; - } - - /* configuring port 0 for the test is enough */ - port_id = 0; - ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf); - if (ret < 0) { - printf("fail to configure port %d\n", port_id); - return -1; - } - - ret = rte_eth_rx_queue_setup(port_id, 0, NB_RXD, SOCKET, &rx_conf, mp); - if (ret < 0) { - printf("fail to setup rx queue for port %d\n", port_id); - return -1; - } - - ret = rte_eth_tx_queue_setup(port_id, 0, NB_TXD, SOCKET, &tx_conf); - if (ret < 0) { - printf("fail to setup tx queue for port %d\n", port_id); - return -1; - } - - ret = rte_eth_dev_start(port_id); - if (ret < 0) { - printf("fail to start port %d\n", port_id); - return -1; - } - ret = rte_eth_promiscuous_enable(port_id); - if (ret != 0) { - printf("fail to enable promiscuous mode for port %d: %s\n", - port_id, rte_strerror(-ret)); - return -1; - } - - /* basic test of kni processing */ - fd = fopen(KNI_MODULE_PARAM_LO, "r"); - if (fd == NULL) { - printf("fopen: %s", strerror(errno)); - return -1; - } - memset(&buf, 0, sizeof(buf)); - if (fgets(buf, sizeof(buf), fd)) { - if (!strncmp(buf, "lo_mode_fifo", strlen("lo_mode_fifo")) || - !strncmp(buf, "lo_mode_fifo_skb", - strlen("lo_mode_fifo_skb"))) { - ret = test_kni_processing(port_id, mp); - if (ret < 0) { - fclose(fd); - goto fail; - } - } else - printf("test_kni_processing skipped because of missing rte_kni module lo_mode argument\n"); - } - fclose(fd); - - /* test of allocating KNI with NULL mempool pointer */ - memset(&info, 0, sizeof(info)); - memset(&conf, 0, sizeof(conf)); - memset(&ops, 0, sizeof(ops)); - - ret = rte_eth_dev_info_get(port_id, &info); - if (ret != 0) { - printf("Error during getting device (port %u) info: %s\n", - port_id, strerror(-ret)); - return -1; - } - - conf.group_id = port_id; - conf.mbuf_size = MAX_PACKET_SZ; - - ops = kni_ops; - ops.port_id = port_id; - kni = rte_kni_alloc(NULL, &conf, &ops); - if (kni) { - ret = -1; - printf("unexpectedly creates kni successfully with NULL " - "mempool pointer\n"); - goto fail; - } - - /* test of allocating KNI without configurations */ - kni = rte_kni_alloc(mp, NULL, NULL); - if (kni) { - ret = -1; - printf("Unexpectedly allocate KNI device successfully " - "without configurations\n"); - goto fail; - } - - /* test of allocating KNI without a name */ - memset(&conf, 0, sizeof(conf)); - memset(&info, 0, sizeof(info)); - memset(&ops, 0, sizeof(ops)); - - ret = rte_eth_dev_info_get(port_id, &info); - if (ret != 0) { - printf("Error during getting device (port %u) info: %s\n", - port_id, strerror(-ret)); - ret = -1; - goto fail; - } - - conf.group_id = port_id; - conf.mbuf_size = MAX_PACKET_SZ; - - ops = kni_ops; - ops.port_id = port_id; - kni = rte_kni_alloc(mp, &conf, &ops); - if (kni) { - ret = -1; - printf("Unexpectedly allocate a KNI device successfully " - "without a name\n"); - goto fail; - } - - /* test of releasing NULL kni context */ - ret = rte_kni_release(NULL); - if (ret == 0) { - ret = -1; - printf("unexpectedly release kni successfully\n"); - goto fail; - } - - /* test of handling request on NULL device pointer */ - ret = rte_kni_handle_request(NULL); - if (ret == 0) { - ret = -1; - printf("Unexpectedly handle request on NULL device pointer\n"); - goto fail; - } - - /* test of getting KNI device with pointer to NULL */ - kni = rte_kni_get(NULL); - if (kni) { - ret = -1; - printf("Unexpectedly get a KNI device with " - "NULL name pointer\n"); - goto fail; - } - - /* test of getting KNI device with an zero length name string */ - memset(&conf, 0, sizeof(conf)); - kni = rte_kni_get(conf.name); - if (kni) { - ret = -1; - printf("Unexpectedly get a KNI device with " - "zero length name string\n"); - goto fail; - } - - /* test of getting KNI device with an invalid string name */ - memset(&conf, 0, sizeof(conf)); - snprintf(conf.name, sizeof(conf.name), "testing"); - kni = rte_kni_get(conf.name); - if (kni) { - ret = -1; - printf("Unexpectedly get a KNI device with " - "a never used name string\n"); - goto fail; - } - ret = 0; - -fail: - if (rte_eth_dev_stop(port_id) != 0) - printf("Failed to stop port %u\n", port_id); - - return ret; -} - -#endif - -REGISTER_TEST_COMMAND(kni_autotest, test_kni); diff --git a/dpdk/app/test/test_telemetry.sh b/dpdk/app/test/test_telemetry.sh deleted file mode 100755 index ca6abe266..000000000 --- a/dpdk/app/test/test_telemetry.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2022 Red Hat, Inc. - -which jq || { - echo "No jq available, skipping test." - exit 77 -} - -rootdir=$(readlink -f $(dirname $(readlink -f $0))/../..) -tmpoutput=$(mktemp -t dpdk.test_telemetry.XXXXXX) -trap "cat $tmpoutput; rm -f $tmpoutput" EXIT - -call_all_telemetry() { - telemetry_script=$rootdir/usertools/dpdk-telemetry.py - echo >$tmpoutput - echo "Telemetry commands log:" >>$tmpoutput - for cmd in $(echo / | $telemetry_script | jq -r '.["/"][]') - do - for input in $cmd $cmd,0 $cmd,z - do - echo Calling $input >> $tmpoutput - echo $input | $telemetry_script >> $tmpoutput 2>&1 - done - done -} - -(sleep 1 && call_all_telemetry && echo quit) | $@ diff --git a/dpdk/buildtools/binutils-avx512-check.py b/dpdk/buildtools/binutils-avx512-check.py deleted file mode 100644 index a0847a23d..000000000 --- a/dpdk/buildtools/binutils-avx512-check.py +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/env python3 -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2020 Intel Corporation - -import subprocess -import sys -import tempfile - -objdump, *cc = sys.argv[1:] -with tempfile.NamedTemporaryFile() as obj: - # On Windows, the file is opened exclusively and is not writable. - obj.close() - # from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90028 - gather_params = '0x8(,%ymm1,1),%ymm0{%k2}' - src = '__asm__("vpgatherqq {}");'.format(gather_params).encode('utf-8') - subprocess.run(cc + ['-c', '-xc', '-o', obj.name, '-'], input=src, check=True) - asm = subprocess.run([objdump, '-d', '--no-show-raw-insn', obj.name], - stdout=subprocess.PIPE, check=True).stdout.decode('utf-8') - if gather_params not in asm: - print('vpgatherqq displacement error with as') - sys.exit(1) diff --git a/dpdk/devtools/cocci/func_or_ret.cocci b/dpdk/devtools/cocci/func_or_ret.cocci deleted file mode 100644 index f23d60cc4..000000000 --- a/dpdk/devtools/cocci/func_or_ret.cocci +++ /dev/null @@ -1,12 +0,0 @@ -@@ -expression cond, ret; -@@ --RTE_FUNC_PTR_OR_ERR_RET(cond, ret); -+if (cond == NULL) -+ return ret; -@@ -expression cond; -@@ --RTE_FUNC_PTR_OR_RET(cond); -+if (cond == NULL) -+ return; diff --git a/dpdk/devtools/gen-abi.sh b/dpdk/devtools/gen-abi.sh deleted file mode 100755 index f15a3b9aa..000000000 --- a/dpdk/devtools/gen-abi.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2019 Red Hat, Inc. - -if [ $# != 1 ]; then - echo "Usage: $0 installdir" >&2 - exit 1 -fi - -installdir=$1 -if [ ! -d $installdir ]; then - echo "Error: install directory '$installdir' does not exist." >&2 - exit 1 -fi - -dumpdir=$installdir/dump -rm -rf $dumpdir -mkdir -p $dumpdir -for f in $(find $installdir -name "*.so.*"); do - if test -L $f; then - continue - fi - - libname=$(basename $f) - abidw --out-file $dumpdir/${libname%.so*}.dump $f -done diff --git a/dpdk/doc/guides/bbdevs/acc200.rst b/dpdk/doc/guides/bbdevs/acc200.rst deleted file mode 100644 index 012b3870a..000000000 --- a/dpdk/doc/guides/bbdevs/acc200.rst +++ /dev/null @@ -1,260 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2022 Intel Corporation - -.. include:: - -Intel\ |reg| ACC200 vRAN Dedicated Accelerator Poll Mode Driver -=============================================================== - -The Intel\ |reg| vRAN Dedicated Accelerator ACC200 peripheral enables -cost-effective 4G and 5G next-generation virtualized Radio Access Network (vRAN) -solutions integrated on Sapphire Rapids Edge Enhanced Processor (SPR-EE) -Intel\ |reg| 7 based Xeon\ |reg| multi-core server processor. - - -Features --------- - -The ACC200 includes a 5G Low Density Parity Check (LDPC) encoder/decoder, -rate match/dematch, Hybrid Automatic Repeat Request (HARQ) with access to DDR -memory for buffer management, a 4G Turbo encoder/decoder, -a Fast Fourier Transform (FFT) block providing DFT/iDFT processing offload -for the 5G Sounding Reference Signal (SRS), a Queue Manager (QMGR), -and a DMA subsystem. -There is no dedicated on-card memory for HARQ, -this is using coherent memory on the CPU side. - -These correspond to the following features exposed by the PMD: - -- LDPC Encode in the Downlink (5GNR) -- LDPC Decode in the Uplink (5GNR) -- Turbo Encode in the Downlink (4G) -- Turbo Decode in the Uplink (4G) -- FFT processing -- SR-IOV with 16 VFs per PF -- Maximum of 256 queues per VF -- MSI - -ACC200 PMD supports the following bbdev capabilities: - -* For the LDPC encode operation: - - ``RTE_BBDEV_LDPC_CRC_24B_ATTACH``: set to attach CRC24B to CB(s). - - ``RTE_BBDEV_LDPC_RATE_MATCH``: if set then do not do Rate Match bypass. - - ``RTE_BBDEV_LDPC_INTERLEAVER_BYPASS``: if set then bypass interleaver. - -* For the LDPC decode operation: - - ``RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK``: check CRC24B from CB(s). - - ``RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP``: drops CRC24B bits appended while decoding. - - ``RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK``: check CRC24A from CB(s). - - ``RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK``: check CRC16 from CB(s). - - ``RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE``: provides an input for HARQ combining. - - ``RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE``: provides an input for HARQ combining. - - ``RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE``: disable early termination. - - ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER``: supports scatter-gather for input/output data. - - ``RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION``: supports compression of the HARQ input/output. - - ``RTE_BBDEV_LDPC_LLR_COMPRESSION``: supports LLR input compression. - -* For the turbo encode operation: - - ``RTE_BBDEV_TURBO_CRC_24B_ATTACH``: set to attach CRC24B to CB(s). - - ``RTE_BBDEV_TURBO_RATE_MATCH``: if set then do not do Rate Match bypass. - - ``RTE_BBDEV_TURBO_ENC_INTERRUPTS``: set for encoder dequeue interrupts. - - ``RTE_BBDEV_TURBO_RV_INDEX_BYPASS``: set to bypass RV index. - - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``: supports scatter-gather for input/output data. - -* For the turbo decode operation: - - ``RTE_BBDEV_TURBO_CRC_TYPE_24B``: check CRC24B from CB(s). - - ``RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE``: perform subblock de-interleave. - - ``RTE_BBDEV_TURBO_DEC_INTERRUPTS``: set for decoder dequeue interrupts. - - ``RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN``: set if negative LLR input is supported. - - ``RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP``: keep CRC24B bits appended while decoding. - - ``RTE_BBDEV_TURBO_DEC_CRC_24B_DROP``: option to drop the code block CRC after decoding. - - ``RTE_BBDEV_TURBO_EARLY_TERMINATION``: set early termination feature. - - ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``: supports scatter-gather for input/output data. - - ``RTE_BBDEV_TURBO_HALF_ITERATION_EVEN``: set half iteration granularity. - - ``RTE_BBDEV_TURBO_SOFT_OUTPUT``: set the APP LLR soft output. - - ``RTE_BBDEV_TURBO_EQUALIZER``: set the turbo equalizer feature. - - ``RTE_BBDEV_TURBO_SOFT_OUT_SATURATE``: set the soft output saturation. - - ``RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH``: set to run an extra odd iteration after CRC match. - - ``RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT``: set if negative APP LLR output supported. - - ``RTE_BBDEV_TURBO_MAP_DEC``: supports flexible parallel MAP engine decoding. - -* For the FFT operation: - - ``RTE_BBDEV_FFT_WINDOWING``: flexible windowing capability. - - ``RTE_BBDEV_FFT_CS_ADJUSTMENT``: flexible adjustment of Cyclic Shift time offset. - - ``RTE_BBDEV_FFT_DFT_BYPASS``: set for bypass the DFT and get directly into iDFT input. - - ``RTE_BBDEV_FFT_IDFT_BYPASS``: set for bypass the IDFT and get directly the DFT output. - - ``RTE_BBDEV_FFT_WINDOWING_BYPASS``: set for bypass time domain windowing. - - -Installation ------------- - -Section 3 of the DPDK manual provides instructions on installing and compiling DPDK. - -DPDK requires hugepages to be configured as detailed in section 2 of the DPDK manual. -The bbdev test application has been tested with a configuration 40 x 1GB hugepages. -The hugepage configuration of a server may be examined using: - -.. code-block:: console - - grep Huge* /proc/meminfo - - -Initialization --------------- - -When the device first powers up, its PCI Physical Functions (PF) -can be listed through these commands for ACC200: - -.. code-block:: console - - sudo lspci -vd8086:57c0 - -The physical and virtual functions are compatible with Linux UIO drivers: -``vfio`` and ``igb_uio``. -However, in order to work the 5G/4G FEC device first needs to be bound -to one of these Linux drivers through DPDK. - - -Bind PF UIO driver(s) -~~~~~~~~~~~~~~~~~~~~~ - -Install the DPDK igb_uio driver, bind it with the PF PCI device ID and use -``lspci`` to confirm the PF device is under use by ``igb_uio`` DPDK UIO driver. - -The igb_uio driver may be bound to the PF PCI device using one of two methods -for ACC200: - -#. PCI functions (physical or virtual, depending on the use case) can be bound -to the UIO driver by repeating this command for every function. - -.. code-block:: console - - cd - insmod build/kmod/igb_uio.ko - echo "8086 57c0" > /sys/bus/pci/drivers/igb_uio/new_id - lspci -vd8086:57c0 - -#. Another way to bind PF with DPDK UIO driver is by using the ``dpdk-devbind.py`` tool - -.. code-block:: console - - cd - usertools/dpdk-devbind.py -b igb_uio 0000:f7:00.0 - -where the PCI device ID (example: 0000:f7:00.0) is obtained using ``lspci -vd8086:57c0``. - -In a similar way the PF may be bound with vfio-pci as any PCIe device. - - -Enable Virtual Functions -~~~~~~~~~~~~~~~~~~~~~~~~ - -Now, it should be visible in the printouts that PCI PF is under igb_uio control -"``Kernel driver in use: igb_uio``" - -To show the number of available VFs on the device, read ``sriov_totalvfs`` file. - -.. code-block:: console - - cat /sys/bus/pci/devices/0000\:\:./sriov_totalvfs - -where ``0000\:\:.`` is the PCI device ID - -To enable VFs via igb_uio, echo the number of virtual functions intended -to enable to ``max_vfs`` file. - -.. code-block:: console - - echo > /sys/bus/pci/devices/0000\:\:./max_vfs - -Afterwards, all VFs must be bound to appropriate UIO drivers as required, -same way it was done with the physical function previously. - -Enabling SR-IOV via VFIO driver is pretty much the same, -except that the file name is different: - -.. code-block:: console - - echo > /sys/bus/pci/devices/0000\:\:./sriov_numvfs - - -Configure the VFs through PF -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The PCI virtual functions must be configured before working or getting assigned -to VMs/Containers. -The configuration involves allocating the number of hardware queues, priorities, -load balance, bandwidth and other settings necessary for the device -to perform FEC functions. - -This configuration needs to be executed at least once after reboot or PCI FLR -and can be achieved by using the functions ``rte_acc200_configure()``, -which sets up the parameters defined in the compatible ``acc200_conf`` structure. - - -Test Application ----------------- - -The bbdev class is provided with a test application, ``test-bbdev.py`` -and range of test data for testing the functionality of the device, -depending on the device's capabilities. -The test application is located under app/test-bbdev folder -and has the following options: - -.. code-block:: console - - "-p", "--testapp-path": specifies path to the bbdev test app. - "-e", "--eal-params": EAL arguments which are passed to the test app. - "-t", "--timeout": Timeout in seconds (default=300). - "-c", "--test-cases": Defines test cases to run. Run all if not specified. - "-v", "--test-vector": Test vector path. - "-n", "--num-ops": Number of operations to process on device (default=32). - "-b", "--burst-size": Operations enqueue/dequeue burst size (default=32). - "-s", "--snr": SNR in dB used when generating LLRs for bler tests. - "-s", "--iter_max": Number of iterations for LDPC decoder. - "-l", "--num-lcores": Number of lcores to run (default=16). - "-i", "--init-device": Initialise PF device with default values. - - -To execute the test application tool using simple decode or encode data, -type one of the following: - -.. code-block:: console - - ./test-bbdev.py -c validation -n 64 -b 1 -v ./ldpc_dec_default.data - ./test-bbdev.py -c validation -n 64 -b 1 -v ./ldpc_enc_default.data - - -The test application ``test-bbdev.py``, supports the ability to configure the -PF device with a default set of values, if the "-i" or "- -init-device" option -is included. The default values are defined in test_bbdev_perf.c. - - -Test Vectors -~~~~~~~~~~~~ - -In addition to the simple LDPC decoder and LDPC encoder tests, -bbdev also provides a range of additional tests under the test_vectors folder, -which may be useful. -The results of these tests will depend on the device capabilities which may -cause some test cases to be skipped, but no failure should be reported. - - -Alternate Baseband Device configuration tool -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -On top of the embedded configuration feature supported in test-bbdev using -"- -init-device" option mentioned above, there is also a tool available -to perform that device configuration using a companion application. -The ``pf_bb_config`` application notably enables then to run bbdev-test -from the VF and not only limited to the PF as captured above. - -See for more details: https://github.com/intel/pf-bb-config - -Specifically for the bbdev ACC200 PMD, the command below can be used: - -.. code-block:: console - - pf_bb_config ACC200 -c ./acc200/acc200_config_vf_5g.cfg - test-bbdev.py -e="-c 0xff0 -a${VF_PCI_ADDR}" -c validation -n 64 -b 64 -l 1 -v ./ldpc_dec_default.data diff --git a/dpdk/doc/guides/bbdevs/features/acc200.ini b/dpdk/doc/guides/bbdevs/features/acc200.ini deleted file mode 100644 index 7319aea72..000000000 --- a/dpdk/doc/guides/bbdevs/features/acc200.ini +++ /dev/null @@ -1,14 +0,0 @@ -; -; Supported features of the 'acc200' bbdev driver. -; -; Refer to default.ini for the full list of available PMD features. -; -[Features] -Turbo Decoder (4G) = Y -Turbo Encoder (4G) = Y -LDPC Decoder (5G) = Y -LDPC Encoder (5G) = Y -LLR/HARQ Compression = Y -FFT/SRS = Y -External DDR Access = N -HW Accelerated = Y diff --git a/dpdk/doc/guides/nics/features/liquidio.ini b/dpdk/doc/guides/nics/features/liquidio.ini deleted file mode 100644 index a8bde282e..000000000 --- a/dpdk/doc/guides/nics/features/liquidio.ini +++ /dev/null @@ -1,29 +0,0 @@ -; -; Supported features of the 'LiquidIO' network poll mode driver. -; -; Refer to default.ini for the full list of available PMD features. -; -[Features] -Speed capabilities = Y -Link status = Y -Link status event = Y -MTU update = Y -Scattered Rx = Y -Promiscuous mode = Y -Allmulticast mode = Y -RSS hash = Y -RSS key update = Y -RSS reta update = Y -VLAN filter = Y -CRC offload = Y -VLAN offload = P -L3 checksum offload = Y -L4 checksum offload = Y -Inner L3 checksum = Y -Inner L4 checksum = Y -Basic stats = Y -Extended stats = Y -Multiprocess aware = Y -Linux = Y -x86-64 = Y -Usage doc = Y diff --git a/dpdk/doc/guides/nics/kni.rst b/dpdk/doc/guides/nics/kni.rst deleted file mode 100644 index 2a23bb3f3..000000000 --- a/dpdk/doc/guides/nics/kni.rst +++ /dev/null @@ -1,170 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2017 Intel Corporation. - -KNI Poll Mode Driver -====================== - -KNI PMD is wrapper to the :ref:`librte_kni ` library. - -This PMD enables using KNI without having a KNI specific application, -any forwarding application can use PMD interface for KNI. - -Sending packets to any DPDK controlled interface or sending to the -Linux networking stack will be transparent to the DPDK application. - -To create a KNI device ``net_kni#`` device name should be used, and this -will create ``kni#`` Linux virtual network interface. - -There is no physical device backend for the virtual KNI device. - -Packets sent to the KNI Linux interface will be received by the DPDK -application, and DPDK application may forward packets to a physical NIC -or to a virtual device (like another KNI interface or PCAP interface). - -To forward any traffic from physical NIC to the Linux networking stack, -an application should control a physical port and create one virtual KNI port, -and forward between two. - -Using this PMD requires KNI kernel module be inserted. - - -Usage ------ - -EAL ``--vdev`` argument can be used to create KNI device instance, like:: - - dpdk-testpmd --vdev=net_kni0 --vdev=net_kni1 -- -i - -Above command will create ``kni0`` and ``kni1`` Linux network interfaces, -those interfaces can be controlled by standard Linux tools. - -When testpmd forwarding starts, any packets sent to ``kni0`` interface -forwarded to the ``kni1`` interface and vice versa. - -There is no hard limit on number of interfaces that can be created. - - -Default interface configuration -------------------------------- - -``librte_kni`` can create Linux network interfaces with different features, -feature set controlled by a configuration struct, and KNI PMD uses a fixed -configuration: - - .. code-block:: console - - Interface name: kni# - force bind kernel thread to a core : NO - mbuf size: (rte_pktmbuf_data_room_size(pktmbuf_pool) - RTE_PKTMBUF_HEADROOM) - mtu: (conf.mbuf_size - RTE_ETHER_HDR_LEN) - -KNI control path is not supported with the PMD, since there is no physical -backend device by default. - - -PMD arguments -------------- - -``no_request_thread``, by default PMD creates a pthread for each KNI interface -to handle Linux network interface control commands, like ``ifconfig kni0 up`` - -With ``no_request_thread`` option, pthread is not created and control commands -not handled by PMD. - -By default request thread is enabled. And this argument should not be used -most of the time, unless this PMD used with customized DPDK application to handle -requests itself. - -Argument usage:: - - dpdk-testpmd --vdev "net_kni0,no_request_thread=1" -- -i - - -PMD log messages ----------------- - -If KNI kernel module (rte_kni.ko) not inserted, following error log printed:: - - "KNI: KNI subsystem has not been initialized. Invoke rte_kni_init() first" - - -PMD testing ------------ - -It is possible to test PMD quickly using KNI kernel module loopback feature: - -* Insert KNI kernel module with loopback support: - - .. code-block:: console - - insmod /kernel/linux/kni/rte_kni.ko lo_mode=lo_mode_fifo_skb - -* Start testpmd with no physical device but two KNI virtual devices: - - .. code-block:: console - - ./dpdk-testpmd --vdev net_kni0 --vdev net_kni1 -- -i - - .. code-block:: console - - ... - Configuring Port 0 (socket 0) - KNI: pci: 00:00:00 c580:b8 - Port 0: 1A:4A:5B:7C:A2:8C - Configuring Port 1 (socket 0) - KNI: pci: 00:00:00 600:b9 - Port 1: AE:95:21:07:93:DD - Checking link statuses... - Port 0 Link Up - speed 10000 Mbps - full-duplex - Port 1 Link Up - speed 10000 Mbps - full-duplex - Done - testpmd> - -* Observe Linux interfaces - - .. code-block:: console - - $ ifconfig kni0 && ifconfig kni1 - kni0: flags=4098 mtu 1500 - ether ae:8e:79:8e:9b:c8 txqueuelen 1000 (Ethernet) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - - kni1: flags=4098 mtu 1500 - ether 9e:76:43:53:3e:9b txqueuelen 1000 (Ethernet) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - - -* Start forwarding with tx_first: - - .. code-block:: console - - testpmd> start tx_first - -* Quit and check forwarding stats: - - .. code-block:: console - - testpmd> quit - Telling cores to stop... - Waiting for lcores to finish... - - ---------------------- Forward statistics for port 0 ---------------------- - RX-packets: 35637905 RX-dropped: 0 RX-total: 35637905 - TX-packets: 35637947 TX-dropped: 0 TX-total: 35637947 - ---------------------------------------------------------------------------- - - ---------------------- Forward statistics for port 1 ---------------------- - RX-packets: 35637915 RX-dropped: 0 RX-total: 35637915 - TX-packets: 35637937 TX-dropped: 0 TX-total: 35637937 - ---------------------------------------------------------------------------- - - +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++ - RX-packets: 71275820 RX-dropped: 0 RX-total: 71275820 - TX-packets: 71275884 TX-dropped: 0 TX-total: 71275884 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/dpdk/doc/guides/nics/liquidio.rst b/dpdk/doc/guides/nics/liquidio.rst deleted file mode 100644 index f893b3b53..000000000 --- a/dpdk/doc/guides/nics/liquidio.rst +++ /dev/null @@ -1,169 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2017 Cavium, Inc - -LiquidIO VF Poll Mode Driver -============================ - -The LiquidIO VF PMD library (**librte_net_liquidio**) provides poll mode driver support for -Cavium LiquidIO® II server adapter VFs. PF management and VF creation can be -done using kernel driver. - -More information can be found at `Cavium Official Website -`_. - -Supported LiquidIO Adapters ------------------------------ - -- LiquidIO II CN2350 210SV/225SV -- LiquidIO II CN2350 210SVPT -- LiquidIO II CN2360 210SV/225SV -- LiquidIO II CN2360 210SVPT - - -SR-IOV: Prerequisites and Sample Application Notes --------------------------------------------------- - -This section provides instructions to configure SR-IOV with Linux OS. - -#. Verify SR-IOV and ARI capabilities are enabled on the adapter using ``lspci``: - - .. code-block:: console - - lspci -s -vvv - - Example output: - - .. code-block:: console - - [...] - Capabilities: [148 v1] Alternative Routing-ID Interpretation (ARI) - [...] - Capabilities: [178 v1] Single Root I/O Virtualization (SR-IOV) - [...] - Kernel driver in use: LiquidIO - -#. Load the kernel module: - - .. code-block:: console - - modprobe liquidio - -#. Bring up the PF ports: - - .. code-block:: console - - ifconfig p4p1 up - ifconfig p4p2 up - -#. Change PF MTU if required: - - .. code-block:: console - - ifconfig p4p1 mtu 9000 - ifconfig p4p2 mtu 9000 - -#. Create VF device(s): - - Echo number of VFs to be created into ``"sriov_numvfs"`` sysfs entry - of the parent PF. - - .. code-block:: console - - echo 1 > /sys/bus/pci/devices/0000:03:00.0/sriov_numvfs - echo 1 > /sys/bus/pci/devices/0000:03:00.1/sriov_numvfs - -#. Assign VF MAC address: - - Assign MAC address to the VF using iproute2 utility. The syntax is:: - - ip link set vf mac - - Example output: - - .. code-block:: console - - ip link set p4p1 vf 0 mac F2:A8:1B:5E:B4:66 - -#. Assign VF(s) to VM. - - The VF devices may be passed through to the guest VM using qemu or - virt-manager or virsh etc. - - Example qemu guest launch command: - - .. code-block:: console - - ./qemu-system-x86_64 -name lio-vm -machine accel=kvm \ - -cpu host -m 4096 -smp 4 \ - -drive file=,if=none,id=disk1,format= \ - -device virtio-blk-pci,scsi=off,drive=disk1,id=virtio-disk1,bootindex=1 \ - -device vfio-pci,host=03:00.3 -device vfio-pci,host=03:08.3 - -#. Running testpmd - - Refer to the document - :ref:`compiling and testing a PMD for a NIC ` to run - ``testpmd`` application. - - .. note:: - - Use ``igb_uio`` instead of ``vfio-pci`` in VM. - - Example output: - - .. code-block:: console - - [...] - EAL: PCI device 0000:03:00.3 on NUMA socket 0 - EAL: probe driver: 177d:9712 net_liovf - EAL: using IOMMU type 1 (Type 1) - PMD: net_liovf[03:00.3]INFO: DEVICE : CN23XX VF - EAL: PCI device 0000:03:08.3 on NUMA socket 0 - EAL: probe driver: 177d:9712 net_liovf - PMD: net_liovf[03:08.3]INFO: DEVICE : CN23XX VF - Interactive-mode selected - USER1: create a new mbuf pool : n=171456, size=2176, socket=0 - Configuring Port 0 (socket 0) - PMD: net_liovf[03:00.3]INFO: Starting port 0 - Port 0: F2:A8:1B:5E:B4:66 - Configuring Port 1 (socket 0) - PMD: net_liovf[03:08.3]INFO: Starting port 1 - Port 1: 32:76:CC:EE:56:D7 - Checking link statuses... - Port 0 Link Up - speed 10000 Mbps - full-duplex - Port 1 Link Up - speed 10000 Mbps - full-duplex - Done - testpmd> - -#. Enabling VF promiscuous mode - - One VF per PF can be marked as trusted for promiscuous mode. - - .. code-block:: console - - ip link set dev vf trust on - - -Limitations ------------ - -VF MTU -~~~~~~ - -VF MTU is limited by PF MTU. Raise PF value before configuring VF for larger packet size. - -VLAN offload -~~~~~~~~~~~~ - -Tx VLAN insertion is not supported and consequently VLAN offload feature is -marked partial. - -Ring size -~~~~~~~~~ - -Number of descriptors for Rx/Tx ring should be in the range 128 to 512. - -CRC stripping -~~~~~~~~~~~~~ - -LiquidIO adapters strip ethernet FCS of every packet coming to the host interface. diff --git a/dpdk/doc/guides/prog_guide/flow_classify_lib.rst b/dpdk/doc/guides/prog_guide/flow_classify_lib.rst deleted file mode 100644 index ad2e10ec2..000000000 --- a/dpdk/doc/guides/prog_guide/flow_classify_lib.rst +++ /dev/null @@ -1,424 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2017 Intel Corporation. - -Flow Classification Library -=========================== - -.. note:: - - The Flow Classification library is deprecated and will be removed in future. - See :doc:`../rel_notes/deprecation`. - - It is disabled by default in the DPDK build. - To re-enable the library, remove 'flow_classify' from the "disable_libs" - meson option when configuring a build. - -DPDK provides a Flow Classification library that provides the ability -to classify an input packet by matching it against a set of Flow rules. - -The initial implementation supports counting of IPv4 5-tuple packets which match -a particular Flow rule only. - -Please refer to the -:doc:`./rte_flow` -for more information. - -The Flow Classification library uses the ``librte_table`` API for managing Flow -rules and matching packets against the Flow rules. -The library is table agnostic and can use the following tables: -``Access Control List``, ``Hash`` and ``Longest Prefix Match(LPM)``. -The ``Access Control List`` table is used in the initial implementation. - -Please refer to the -:doc:`./packet_framework` -for more information.on ``librte_table``. - -DPDK provides an Access Control List library that provides the ability to -classify an input packet based on a set of classification rules. - -Please refer to the -:doc:`./packet_classif_access_ctrl` -library for more information on ``librte_acl``. - -There is also a Flow Classify sample application which demonstrates the use of -the Flow Classification Library API's. - -Please refer to the -:doc:`../sample_app_ug/flow_classify` -for more information on the ``flow_classify`` sample application. - -Overview --------- - -The library has the following API's - -.. code-block:: c - - /** - * Flow classifier create - * - * @param params - * Parameters for flow classifier creation - * @return - * Handle to flow classifier instance on success or NULL otherwise - */ - struct rte_flow_classifier * - rte_flow_classifier_create(struct rte_flow_classifier_params *params); - - /** - * Flow classifier free - * - * @param cls - * Handle to flow classifier instance - * @return - * 0 on success, error code otherwise - */ - int - rte_flow_classifier_free(struct rte_flow_classifier *cls); - - /** - * Flow classify table create - * - * @param cls - * Handle to flow classifier instance - * @param params - * Parameters for flow_classify table creation - * @return - * 0 on success, error code otherwise - */ - int - rte_flow_classify_table_create(struct rte_flow_classifier *cls, - struct rte_flow_classify_table_params *params); - - /** - * Validate the flow classify rule - * - * @param[in] cls - * Handle to flow classifier instance - * @param[in] attr - * Flow rule attributes - * @param[in] pattern - * Pattern specification (list terminated by the END pattern item). - * @param[in] actions - * Associated actions (list terminated by the END pattern item). - * @param[out] error - * Perform verbose error reporting if not NULL. Structure - * initialised in case of error only. - * @return - * 0 on success, error code otherwise - */ - int - rte_flow_classify_validate(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_flow_error *error); - - /** - * Add a flow classify rule to the flow_classifier table. - * - * @param[in] cls - * Flow classifier handle - * @param[in] attr - * Flow rule attributes - * @param[in] pattern - * Pattern specification (list terminated by the END pattern item). - * @param[in] actions - * Associated actions (list terminated by the END pattern item). - * @param[out] key_found - * returns 1 if rule present already, 0 otherwise. - * @param[out] error - * Perform verbose error reporting if not NULL. Structure - * initialised in case of error only. - * @return - * A valid handle in case of success, NULL otherwise. - */ - struct rte_flow_classify_rule * - rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - int *key_found; - struct rte_flow_error *error); - - /** - * Delete a flow classify rule from the flow_classifier table. - * - * @param[in] cls - * Flow classifier handle - * @param[in] rule - * Flow classify rule - * @return - * 0 on success, error code otherwise. - */ - int - rte_flow_classify_table_entry_delete(struct rte_flow_classifier *cls, - struct rte_flow_classify_rule *rule); - - /** - * Query flow classifier for given rule. - * - * @param[in] cls - * Flow classifier handle - * @param[in] pkts - * Pointer to packets to process - * @param[in] nb_pkts - * Number of packets to process - * @param[in] rule - * Flow classify rule - * @param[in] stats - * Flow classify stats - * - * @return - * 0 on success, error code otherwise. - */ - int - rte_flow_classifier_query(struct rte_flow_classifier *cls, - struct rte_mbuf **pkts, - const uint16_t nb_pkts, - struct rte_flow_classify_rule *rule, - struct rte_flow_classify_stats *stats); - -Classifier creation -~~~~~~~~~~~~~~~~~~~ - -The application creates the ``Classifier`` using the -``rte_flow_classifier_create`` API. -The ``rte_flow_classify_params`` structure must be initialised by the -application before calling the API. - -.. code-block:: c - - struct rte_flow_classifier_params { - /** flow classifier name */ - const char *name; - - /** CPU socket ID where memory for the flow classifier and its */ - /** elements (tables) should be allocated */ - int socket_id; - }; - -The ``Classifier`` has the following internal structures: - -.. code-block:: c - - struct rte_cls_table { - /* Input parameters */ - struct rte_table_ops ops; - uint32_t entry_size; - enum rte_flow_classify_table_type type; - - /* Handle to the low-level table object */ - void *h_table; - }; - - #define RTE_FLOW_CLASSIFIER_MAX_NAME_SZ 256 - - struct rte_flow_classifier { - /* Input parameters */ - char name[RTE_FLOW_CLASSIFIER_MAX_NAME_SZ]; - int socket_id; - - /* Internal */ - /* ntuple_filter */ - struct rte_eth_ntuple_filter ntuple_filter; - - /* classifier tables */ - struct rte_cls_table tables[RTE_FLOW_CLASSIFY_TABLE_MAX]; - uint32_t table_mask; - uint32_t num_tables; - - uint16_t nb_pkts; - struct rte_flow_classify_table_entry - *entries[RTE_PORT_IN_BURST_SIZE_MAX]; - } __rte_cache_aligned; - -Adding a table to the Classifier -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The application adds a table to the ``Classifier`` using the -``rte_flow_classify_table_create`` API. -The ``rte_flow_classify_table_params`` structure must be initialised by the -application before calling the API. - -.. code-block:: c - - struct rte_flow_classify_table_params { - /** Table operations (specific to each table type) */ - struct rte_table_ops *ops; - - /** Opaque param to be passed to the table create operation */ - void *arg_create; - - /** Classifier table type */ - enum rte_flow_classify_table_type type; - }; - -To create an ACL table the ``rte_table_acl_params`` structure must be -initialised and assigned to ``arg_create`` in the -``rte_flow_classify_table_params`` structure. - -.. code-block:: c - - struct rte_table_acl_params { - /** Name */ - const char *name; - - /** Maximum number of ACL rules in the table */ - uint32_t n_rules; - - /** Number of fields in the ACL rule specification */ - uint32_t n_rule_fields; - - /** Format specification of the fields of the ACL rule */ - struct rte_acl_field_def field_format[RTE_ACL_MAX_FIELDS]; - }; - -The fields for the ACL rule must also be initialised by the application. - -An ACL table can be added to the ``Classifier`` for each ACL rule, for example -another table could be added for the IPv6 5-tuple rule. - -Flow Parsing -~~~~~~~~~~~~ - -The library currently supports three IPv4 5-tuple flow patterns, for UDP, TCP -and SCTP. - -.. code-block:: c - - /* Pattern for IPv4 5-tuple UDP filter */ - static enum rte_flow_item_type pattern_ntuple_1[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_UDP, - RTE_FLOW_ITEM_TYPE_END, - }; - - /* Pattern for IPv4 5-tuple TCP filter */ - static enum rte_flow_item_type pattern_ntuple_2[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_TCP, - RTE_FLOW_ITEM_TYPE_END, - }; - - /* Pattern for IPv4 5-tuple SCTP filter */ - static enum rte_flow_item_type pattern_ntuple_3[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_SCTP, - RTE_FLOW_ITEM_TYPE_END, - }; - -The API function ``rte_flow_classify_validate`` parses the -IPv4 5-tuple pattern, attributes and actions and returns the 5-tuple data in the -``rte_eth_ntuple_filter`` structure. - -.. code-block:: c - - static int - rte_flow_classify_validate(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_flow_error *error) - -Adding Flow Rules -~~~~~~~~~~~~~~~~~ - -The ``rte_flow_classify_table_entry_add`` API creates an -``rte_flow_classify`` object which contains the flow_classify id and type, the -action, a union of add and delete keys and a union of rules. -It uses the ``rte_flow_classify_validate`` API function for parsing the -flow parameters. -The 5-tuple ACL key data is obtained from the ``rte_eth_ntuple_filter`` -structure populated by the ``classify_parse_ntuple_filter`` function which -parses the Flow rule. - -.. code-block:: c - - struct acl_keys { - struct rte_table_acl_rule_add_params key_add; /* add key */ - struct rte_table_acl_rule_delete_params key_del; /* delete key */ - }; - - struct classify_rules { - enum rte_flow_classify_rule_type type; - union { - struct rte_flow_classify_ipv4_5tuple ipv4_5tuple; - } u; - }; - - struct rte_flow_classify { - uint32_t id; /* unique ID of classify object */ - enum rte_flow_classify_table_type tbl_type; /* rule table */ - struct classify_rules rules; /* union of rules */ - union { - struct acl_keys key; - } u; - int key_found; /* rule key found in table */ - struct rte_flow_classify_table_entry entry; /* rule meta data */ - void *entry_ptr; /* handle to the table entry for rule meta data */ - }; - -It then calls the ``table.ops.f_add`` API to add the rule to the ACL -table. - -Deleting Flow Rules -~~~~~~~~~~~~~~~~~~~ - -The ``rte_flow_classify_table_entry_delete`` API calls the -``table.ops.f_delete`` API to delete a rule from the ACL table. - -Packet Matching -~~~~~~~~~~~~~~~ - -The ``rte_flow_classifier_query`` API is used to find packets which match a -given flow rule in the table. -This API calls the flow_classify_run internal function which calls the -``table.ops.f_lookup`` API to see if any packets in a burst match any -of the Flow rules in the table. -The meta data for the highest priority rule matched for each packet is returned -in the entries array in the ``rte_flow_classify`` object. -The internal function ``action_apply`` implements the ``Count`` action which is -used to return data which matches a particular Flow rule. - -The rte_flow_classifier_query API uses the following structures to return data -to the application. - -.. code-block:: c - - /** IPv4 5-tuple data */ - struct rte_flow_classify_ipv4_5tuple { - uint32_t dst_ip; /**< Destination IP address in big endian. */ - uint32_t dst_ip_mask; /**< Mask of destination IP address. */ - uint32_t src_ip; /**< Source IP address in big endian. */ - uint32_t src_ip_mask; /**< Mask of destination IP address. */ - uint16_t dst_port; /**< Destination port in big endian. */ - uint16_t dst_port_mask; /**< Mask of destination port. */ - uint16_t src_port; /**< Source Port in big endian. */ - uint16_t src_port_mask; /**< Mask of source port. */ - uint8_t proto; /**< L4 protocol. */ - uint8_t proto_mask; /**< Mask of L4 protocol. */ - }; - - /** - * Flow stats - * - * For the count action, stats can be returned by the query API. - * - * Storage for stats is provided by the application. - * - * - */ - struct rte_flow_classify_stats { - void *stats; - }; - - struct rte_flow_classify_5tuple_stats { - /** count of packets that match IPv4 5tuple pattern */ - uint64_t counter1; - /** IPv4 5tuple data */ - struct rte_flow_classify_ipv4_5tuple ipv4_5tuple; - }; diff --git a/dpdk/doc/guides/prog_guide/kernel_nic_interface.rst b/dpdk/doc/guides/prog_guide/kernel_nic_interface.rst deleted file mode 100644 index 392e5df75..000000000 --- a/dpdk/doc/guides/prog_guide/kernel_nic_interface.rst +++ /dev/null @@ -1,423 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2010-2015 Intel Corporation. - -.. _kni: - -Kernel NIC Interface -==================== - -.. note:: - - KNI is deprecated and will be removed in future. - See :doc:`../rel_notes/deprecation`. - - :ref:`virtio_user_as_exception_path` alternative is the preferred way - for interfacing with the Linux network stack - as it is an in-kernel solution and has similar performance expectations. - -.. note:: - - KNI is disabled by default in the DPDK build. - To re-enable the library, remove 'kni' from the "disable_libs" meson option when configuring a build. - -The DPDK Kernel NIC Interface (KNI) allows userspace applications access to the Linux* control plane. - -KNI provides an interface with the kernel network stack -and allows management of DPDK ports using standard Linux net tools -such as ``ethtool``, ``iproute2`` and ``tcpdump``. - -The main use case of KNI is to get/receive exception packets from/to Linux network stack -while main datapath IO is done bypassing the networking stack. - -There are other alternatives to KNI, all are available in the upstream Linux: - -#. :ref:`virtio_user_as_exception_path` - -#. :doc:`../nics/tap` as wrapper to `Linux tun/tap - `_ - -The benefits of using the KNI against alternatives are: - -* Faster than existing Linux TUN/TAP interfaces - (by eliminating system calls and copy_to_user()/copy_from_user() operations. - -The disadvantages of the KNI are: - -* It is out-of-tree Linux kernel module - which makes updating and distributing the driver more difficult. - Most users end up building the KNI driver from source - which requires the packages and tools to build kernel modules. - -* As it shares memory between userspace and kernelspace, - and kernel part directly uses input provided by userspace, it is not safe. - This makes hard to upstream the module. - -* Requires dedicated kernel cores. - -* Only a subset of net devices control commands are supported by KNI. - -The components of an application using the DPDK Kernel NIC Interface are shown in :numref:`figure_kernel_nic_intf`. - -.. _figure_kernel_nic_intf: - -.. figure:: img/kernel_nic_intf.* - - Components of a DPDK KNI Application - - -The DPDK KNI Kernel Module --------------------------- - -The KNI kernel loadable module ``rte_kni`` provides the kernel interface -for DPDK applications. - -When the ``rte_kni`` module is loaded, it will create a device ``/dev/kni`` -that is used by the DPDK KNI API functions to control and communicate with -the kernel module. - -The ``rte_kni`` kernel module contains several optional parameters which -can be specified when the module is loaded to control its behavior: - -.. code-block:: console - - # modinfo rte_kni.ko - - parm: lo_mode: KNI loopback mode (default=lo_mode_none): - lo_mode_none Kernel loopback disabled - lo_mode_fifo Enable kernel loopback with fifo - lo_mode_fifo_skb Enable kernel loopback with fifo and skb buffer - (charp) - parm: kthread_mode: Kernel thread mode (default=single): - single Single kernel thread mode enabled. - multiple Multiple kernel thread mode enabled. - (charp) - parm: carrier: Default carrier state for KNI interface (default=off): - off Interfaces will be created with carrier state set to off. - on Interfaces will be created with carrier state set to on. - (charp) - parm: enable_bifurcated: Enable request processing support for - bifurcated drivers, which means releasing rtnl_lock before calling - userspace callback and supporting async requests (default=off): - on Enable request processing support for bifurcated drivers. - (charp) - parm: min_scheduling_interval: KNI thread min scheduling interval (default=100 microseconds) - (long) - parm: max_scheduling_interval: KNI thread max scheduling interval (default=200 microseconds) - (long) - - -Loading the ``rte_kni`` kernel module without any optional parameters is -the typical way a DPDK application gets packets into and out of the kernel -network stack. Without any parameters, only one kernel thread is created -for all KNI devices for packet receiving in kernel side, loopback mode is -disabled, and the default carrier state of KNI interfaces is set to *off*. - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko - -.. _kni_loopback_mode: - -Loopback Mode -~~~~~~~~~~~~~ - -For testing, the ``rte_kni`` kernel module can be loaded in loopback mode -by specifying the ``lo_mode`` parameter: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko lo_mode=lo_mode_fifo - -The ``lo_mode_fifo`` loopback option will loop back ring enqueue/dequeue -operations in kernel space. - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko lo_mode=lo_mode_fifo_skb - -The ``lo_mode_fifo_skb`` loopback option will loop back ring enqueue/dequeue -operations and sk buffer copies in kernel space. - -If the ``lo_mode`` parameter is not specified, loopback mode is disabled. - -.. _kni_kernel_thread_mode: - -Kernel Thread Mode -~~~~~~~~~~~~~~~~~~ - -To provide flexibility of performance, the ``rte_kni`` KNI kernel module -can be loaded with the ``kthread_mode`` parameter. The ``rte_kni`` kernel -module supports two options: "single kernel thread" mode and "multiple -kernel thread" mode. - -Single kernel thread mode is enabled as follows: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko kthread_mode=single - -This mode will create only one kernel thread for all KNI interfaces to -receive data on the kernel side. By default, this kernel thread is not -bound to any particular core, but the user can set the core affinity for -this kernel thread by setting the ``core_id`` and ``force_bind`` parameters -in ``struct rte_kni_conf`` when the first KNI interface is created: - -For optimum performance, the kernel thread should be bound to a core in -on the same socket as the DPDK lcores used in the application. - -The KNI kernel module can also be configured to start a separate kernel -thread for each KNI interface created by the DPDK application. Multiple -kernel thread mode is enabled as follows: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko kthread_mode=multiple - -This mode will create a separate kernel thread for each KNI interface to -receive data on the kernel side. The core affinity of each ``kni_thread`` -kernel thread can be specified by setting the ``core_id`` and ``force_bind`` -parameters in ``struct rte_kni_conf`` when each KNI interface is created. - -Multiple kernel thread mode can provide scalable higher performance if -sufficient unused cores are available on the host system. - -If the ``kthread_mode`` parameter is not specified, the "single kernel -thread" mode is used. - -.. _kni_default_carrier_state: - -Default Carrier State -~~~~~~~~~~~~~~~~~~~~~ - -The default carrier state of KNI interfaces created by the ``rte_kni`` -kernel module is controlled via the ``carrier`` option when the module -is loaded. - -If ``carrier=off`` is specified, the kernel module will leave the carrier -state of the interface *down* when the interface is management enabled. -The DPDK application can set the carrier state of the KNI interface using the -``rte_kni_update_link()`` function. This is useful for DPDK applications -which require that the carrier state of the KNI interface reflect the -actual link state of the corresponding physical NIC port. - -If ``carrier=on`` is specified, the kernel module will automatically set -the carrier state of the interface to *up* when the interface is management -enabled. This is useful for DPDK applications which use the KNI interface as -a purely virtual interface that does not correspond to any physical hardware -and do not wish to explicitly set the carrier state of the interface with -``rte_kni_update_link()``. It is also useful for testing in loopback mode -where the NIC port may not be physically connected to anything. - -To set the default carrier state to *on*: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko carrier=on - -To set the default carrier state to *off*: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko carrier=off - -If the ``carrier`` parameter is not specified, the default carrier state -of KNI interfaces will be set to *off*. - -.. _kni_bifurcated_device_support: - -Bifurcated Device Support -~~~~~~~~~~~~~~~~~~~~~~~~~ - -User callbacks are executed while kernel module holds the ``rtnl`` lock, this -causes a deadlock when callbacks run control commands on another Linux kernel -network interface. - -Bifurcated devices has kernel network driver part and to prevent deadlock for -them ``enable_bifurcated`` is used. - -To enable bifurcated device support: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko enable_bifurcated=on - -Enabling bifurcated device support releases ``rtnl`` lock before calling -callback and locks it back after callback. Also enables asynchronous request to -support callbacks that requires rtnl lock to work (interface down). - -KNI Kthread Scheduling -~~~~~~~~~~~~~~~~~~~~~~ - -The ``min_scheduling_interval`` and ``max_scheduling_interval`` parameters -control the rescheduling interval of the KNI kthreads. - -This might be useful if we have use cases in which we require improved -latency or performance for control plane traffic. - -The implementation is backed by Linux High Precision Timers, and uses ``usleep_range``. -Hence, it will have the same granularity constraints as this Linux subsystem. - -For Linux High Precision Timers, you can check the following resource: `Kernel Timers `_ - -To set the ``min_scheduling_interval`` to a value of 100 microseconds: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko min_scheduling_interval=100 - -To set the ``max_scheduling_interval`` to a value of 200 microseconds: - -.. code-block:: console - - # insmod /kernel/linux/kni/rte_kni.ko max_scheduling_interval=200 - -If the ``min_scheduling_interval`` and ``max_scheduling_interval`` parameters are -not specified, the default interval limits will be set to *100* and *200* respectively. - -KNI Creation and Deletion -------------------------- - -Before any KNI interfaces can be created, the ``rte_kni`` kernel module must -be loaded into the kernel and configured with the ``rte_kni_init()`` function. - -The KNI interfaces are created by a DPDK application dynamically via the -``rte_kni_alloc()`` function. - -The ``struct rte_kni_conf`` structure contains fields which allow the -user to specify the interface name, set the MTU size, set an explicit or -random MAC address and control the affinity of the kernel Rx thread(s) -(both single and multi-threaded modes). -By default the KNI sample example gets the MTU from the matching device, -and in case of KNI PMD it is derived from mbuf buffer length. - -The ``struct rte_kni_ops`` structure contains pointers to functions to -handle requests from the ``rte_kni`` kernel module. These functions -allow DPDK applications to perform actions when the KNI interfaces are -manipulated by control commands or functions external to the application. - -For example, the DPDK application may wish to enabled/disable a physical -NIC port when a user enabled/disables a KNI interface with ``ip link set -[up|down] dev ``. The DPDK application can register a callback for -``config_network_if`` which will be called when the interface management -state changes. - -There are currently four callbacks for which the user can register -application functions: - -``config_network_if``: - - Called when the management state of the KNI interface changes. - For example, when the user runs ``ip link set [up|down] dev ``. - -``change_mtu``: - - Called when the user changes the MTU size of the KNI - interface. For example, when the user runs ``ip link set mtu - dev ``. - -``config_mac_address``: - - Called when the user changes the MAC address of the KNI interface. - For example, when the user runs ``ip link set address - dev ``. If the user sets this callback function to NULL, - but sets the ``port_id`` field to a value other than -1, a default - callback handler in the rte_kni library ``kni_config_mac_address()`` - will be called which calls ``rte_eth_dev_default_mac_addr_set()`` - on the specified ``port_id``. - -``config_promiscusity``: - - Called when the user changes the promiscuity state of the KNI - interface. For example, when the user runs ``ip link set promisc - [on|off] dev ``. If the user sets this callback function to - NULL, but sets the ``port_id`` field to a value other than -1, a default - callback handler in the rte_kni library ``kni_config_promiscusity()`` - will be called which calls ``rte_eth_promiscuous_()`` - on the specified ``port_id``. - -``config_allmulticast``: - - Called when the user changes the allmulticast state of the KNI interface. - For example, when the user runs ``ifconfig [-]allmulti``. If the - user sets this callback function to NULL, but sets the ``port_id`` field to - a value other than -1, a default callback handler in the rte_kni library - ``kni_config_allmulticast()`` will be called which calls - ``rte_eth_allmulticast_()`` on the specified ``port_id``. - -In order to run these callbacks, the application must periodically call -the ``rte_kni_handle_request()`` function. Any user callback function -registered will be called directly from ``rte_kni_handle_request()`` so -care must be taken to prevent deadlock and to not block any DPDK fastpath -tasks. Typically DPDK applications which use these callbacks will need -to create a separate thread or secondary process to periodically call -``rte_kni_handle_request()``. - -The KNI interfaces can be deleted by a DPDK application with -``rte_kni_release()``. All KNI interfaces not explicitly deleted will be -deleted when the ``/dev/kni`` device is closed, either explicitly with -``rte_kni_close()`` or when the DPDK application is closed. - -DPDK mbuf Flow --------------- - -To minimize the amount of DPDK code running in kernel space, the mbuf mempool is managed in userspace only. -The kernel module will be aware of mbufs, -but all mbuf allocation and free operations will be handled by the DPDK application only. - -:numref:`figure_pkt_flow_kni` shows a typical scenario with packets sent in both directions. - -.. _figure_pkt_flow_kni: - -.. figure:: img/pkt_flow_kni.* - - Packet Flow via mbufs in the DPDK KNI - - -Use Case: Ingress ------------------ - -On the DPDK RX side, the mbuf is allocated by the PMD in the RX thread context. -This thread will enqueue the mbuf in the rx_q FIFO, -and the next pointers in mbuf-chain will convert to physical address. -The KNI thread will poll all KNI active devices for the rx_q. -If an mbuf is dequeued, it will be converted to a sk_buff and sent to the net stack via netif_rx(). -The dequeued mbuf must be freed, so the same pointer is sent back in the free_q FIFO, -and next pointers must convert back to virtual address if exists before put in the free_q FIFO. - -The RX thread, in the same main loop, polls this FIFO and frees the mbuf after dequeuing it. -The address conversion of the next pointer is to prevent the chained mbuf -in different hugepage segments from causing kernel crash. - -Use Case: Egress ----------------- - -For packet egress the DPDK application must first enqueue several mbufs to create an mbuf cache on the kernel side. - -The packet is received from the Linux net stack, by calling the kni_net_tx() callback. -The mbuf is dequeued (without waiting due the cache) and filled with data from sk_buff. -The sk_buff is then freed and the mbuf sent in the tx_q FIFO. - -The DPDK TX thread dequeues the mbuf and sends it to the PMD via ``rte_eth_tx_burst()``. -It then puts the mbuf back in the cache. - -IOVA = VA: Support ------------------- - -KNI operates in IOVA_VA scheme when - -- LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) and -- EAL option `iova-mode=va` is passed or bus IOVA scheme in the DPDK is selected - as RTE_IOVA_VA. - -Due to IOVA to KVA address translations, based on the KNI use case there -can be a performance impact. For mitigation, forcing IOVA to PA via EAL -"--iova-mode=pa" option can be used, IOVA_DC bus iommu scheme can also -result in IOVA as PA. - -Ethtool -------- - -Ethtool is a Linux-specific tool with corresponding support in the kernel. -The current version of kni provides minimal ethtool functionality -including querying version and link state. It does not support link -control, statistics, or dumping device registers. diff --git a/dpdk/doc/guides/sample_app_ug/flow_classify.rst b/dpdk/doc/guides/sample_app_ug/flow_classify.rst deleted file mode 100644 index 6c4c04e93..000000000 --- a/dpdk/doc/guides/sample_app_ug/flow_classify.rst +++ /dev/null @@ -1,242 +0,0 @@ -.. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2017 Intel Corporation. - -Flow Classify Sample Application -================================ - -The Flow Classify sample application is based on the simple *skeleton* example -of a forwarding application. - -It is intended as a demonstration of the basic components of a DPDK forwarding -application which uses the Flow Classify library API's. - -Please refer to the -:doc:`../prog_guide/flow_classify_lib` -for more information. - -Compiling the Application -------------------------- - -To compile the sample application see :doc:`compiling`. - -The application is located in the ``flow_classify`` sub-directory. - -Running the Application ------------------------ - -To run the example in a ``linux`` environment: - -.. code-block:: console - - .//examples/dpdk-flow_classify -c 4 -n 4 -- / - --rule_ipv4="../ipv4_rules_file.txt" - -Please refer to the *DPDK Getting Started Guide*, section -:doc:`../linux_gsg/build_sample_apps` -for general information on running applications and the Environment Abstraction -Layer (EAL) options. - - -Sample ipv4_rules_file.txt --------------------------- - -.. code-block:: console - - #file format: - #src_ip/masklen dst_ip/masklen src_port : mask dst_port : mask proto/mask priority - # - 2.2.2.3/24 2.2.2.7/24 32 : 0xffff 33 : 0xffff 17/0xff 0 - 9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 17/0xff 1 - 9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 6/0xff 2 - 9.9.8.3/24 9.9.8.7/24 32 : 0xffff 33 : 0xffff 6/0xff 3 - 6.7.8.9/24 2.3.4.5/24 32 : 0x0000 33 : 0x0000 132/0xff 4 - -Explanation ------------ - -The following sections provide an explanation of the main components of the -code. - -All DPDK library functions used in the sample code are prefixed with ``rte_`` -and are explained in detail in the *DPDK API Documentation*. - -ACL field definitions for the IPv4 5 tuple rule -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following field definitions are used when creating the ACL table during -initialisation of the ``Flow Classify`` application - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Creation of ACL table during initialization of application. 8< - :end-before: >8 End of creation of ACL table. - -The Main Function -~~~~~~~~~~~~~~~~~ - -The ``main()`` function performs the initialization and calls the execution -threads for each lcore. - -The first task is to initialize the Environment Abstraction Layer (EAL). -The ``argc`` and ``argv`` arguments are provided to the ``rte_eal_init()`` -function. The value returned is the number of parsed arguments: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Initialize the Environment Abstraction Layer (EAL). 8< - :end-before: >8 End of initialization of EAL. - :dedent: 1 - -It then parses the flow_classify application arguments - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Parse application arguments (after the EAL ones). 8< - :end-before: >8 End of parse application arguments. - :dedent: 1 - -The ``main()`` function also allocates a mempool to hold the mbufs -(Message Buffers) used by the application: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Creates a new mempool in memory to hold the mbufs. 8< - :end-before: >8 End of creation of new mempool in memory. - :dedent: 1 - -mbufs are the packet buffer structure used by DPDK. They are explained in -detail in the "Mbuf Library" section of the *DPDK Programmer's Guide*. - -The ``main()`` function also initializes all the ports using the user defined -``port_init()`` function which is explained in the next section: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Initialize all ports. 8< - :end-before: >8 End of initialization of all ports. - :dedent: 1 - -The ``main()`` function creates the ``flow classifier object`` and adds an ``ACL -table`` to the flow classifier. - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Creation of flow classifier object. 8< - :end-before: >8 End of creation of flow classifier object. - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Memory allocation. 8< - :end-before: >8 End of initialization of table create params. - :dedent: 1 - -It then reads the ipv4_rules_file.txt file and initialises the parameters for -the ``rte_flow_classify_table_entry_add`` API. -This API adds a rule to the ACL table. - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Read file of IPv4 tuple rules. 8< - :end-before: >8 End of reading file of IPv4 5 tuple rules. - :dedent: 1 - -Once the initialization is complete, the application is ready to launch a -function on an lcore. In this example ``lcore_main()`` is called on a single -lcore. - -.. code-block:: c - - lcore_main(cls_app); - -The ``lcore_main()`` function is explained below. - -The Port Initialization Function -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The main functional part of the port initialization used in the Basic -Forwarding application is shown below: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Initializing port using global settings. 8< - :end-before: >8 End of initializing a given port. - -The Ethernet ports are configured with default settings using the -``rte_eth_dev_configure()`` function. - -For this example the ports are set up with 1 RX and 1 TX queue using the -``rte_eth_rx_queue_setup()`` and ``rte_eth_tx_queue_setup()`` functions. - -The Ethernet port is then started: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Start the Ethernet port. 8< - :end-before: >8 End of starting the Ethernet port. - :dedent: 1 - - -Finally the RX port is set in promiscuous mode: - -.. code-block:: c - - retval = rte_eth_promiscuous_enable(port); - -The Add Rules function -~~~~~~~~~~~~~~~~~~~~~~ - -The ``add_rules`` function reads the ``ipv4_rules_file.txt`` file and calls the -``add_classify_rule`` function which calls the -``rte_flow_classify_table_entry_add`` API. - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Reads file and calls the add_classify_rule function. 8< - :end-before: >8 End of add_rules. - - -The Lcore Main function -~~~~~~~~~~~~~~~~~~~~~~~ - -As we saw above the ``main()`` function calls an application function on the -available lcores. -The ``lcore_main`` function calls the ``rte_flow_classifier_query`` API. -For the Basic Forwarding application the ``lcore_main`` function looks like the -following: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Flow classify data. 8< - :end-before: >8 End of flow classify data. - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Classifying the packets. 8< - :end-before: >8 End of lcore main. - -The main work of the application is done within the loop: - -.. literalinclude:: ../../../examples/flow_classify/flow_classify.c - :language: c - :start-after: Run until the application is quit or killed. 8< - :end-before: >8 End of main loop. - :dedent: 1 - -Packets are received in bursts on the RX ports and transmitted in bursts on -the TX ports. The ports are grouped in pairs with a simple mapping scheme -using the an XOR on the port number:: - - 0 -> 1 - 1 -> 0 - - 2 -> 3 - 3 -> 2 - - etc. - -The ``rte_eth_tx_burst()`` function frees the memory buffers of packets that -are transmitted. If packets fail to transmit, ``(nb_tx < nb_rx)``, then they -must be freed explicitly using ``rte_pktmbuf_free()``. - -The forwarding loop can be interrupted and the application closed using -``Ctrl-C``. diff --git a/dpdk/drivers/baseband/acc/acc200_cfg.h b/dpdk/drivers/baseband/acc/acc200_cfg.h deleted file mode 100644 index d77506b56..000000000 --- a/dpdk/drivers/baseband/acc/acc200_cfg.h +++ /dev/null @@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#ifndef _ACC200_CFG_H_ -#define _ACC200_CFG_H_ - -/** - * @file acc200_cfg.h - * - * Functions for configuring ACC200 HW. - * Configuration related to encoding/decoding is done through the - * librte_bbdev library. - */ - -/** - * Configure a ACC200 device. - * - * @param dev_name - * The name of the device. This is the short form of PCI BDF, e.g. 00:01.0. - * It can also be retrieved for a bbdev device from the dev_name field in the - * rte_bbdev_info structure returned by rte_bbdev_info_get(). - * @param conf - * Configuration to apply to ACC200 HW. - * - * @return - * Zero on success, negative value on failure. - */ -int -acc200_configure(const char *dev_name, struct rte_acc_conf *conf); - -#endif /* _ACC200_CFG_H_ */ diff --git a/dpdk/drivers/baseband/acc/acc200_pf_enum.h b/dpdk/drivers/baseband/acc/acc200_pf_enum.h deleted file mode 100644 index e52d8f5b1..000000000 --- a/dpdk/drivers/baseband/acc/acc200_pf_enum.h +++ /dev/null @@ -1,108 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2021 Intel Corporation - */ - -#ifndef ACC200_PF_ENUM_H -#define ACC200_PF_ENUM_H - -/* - * ACC200 Register mapping on PF BAR0 - * This is automatically generated from RDL, format may change with new RDL - * Release. - * Variable names are as is - */ -enum { - HWPfQmgrEgressQueuesTemplate = 0x0007FC00, - HWPfQmgrIngressAq = 0x00080000, - HWPfQmgrDepthLog2Grp = 0x00A00200, - HWPfQmgrTholdGrp = 0x00A00300, - HWPfQmgrGrpTmplateReg0Indx = 0x00A00600, - HWPfQmgrGrpTmplateReg1Indx = 0x00A00700, - HWPfQmgrGrpTmplateReg2indx = 0x00A00800, - HWPfQmgrGrpTmplateReg3Indx = 0x00A00900, - HWPfQmgrGrpTmplateReg4Indx = 0x00A00A00, - HWPfQmgrVfBaseAddr = 0x00A01000, - HWPfQmgrArbQDepthGrp = 0x00A02F00, - HWPfQmgrGrpFunction0 = 0x00A02F40, - HWPfQmgrGrpFunction1 = 0x00A02F44, - HWPfQmgrGrpPriority = 0x00A02F48, - HWPfQmgrAqEnableVf = 0x00A10000, - HWPfQmgrRingSizeVf = 0x00A20004, - HWPfQmgrGrpDepthLog20Vf = 0x00A20008, - HWPfQmgrGrpDepthLog21Vf = 0x00A2000C, - HWPfFabricM2iBufferReg = 0x00B30000, - HWPfFabricI2Mdma_weight = 0x00B31044, - HwPfFecUl5gIbDebugReg = 0x00B40200, - HWPfFftConfig0 = 0x00B58004, - HWPfFftRamPageAccess = 0x00B5800C, - HWPfFftRamOff = 0x00B58800, - HWPfDmaConfig0Reg = 0x00B80000, - HWPfDmaConfig1Reg = 0x00B80004, - HWPfDmaQmgrAddrReg = 0x00B80008, - HWPfDmaAxcacheReg = 0x00B80010, - HWPfDmaAxiControl = 0x00B8002C, - HWPfDmaQmanen = 0x00B80040, - HWPfDma4gdlIbThld = 0x00B800CC, - HWPfDmaCfgRrespBresp = 0x00B80814, - HWPfDmaDescriptorSignatuture = 0x00B80868, - HWPfDmaErrorDetectionEn = 0x00B80870, - HWPfDmaFec5GulDescBaseLoRegVf = 0x00B88020, - HWPfDmaFec5GulDescBaseHiRegVf = 0x00B88024, - HWPfDmaFec5GulRespPtrLoRegVf = 0x00B88028, - HWPfDmaFec5GulRespPtrHiRegVf = 0x00B8802C, - HWPfDmaFec5GdlDescBaseLoRegVf = 0x00B88040, - HWPfDmaFec5GdlDescBaseHiRegVf = 0x00B88044, - HWPfDmaFec5GdlRespPtrLoRegVf = 0x00B88048, - HWPfDmaFec5GdlRespPtrHiRegVf = 0x00B8804C, - HWPfDmaFec4GulDescBaseLoRegVf = 0x00B88060, - HWPfDmaFec4GulDescBaseHiRegVf = 0x00B88064, - HWPfDmaFec4GulRespPtrLoRegVf = 0x00B88068, - HWPfDmaFec4GulRespPtrHiRegVf = 0x00B8806C, - HWPfDmaFec4GdlDescBaseLoRegVf = 0x00B88080, - HWPfDmaFec4GdlDescBaseHiRegVf = 0x00B88084, - HWPfDmaFec4GdlRespPtrLoRegVf = 0x00B88088, - HWPfDmaFec4GdlRespPtrHiRegVf = 0x00B8808C, - HWPDmaFftDescBaseLoRegVf = 0x00B880A0, - HWPDmaFftDescBaseHiRegVf = 0x00B880A4, - HWPDmaFftRespPtrLoRegVf = 0x00B880A8, - HWPDmaFftRespPtrHiRegVf = 0x00B880AC, - HWPfQosmonAEvalOverflow0 = 0x00B90008, - HWPfPermonACntrlRegVf = 0x00B98000, - HWPfQosmonBEvalOverflow0 = 0x00BA0008, - HWPfPermonBCntrlRegVf = 0x00BA8000, - HWPfPermonCCntrlRegVf = 0x00BB8000, - HWPfHiInfoRingBaseLoRegPf = 0x00C84014, - HWPfHiInfoRingBaseHiRegPf = 0x00C84018, - HWPfHiInfoRingPointerRegPf = 0x00C8401C, - HWPfHiInfoRingIntWrEnRegPf = 0x00C84020, - HWPfHiBlockTransmitOnErrorEn = 0x00C84038, - HWPfHiCfgMsiIntWrEnRegPf = 0x00C84040, - HWPfHiMsixVectorMapperPf = 0x00C84060, - HWPfHiPfMode = 0x00C84108, - HWPfHiClkGateHystReg = 0x00C8410C, - HWPfHiMsiDropEnableReg = 0x00C84114, - HWPfHiSectionPowerGatingReq = 0x00C84128, - HWPfHiSectionPowerGatingAck = 0x00C8412C, -}; - -/* TIP PF Interrupt numbers */ -enum { - ACC200_PF_INT_QMGR_AQ_OVERFLOW = 0, - ACC200_PF_INT_DOORBELL_VF_2_PF = 1, - ACC200_PF_INT_ILLEGAL_FORMAT = 2, - ACC200_PF_INT_QMGR_DISABLED_ACCESS = 3, - ACC200_PF_INT_QMGR_AQ_OVERTHRESHOLD = 4, - ACC200_PF_INT_DMA_DL_DESC_IRQ = 5, - ACC200_PF_INT_DMA_UL_DESC_IRQ = 6, - ACC200_PF_INT_DMA_FFT_DESC_IRQ = 7, - ACC200_PF_INT_DMA_UL5G_DESC_IRQ = 8, - ACC200_PF_INT_DMA_DL5G_DESC_IRQ = 9, - ACC200_PF_INT_DMA_MLD_DESC_IRQ = 10, - ACC200_PF_INT_ARAM_ECC_1BIT_ERR = 11, - ACC200_PF_INT_PARITY_ERR = 12, - ACC200_PF_INT_QMGR_ERR = 13, - ACC200_PF_INT_INT_REQ_OVERFLOW = 14, - ACC200_PF_INT_APB_TIMEOUT = 15, -}; - -#endif /* ACC200_PF_ENUM_H */ diff --git a/dpdk/drivers/baseband/acc/acc200_pmd.h b/dpdk/drivers/baseband/acc/acc200_pmd.h deleted file mode 100644 index f3f2627ae..000000000 --- a/dpdk/drivers/baseband/acc/acc200_pmd.h +++ /dev/null @@ -1,196 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#ifndef _RTE_ACC200_PMD_H_ -#define _RTE_ACC200_PMD_H_ - -#include "acc_common.h" -#include "acc200_pf_enum.h" -#include "acc200_vf_enum.h" -#include "acc200_cfg.h" - -/* Helper macro for logging */ -#define rte_bbdev_log(level, fmt, ...) \ - rte_log(RTE_LOG_ ## level, acc200_logtype, fmt "\n", \ - ##__VA_ARGS__) - -#ifdef RTE_LIBRTE_BBDEV_DEBUG -#define rte_bbdev_log_debug(fmt, ...) \ - rte_bbdev_log(DEBUG, "acc200_pmd: " fmt, \ - ##__VA_ARGS__) -#else -#define rte_bbdev_log_debug(fmt, ...) -#endif - -/* ACC200 PF and VF driver names */ -#define ACC200PF_DRIVER_NAME intel_acc200_pf -#define ACC200VF_DRIVER_NAME intel_acc200_vf - -/* ACC200 PCI vendor & device IDs */ -#define RTE_ACC200_VENDOR_ID (0x8086) -#define RTE_ACC200_PF_DEVICE_ID (0x57C0) -#define RTE_ACC200_VF_DEVICE_ID (0x57C1) - -#define ACC200_MAX_PF_MSIX (256+32) -#define ACC200_MAX_VF_MSIX (256+7) - -/* Values used in writing to the registers */ -#define ACC200_REG_IRQ_EN_ALL 0x1FF83FF /* Enable all interrupts */ - -/* Number of Virtual Functions ACC200 supports */ -#define ACC200_NUM_VFS 16 -#define ACC200_NUM_QGRPS 16 -#define ACC200_NUM_AQS 16 - -#define ACC200_GRP_ID_SHIFT 10 /* Queue Index Hierarchy */ -#define ACC200_VF_ID_SHIFT 4 /* Queue Index Hierarchy */ -#define ACC200_WORDS_IN_ARAM_SIZE (256 * 1024 / 4) - -/* Mapping of signals for the available engines */ -#define ACC200_SIG_UL_5G 0 -#define ACC200_SIG_UL_5G_LAST 4 -#define ACC200_SIG_DL_5G 10 -#define ACC200_SIG_DL_5G_LAST 11 -#define ACC200_SIG_UL_4G 12 -#define ACC200_SIG_UL_4G_LAST 16 -#define ACC200_SIG_DL_4G 21 -#define ACC200_SIG_DL_4G_LAST 23 -#define ACC200_SIG_FFT 24 -#define ACC200_SIG_FFT_LAST 24 - -#define ACC200_NUM_ACCS 5 - -/* ACC200 Configuration */ -#define ACC200_FABRIC_MODE 0x8000103 -#define ACC200_CFG_DMA_ERROR 0x3DF -#define ACC200_CFG_AXI_CACHE 0x11 -#define ACC200_CFG_QMGR_HI_P 0x0F0F -#define ACC200_RESET_HARD 0x1FF -#define ACC200_ENGINES_MAX 9 -#define ACC200_GPEX_AXIMAP_NUM 17 -#define ACC200_CLOCK_GATING_EN 0x30000 -#define ACC200_FFT_CFG_0 0x2001 -#define ACC200_FFT_RAM_EN 0x80008000 -#define ACC200_FFT_RAM_DIS 0x0 -#define ACC200_FFT_RAM_SIZE 512 -#define ACC200_CLK_EN 0x00010A01 -#define ACC200_CLK_DIS 0x01F10A01 -#define ACC200_PG_MASK_0 0x1F -#define ACC200_PG_MASK_1 0xF -#define ACC200_PG_MASK_2 0x1 -#define ACC200_PG_MASK_3 0x0 -#define ACC200_PG_MASK_FFT 1 -#define ACC200_PG_MASK_4GUL 4 -#define ACC200_PG_MASK_5GUL 8 -#define ACC200_STATUS_WAIT 10 -#define ACC200_STATUS_TO 100 - -struct acc200_registry_addr { - unsigned int dma_ring_dl5g_hi; - unsigned int dma_ring_dl5g_lo; - unsigned int dma_ring_ul5g_hi; - unsigned int dma_ring_ul5g_lo; - unsigned int dma_ring_dl4g_hi; - unsigned int dma_ring_dl4g_lo; - unsigned int dma_ring_ul4g_hi; - unsigned int dma_ring_ul4g_lo; - unsigned int dma_ring_fft_hi; - unsigned int dma_ring_fft_lo; - unsigned int ring_size; - unsigned int info_ring_hi; - unsigned int info_ring_lo; - unsigned int info_ring_en; - unsigned int info_ring_ptr; - unsigned int tail_ptrs_dl5g_hi; - unsigned int tail_ptrs_dl5g_lo; - unsigned int tail_ptrs_ul5g_hi; - unsigned int tail_ptrs_ul5g_lo; - unsigned int tail_ptrs_dl4g_hi; - unsigned int tail_ptrs_dl4g_lo; - unsigned int tail_ptrs_ul4g_hi; - unsigned int tail_ptrs_ul4g_lo; - unsigned int tail_ptrs_fft_hi; - unsigned int tail_ptrs_fft_lo; - unsigned int depth_log0_offset; - unsigned int depth_log1_offset; - unsigned int qman_group_func; - unsigned int hi_mode; - unsigned int pmon_ctrl_a; - unsigned int pmon_ctrl_b; - unsigned int pmon_ctrl_c; -}; - -/* Structure holding registry addresses for PF */ -static const struct acc200_registry_addr pf_reg_addr = { - .dma_ring_dl5g_hi = HWPfDmaFec5GdlDescBaseHiRegVf, - .dma_ring_dl5g_lo = HWPfDmaFec5GdlDescBaseLoRegVf, - .dma_ring_ul5g_hi = HWPfDmaFec5GulDescBaseHiRegVf, - .dma_ring_ul5g_lo = HWPfDmaFec5GulDescBaseLoRegVf, - .dma_ring_dl4g_hi = HWPfDmaFec4GdlDescBaseHiRegVf, - .dma_ring_dl4g_lo = HWPfDmaFec4GdlDescBaseLoRegVf, - .dma_ring_ul4g_hi = HWPfDmaFec4GulDescBaseHiRegVf, - .dma_ring_ul4g_lo = HWPfDmaFec4GulDescBaseLoRegVf, - .dma_ring_fft_hi = HWPDmaFftDescBaseHiRegVf, - .dma_ring_fft_lo = HWPDmaFftDescBaseLoRegVf, - .ring_size = HWPfQmgrRingSizeVf, - .info_ring_hi = HWPfHiInfoRingBaseHiRegPf, - .info_ring_lo = HWPfHiInfoRingBaseLoRegPf, - .info_ring_en = HWPfHiInfoRingIntWrEnRegPf, - .info_ring_ptr = HWPfHiInfoRingPointerRegPf, - .tail_ptrs_dl5g_hi = HWPfDmaFec5GdlRespPtrHiRegVf, - .tail_ptrs_dl5g_lo = HWPfDmaFec5GdlRespPtrLoRegVf, - .tail_ptrs_ul5g_hi = HWPfDmaFec5GulRespPtrHiRegVf, - .tail_ptrs_ul5g_lo = HWPfDmaFec5GulRespPtrLoRegVf, - .tail_ptrs_dl4g_hi = HWPfDmaFec4GdlRespPtrHiRegVf, - .tail_ptrs_dl4g_lo = HWPfDmaFec4GdlRespPtrLoRegVf, - .tail_ptrs_ul4g_hi = HWPfDmaFec4GulRespPtrHiRegVf, - .tail_ptrs_ul4g_lo = HWPfDmaFec4GulRespPtrLoRegVf, - .tail_ptrs_fft_hi = HWPDmaFftRespPtrHiRegVf, - .tail_ptrs_fft_lo = HWPDmaFftRespPtrLoRegVf, - .depth_log0_offset = HWPfQmgrGrpDepthLog20Vf, - .depth_log1_offset = HWPfQmgrGrpDepthLog21Vf, - .qman_group_func = HWPfQmgrGrpFunction0, - .hi_mode = HWPfHiMsixVectorMapperPf, - .pmon_ctrl_a = HWPfPermonACntrlRegVf, - .pmon_ctrl_b = HWPfPermonBCntrlRegVf, - .pmon_ctrl_c = HWPfPermonCCntrlRegVf, -}; - -/* Structure holding registry addresses for VF */ -static const struct acc200_registry_addr vf_reg_addr = { - .dma_ring_dl5g_hi = HWVfDmaFec5GdlDescBaseHiRegVf, - .dma_ring_dl5g_lo = HWVfDmaFec5GdlDescBaseLoRegVf, - .dma_ring_ul5g_hi = HWVfDmaFec5GulDescBaseHiRegVf, - .dma_ring_ul5g_lo = HWVfDmaFec5GulDescBaseLoRegVf, - .dma_ring_dl4g_hi = HWVfDmaFec4GdlDescBaseHiRegVf, - .dma_ring_dl4g_lo = HWVfDmaFec4GdlDescBaseLoRegVf, - .dma_ring_ul4g_hi = HWVfDmaFec4GulDescBaseHiRegVf, - .dma_ring_ul4g_lo = HWVfDmaFec4GulDescBaseLoRegVf, - .dma_ring_fft_hi = HWVfDmaFftDescBaseHiRegVf, - .dma_ring_fft_lo = HWVfDmaFftDescBaseLoRegVf, - .ring_size = HWVfQmgrRingSizeVf, - .info_ring_hi = HWVfHiInfoRingBaseHiVf, - .info_ring_lo = HWVfHiInfoRingBaseLoVf, - .info_ring_en = HWVfHiInfoRingIntWrEnVf, - .info_ring_ptr = HWVfHiInfoRingPointerVf, - .tail_ptrs_dl5g_hi = HWVfDmaFec5GdlRespPtrHiRegVf, - .tail_ptrs_dl5g_lo = HWVfDmaFec5GdlRespPtrLoRegVf, - .tail_ptrs_ul5g_hi = HWVfDmaFec5GulRespPtrHiRegVf, - .tail_ptrs_ul5g_lo = HWVfDmaFec5GulRespPtrLoRegVf, - .tail_ptrs_dl4g_hi = HWVfDmaFec4GdlRespPtrHiRegVf, - .tail_ptrs_dl4g_lo = HWVfDmaFec4GdlRespPtrLoRegVf, - .tail_ptrs_ul4g_hi = HWVfDmaFec4GulRespPtrHiRegVf, - .tail_ptrs_ul4g_lo = HWVfDmaFec4GulRespPtrLoRegVf, - .tail_ptrs_fft_hi = HWVfDmaFftRespPtrHiRegVf, - .tail_ptrs_fft_lo = HWVfDmaFftRespPtrLoRegVf, - .depth_log0_offset = HWVfQmgrGrpDepthLog20Vf, - .depth_log1_offset = HWVfQmgrGrpDepthLog21Vf, - .qman_group_func = HWVfQmgrGrpFunction0Vf, - .hi_mode = HWVfHiMsixVectorMapperVf, - .pmon_ctrl_a = HWVfPmACntrlRegVf, - .pmon_ctrl_b = HWVfPmBCntrlRegVf, - .pmon_ctrl_c = HWVfPmCCntrlRegVf, -}; - -#endif /* _RTE_ACC200_PMD_H_ */ diff --git a/dpdk/drivers/baseband/acc/acc200_vf_enum.h b/dpdk/drivers/baseband/acc/acc200_vf_enum.h deleted file mode 100644 index 0d354208a..000000000 --- a/dpdk/drivers/baseband/acc/acc200_vf_enum.h +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2021 Intel Corporation - */ - -#ifndef ACC200_VF_ENUM_H -#define ACC200_VF_ENUM_H - -/* - * ACC200 Register mapping on VF BAR0 - * This is automatically generated from RDL, format may change with new RDL - */ -enum { - HWVfQmgrIngressAq = 0x00000000, - HWVfHiVfToPfDbellVf = 0x00000800, - HWVfHiPfToVfDbellVf = 0x00000808, - HWVfHiInfoRingBaseLoVf = 0x00000810, - HWVfHiInfoRingBaseHiVf = 0x00000814, - HWVfHiInfoRingPointerVf = 0x00000818, - HWVfHiInfoRingIntWrEnVf = 0x00000820, - HWVfHiInfoRingPf2VfWrEnVf = 0x00000824, - HWVfHiMsixVectorMapperVf = 0x00000860, - HWVfDmaFec5GulDescBaseLoRegVf = 0x00000920, - HWVfDmaFec5GulDescBaseHiRegVf = 0x00000924, - HWVfDmaFec5GulRespPtrLoRegVf = 0x00000928, - HWVfDmaFec5GulRespPtrHiRegVf = 0x0000092C, - HWVfDmaFec5GdlDescBaseLoRegVf = 0x00000940, - HWVfDmaFec5GdlDescBaseHiRegVf = 0x00000944, - HWVfDmaFec5GdlRespPtrLoRegVf = 0x00000948, - HWVfDmaFec5GdlRespPtrHiRegVf = 0x0000094C, - HWVfDmaFec4GulDescBaseLoRegVf = 0x00000960, - HWVfDmaFec4GulDescBaseHiRegVf = 0x00000964, - HWVfDmaFec4GulRespPtrLoRegVf = 0x00000968, - HWVfDmaFec4GulRespPtrHiRegVf = 0x0000096C, - HWVfDmaFec4GdlDescBaseLoRegVf = 0x00000980, - HWVfDmaFec4GdlDescBaseHiRegVf = 0x00000984, - HWVfDmaFec4GdlRespPtrLoRegVf = 0x00000988, - HWVfDmaFec4GdlRespPtrHiRegVf = 0x0000098C, - HWVfDmaFftDescBaseLoRegVf = 0x000009A0, - HWVfDmaFftDescBaseHiRegVf = 0x000009A4, - HWVfDmaFftRespPtrLoRegVf = 0x000009A8, - HWVfDmaFftRespPtrHiRegVf = 0x000009AC, - HWVfQmgrAqResetVf = 0x00000E00, - HWVfQmgrRingSizeVf = 0x00000E04, - HWVfQmgrGrpDepthLog20Vf = 0x00000E08, - HWVfQmgrGrpDepthLog21Vf = 0x00000E0C, - HWVfQmgrGrpFunction0Vf = 0x00000E10, - HWVfQmgrGrpFunction1Vf = 0x00000E14, - HWVfPmACntrlRegVf = 0x00000F40, - HWVfPmACountVf = 0x00000F48, - HWVfPmAKCntLoVf = 0x00000F50, - HWVfPmAKCntHiVf = 0x00000F54, - HWVfPmADeltaCntLoVf = 0x00000F60, - HWVfPmADeltaCntHiVf = 0x00000F64, - HWVfPmBCntrlRegVf = 0x00000F80, - HWVfPmBCountVf = 0x00000F88, - HWVfPmBKCntLoVf = 0x00000F90, - HWVfPmBKCntHiVf = 0x00000F94, - HWVfPmBDeltaCntLoVf = 0x00000FA0, - HWVfPmBDeltaCntHiVf = 0x00000FA4, - HWVfPmCCntrlRegVf = 0x00000FC0, - HWVfPmCCountVf = 0x00000FC8, - HWVfPmCKCntLoVf = 0x00000FD0, - HWVfPmCKCntHiVf = 0x00000FD4, - HWVfPmCDeltaCntLoVf = 0x00000FE0, - HWVfPmCDeltaCntHiVf = 0x00000FE4 -}; - -/* TIP VF Interrupt numbers */ -enum { - ACC200_VF_INT_QMGR_AQ_OVERFLOW = 0, - ACC200_VF_INT_DOORBELL_PF_2_VF = 1, - ACC200_VF_INT_ILLEGAL_FORMAT = 2, - ACC200_VF_INT_QMGR_DISABLED_ACCESS = 3, - ACC200_VF_INT_QMGR_AQ_OVERTHRESHOLD = 4, - ACC200_VF_INT_DMA_DL_DESC_IRQ = 5, - ACC200_VF_INT_DMA_UL_DESC_IRQ = 6, - ACC200_VF_INT_DMA_FFT_DESC_IRQ = 7, - ACC200_VF_INT_DMA_UL5G_DESC_IRQ = 8, - ACC200_VF_INT_DMA_DL5G_DESC_IRQ = 9, - ACC200_VF_INT_DMA_MLD_DESC_IRQ = 10, -}; - -#endif /* ACC200_VF_ENUM_H */ diff --git a/dpdk/drivers/baseband/acc/acc_common.c b/dpdk/drivers/baseband/acc/acc_common.c deleted file mode 100644 index f8d2b1957..000000000 --- a/dpdk/drivers/baseband/acc/acc_common.c +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2023 Red Hat, Inc. - */ - -#include - -RTE_LOG_REGISTER_SUFFIX(acc_common_logtype, common, INFO); diff --git a/dpdk/drivers/baseband/acc/rte_acc200_pmd.c b/dpdk/drivers/baseband/acc/rte_acc200_pmd.c deleted file mode 100644 index 8bda3a8e0..000000000 --- a/dpdk/drivers/baseband/acc/rte_acc200_pmd.c +++ /dev/null @@ -1,3845 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef RTE_BBDEV_OFFLOAD_COST -#include -#endif - -#include -#include -#include "acc200_pmd.h" - -#ifdef RTE_LIBRTE_BBDEV_DEBUG -RTE_LOG_REGISTER_SUFFIX(acc200_logtype, acc200, DEBUG); -#else -RTE_LOG_REGISTER_SUFFIX(acc200_logtype, acc200, NOTICE); -#endif - -/* Calculate the offset of the enqueue register. */ -static inline uint32_t -queue_offset(bool pf_device, uint8_t vf_id, uint8_t qgrp_id, uint16_t aq_id) -{ - if (pf_device) - return ((vf_id << 12) + (qgrp_id << 7) + (aq_id << 3) + - HWPfQmgrIngressAq); - else - return ((qgrp_id << 7) + (aq_id << 3) + - HWVfQmgrIngressAq); -} - -enum {UL_4G = 0, UL_5G, DL_4G, DL_5G, FFT, NUM_ACC}; - -/* Return the accelerator enum for a Queue Group Index. */ -static inline int -accFromQgid(int qg_idx, const struct rte_acc_conf *acc_conf) -{ - int accQg[ACC200_NUM_QGRPS]; - int NumQGroupsPerFn[NUM_ACC]; - int acc, qgIdx, qgIndex = 0; - for (qgIdx = 0; qgIdx < ACC200_NUM_QGRPS; qgIdx++) - accQg[qgIdx] = 0; - NumQGroupsPerFn[UL_4G] = acc_conf->q_ul_4g.num_qgroups; - NumQGroupsPerFn[UL_5G] = acc_conf->q_ul_5g.num_qgroups; - NumQGroupsPerFn[DL_4G] = acc_conf->q_dl_4g.num_qgroups; - NumQGroupsPerFn[DL_5G] = acc_conf->q_dl_5g.num_qgroups; - NumQGroupsPerFn[FFT] = acc_conf->q_fft.num_qgroups; - for (acc = UL_4G; acc < NUM_ACC; acc++) - for (qgIdx = 0; qgIdx < NumQGroupsPerFn[acc]; qgIdx++) - accQg[qgIndex++] = acc; - acc = accQg[qg_idx]; - return acc; -} - -/* Return the queue topology for a Queue Group Index. */ -static inline void -qtopFromAcc(struct rte_acc_queue_topology **qtop, int acc_enum, struct rte_acc_conf *acc_conf) -{ - struct rte_acc_queue_topology *p_qtop; - p_qtop = NULL; - - switch (acc_enum) { - case UL_4G: - p_qtop = &(acc_conf->q_ul_4g); - break; - case UL_5G: - p_qtop = &(acc_conf->q_ul_5g); - break; - case DL_4G: - p_qtop = &(acc_conf->q_dl_4g); - break; - case DL_5G: - p_qtop = &(acc_conf->q_dl_5g); - break; - case FFT: - p_qtop = &(acc_conf->q_fft); - break; - default: - /* NOTREACHED. */ - rte_bbdev_log(ERR, "Unexpected error evaluating %s using %d", __func__, acc_enum); - break; - } - *qtop = p_qtop; -} - -/* Return the AQ depth for a Queue Group Index. */ -static inline int -aqDepth(int qg_idx, struct rte_acc_conf *acc_conf) -{ - struct rte_acc_queue_topology *q_top = NULL; - - int acc_enum = accFromQgid(qg_idx, acc_conf); - qtopFromAcc(&q_top, acc_enum, acc_conf); - - if (unlikely(q_top == NULL)) - return 1; - - return RTE_MAX(1, q_top->aq_depth_log2); -} - -/* Return the AQ depth for a Queue Group Index. */ -static inline int -aqNum(int qg_idx, struct rte_acc_conf *acc_conf) -{ - struct rte_acc_queue_topology *q_top = NULL; - - int acc_enum = accFromQgid(qg_idx, acc_conf); - qtopFromAcc(&q_top, acc_enum, acc_conf); - - if (unlikely(q_top == NULL)) - return 0; - - return q_top->num_aqs_per_groups; -} - -static void -initQTop(struct rte_acc_conf *acc_conf) -{ - acc_conf->q_ul_4g.num_aqs_per_groups = 0; - acc_conf->q_ul_4g.num_qgroups = 0; - acc_conf->q_ul_4g.first_qgroup_index = -1; - acc_conf->q_ul_5g.num_aqs_per_groups = 0; - acc_conf->q_ul_5g.num_qgroups = 0; - acc_conf->q_ul_5g.first_qgroup_index = -1; - acc_conf->q_dl_4g.num_aqs_per_groups = 0; - acc_conf->q_dl_4g.num_qgroups = 0; - acc_conf->q_dl_4g.first_qgroup_index = -1; - acc_conf->q_dl_5g.num_aqs_per_groups = 0; - acc_conf->q_dl_5g.num_qgroups = 0; - acc_conf->q_dl_5g.first_qgroup_index = -1; - acc_conf->q_fft.num_aqs_per_groups = 0; - acc_conf->q_fft.num_qgroups = 0; - acc_conf->q_fft.first_qgroup_index = -1; -} - -static inline void -updateQtop(uint8_t acc, uint8_t qg, struct rte_acc_conf *acc_conf, struct acc_device *d) { - uint32_t reg; - struct rte_acc_queue_topology *q_top = NULL; - uint16_t aq; - - qtopFromAcc(&q_top, acc, acc_conf); - if (unlikely(q_top == NULL)) - return; - q_top->num_qgroups++; - if (q_top->first_qgroup_index == -1) { - q_top->first_qgroup_index = qg; - /* Can be optimized to assume all are enabled by default. */ - reg = acc_reg_read(d, queue_offset(d->pf_device, 0, qg, ACC200_NUM_AQS - 1)); - if (reg & ACC_QUEUE_ENABLE) { - q_top->num_aqs_per_groups = ACC200_NUM_AQS; - return; - } - q_top->num_aqs_per_groups = 0; - for (aq = 0; aq < ACC200_NUM_AQS; aq++) { - reg = acc_reg_read(d, queue_offset(d->pf_device, 0, qg, aq)); - if (reg & ACC_QUEUE_ENABLE) - q_top->num_aqs_per_groups++; - } - } -} - -/* Check device Qmgr is enabled for protection */ -static inline bool -acc200_check_device_enable(struct rte_bbdev *dev) -{ - uint32_t reg_aq, qg; - struct acc_device *d = dev->data->dev_private; - - for (qg = 0; qg < ACC200_NUM_QGRPS; qg++) { - reg_aq = acc_reg_read(d, queue_offset(d->pf_device, 0, qg, 0)); - if (reg_aq & ACC_QUEUE_ENABLE) - return true; - } - return false; -} - -/* Fetch configuration enabled for the PF/VF using MMIO Read (slow). */ -static inline void -fetch_acc200_config(struct rte_bbdev *dev) -{ - struct acc_device *d = dev->data->dev_private; - struct rte_acc_conf *acc_conf = &d->acc_conf; - const struct acc200_registry_addr *reg_addr; - uint8_t acc, qg; - uint32_t reg_aq, reg_len0, reg_len1, reg0, reg1; - uint32_t reg_mode, idx; - struct rte_acc_queue_topology *q_top = NULL; - int qman_func_id[ACC200_NUM_ACCS] = {ACC_ACCMAP_0, ACC_ACCMAP_1, - ACC_ACCMAP_2, ACC_ACCMAP_3, ACC_ACCMAP_4}; - - /* No need to retrieve the configuration is already done. */ - if (d->configured) - return; - - if (!acc200_check_device_enable(dev)) { - rte_bbdev_log(NOTICE, "%s has no queue enabled and can't be used.", - dev->data->name); - return; - } - - /* Choose correct registry addresses for the device type. */ - if (d->pf_device) - reg_addr = &pf_reg_addr; - else - reg_addr = &vf_reg_addr; - - d->ddr_size = 0; - - /* Single VF Bundle by VF. */ - acc_conf->num_vf_bundles = 1; - initQTop(acc_conf); - - reg0 = acc_reg_read(d, reg_addr->qman_group_func); - reg1 = acc_reg_read(d, reg_addr->qman_group_func + 4); - for (qg = 0; qg < ACC200_NUM_QGRPS; qg++) { - reg_aq = acc_reg_read(d, queue_offset(d->pf_device, 0, qg, 0)); - if (reg_aq & ACC_QUEUE_ENABLE) { - if (qg < ACC_NUM_QGRPS_PER_WORD) - idx = (reg0 >> (qg * 4)) & 0x7; - else - idx = (reg1 >> ((qg - - ACC_NUM_QGRPS_PER_WORD) * 4)) & 0x7; - if (idx < ACC200_NUM_ACCS) { - acc = qman_func_id[idx]; - updateQtop(acc, qg, acc_conf, d); - } - } - } - - /* Check the depth of the AQs. */ - reg_len0 = acc_reg_read(d, reg_addr->depth_log0_offset); - reg_len1 = acc_reg_read(d, reg_addr->depth_log1_offset); - for (acc = 0; acc < NUM_ACC; acc++) { - qtopFromAcc(&q_top, acc, acc_conf); - if (q_top->first_qgroup_index < ACC_NUM_QGRPS_PER_WORD) - q_top->aq_depth_log2 = (reg_len0 >> (q_top->first_qgroup_index * 4)) & 0xF; - else - q_top->aq_depth_log2 = (reg_len1 >> ((q_top->first_qgroup_index - - ACC_NUM_QGRPS_PER_WORD) * 4)) & 0xF; - } - - /* Read PF mode. */ - if (d->pf_device) { - reg_mode = acc_reg_read(d, HWPfHiPfMode); - acc_conf->pf_mode_en = (reg_mode == ACC_PF_VAL) ? 1 : 0; - } else { - reg_mode = acc_reg_read(d, reg_addr->hi_mode); - acc_conf->pf_mode_en = reg_mode & 1; - } - - rte_bbdev_log_debug( - "%s Config LLR SIGN IN/OUT %s %s QG %u %u %u %u %u AQ %u %u %u %u %u Len %u %u %u %u %u\n", - (d->pf_device) ? "PF" : "VF", - (acc_conf->input_pos_llr_1_bit) ? "POS" : "NEG", - (acc_conf->output_pos_llr_1_bit) ? "POS" : "NEG", - acc_conf->q_ul_4g.num_qgroups, - acc_conf->q_dl_4g.num_qgroups, - acc_conf->q_ul_5g.num_qgroups, - acc_conf->q_dl_5g.num_qgroups, - acc_conf->q_fft.num_qgroups, - acc_conf->q_ul_4g.num_aqs_per_groups, - acc_conf->q_dl_4g.num_aqs_per_groups, - acc_conf->q_ul_5g.num_aqs_per_groups, - acc_conf->q_dl_5g.num_aqs_per_groups, - acc_conf->q_fft.num_aqs_per_groups, - acc_conf->q_ul_4g.aq_depth_log2, - acc_conf->q_dl_4g.aq_depth_log2, - acc_conf->q_ul_5g.aq_depth_log2, - acc_conf->q_dl_5g.aq_depth_log2, - acc_conf->q_fft.aq_depth_log2); -} - -static inline void -acc200_vf2pf(struct acc_device *d, unsigned int payload) -{ - acc_reg_write(d, HWVfHiVfToPfDbellVf, payload); -} - -/* Request device status information. */ -static inline uint32_t -acc200_device_status(struct rte_bbdev *dev) -{ - struct acc_device *d = dev->data->dev_private; - uint32_t reg, time_out = 0; - - if (d->pf_device) - return RTE_BBDEV_DEV_NOT_SUPPORTED; - - acc200_vf2pf(d, ACC_VF2PF_STATUS_REQUEST); - reg = acc_reg_read(d, HWVfHiPfToVfDbellVf); - while ((time_out < ACC200_STATUS_TO) && (reg == RTE_BBDEV_DEV_NOSTATUS)) { - usleep(ACC200_STATUS_WAIT); /*< Wait or VF->PF->VF Comms */ - reg = acc_reg_read(d, HWVfHiPfToVfDbellVf); - time_out++; - } - - return reg; -} - -/* Checks PF Info Ring to find the interrupt cause and handles it accordingly. */ -static inline void -acc200_check_ir(struct acc_device *acc200_dev) -{ - volatile union acc_info_ring_data *ring_data; - uint16_t info_ring_head = acc200_dev->info_ring_head; - if (unlikely(acc200_dev->info_ring == NULL)) - return; - - ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head & ACC_INFO_RING_MASK); - - while (ring_data->valid) { - if ((ring_data->int_nb < ACC200_PF_INT_DMA_DL_DESC_IRQ) || ( - ring_data->int_nb > ACC200_PF_INT_DMA_DL5G_DESC_IRQ)) { - rte_bbdev_log(WARNING, "InfoRing: ITR:%d Info:0x%x", - ring_data->int_nb, ring_data->detailed_info); - /* Initialize Info Ring entry and move forward. */ - ring_data->val = 0; - } - info_ring_head++; - ring_data = acc200_dev->info_ring + (info_ring_head & ACC_INFO_RING_MASK); - } -} - -/* Interrupt handler triggered by ACC200 dev for handling specific interrupt. */ -static void -acc200_dev_interrupt_handler(void *cb_arg) -{ - struct rte_bbdev *dev = cb_arg; - struct acc_device *acc200_dev = dev->data->dev_private; - volatile union acc_info_ring_data *ring_data; - struct acc_deq_intr_details deq_intr_det; - - ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head & ACC_INFO_RING_MASK); - - while (ring_data->valid) { - if (acc200_dev->pf_device) { - rte_bbdev_log_debug( - "ACC200 PF Interrupt received, Info Ring data: 0x%x -> %d", - ring_data->val, ring_data->int_nb); - - switch (ring_data->int_nb) { - case ACC200_PF_INT_DMA_DL_DESC_IRQ: - case ACC200_PF_INT_DMA_UL_DESC_IRQ: - case ACC200_PF_INT_DMA_FFT_DESC_IRQ: - case ACC200_PF_INT_DMA_UL5G_DESC_IRQ: - case ACC200_PF_INT_DMA_DL5G_DESC_IRQ: - deq_intr_det.queue_id = get_queue_id_from_ring_info( - dev->data, *ring_data); - if (deq_intr_det.queue_id == UINT16_MAX) { - rte_bbdev_log(ERR, - "Couldn't find queue: aq_id: %u, qg_id: %u, vf_id: %u", - ring_data->aq_id, - ring_data->qg_id, - ring_data->vf_id); - return; - } - rte_bbdev_pmd_callback_process(dev, - RTE_BBDEV_EVENT_DEQUEUE, &deq_intr_det); - break; - default: - rte_bbdev_pmd_callback_process(dev, RTE_BBDEV_EVENT_ERROR, NULL); - break; - } - } else { - rte_bbdev_log_debug( - "ACC200 VF Interrupt received, Info Ring data: 0x%x\n", - ring_data->val); - switch (ring_data->int_nb) { - case ACC200_VF_INT_DMA_DL_DESC_IRQ: - case ACC200_VF_INT_DMA_UL_DESC_IRQ: - case ACC200_VF_INT_DMA_FFT_DESC_IRQ: - case ACC200_VF_INT_DMA_UL5G_DESC_IRQ: - case ACC200_VF_INT_DMA_DL5G_DESC_IRQ: - /* VFs are not aware of their vf_id - it's set to 0. */ - ring_data->vf_id = 0; - deq_intr_det.queue_id = get_queue_id_from_ring_info( - dev->data, *ring_data); - if (deq_intr_det.queue_id == UINT16_MAX) { - rte_bbdev_log(ERR, - "Couldn't find queue: aq_id: %u, qg_id: %u", - ring_data->aq_id, - ring_data->qg_id); - return; - } - rte_bbdev_pmd_callback_process(dev, - RTE_BBDEV_EVENT_DEQUEUE, &deq_intr_det); - break; - default: - rte_bbdev_pmd_callback_process(dev, RTE_BBDEV_EVENT_ERROR, NULL); - break; - } - } - - /* Initialize Info Ring entry and move forward. */ - ring_data->val = 0; - ++acc200_dev->info_ring_head; - ring_data = acc200_dev->info_ring + - (acc200_dev->info_ring_head & ACC_INFO_RING_MASK); - } -} - -/* Allocate and setup inforing. */ -static int -allocate_info_ring(struct rte_bbdev *dev) -{ - struct acc_device *d = dev->data->dev_private; - const struct acc200_registry_addr *reg_addr; - rte_iova_t info_ring_iova; - uint32_t phys_low, phys_high; - - if (d->info_ring != NULL) - return 0; /* Already configured. */ - - /* Choose correct registry addresses for the device type. */ - if (d->pf_device) - reg_addr = &pf_reg_addr; - else - reg_addr = &vf_reg_addr; - /* Allocate InfoRing */ - d->info_ring = rte_zmalloc_socket("Info Ring", ACC_INFO_RING_NUM_ENTRIES * - sizeof(*d->info_ring), RTE_CACHE_LINE_SIZE, dev->data->socket_id); - if (d->info_ring == NULL) { - rte_bbdev_log(ERR, - "Failed to allocate Info Ring for %s:%u", - dev->device->driver->name, - dev->data->dev_id); - return -ENOMEM; - } - info_ring_iova = rte_malloc_virt2iova(d->info_ring); - - /* Setup Info Ring. */ - phys_high = (uint32_t)(info_ring_iova >> 32); - phys_low = (uint32_t)(info_ring_iova); - acc_reg_write(d, reg_addr->info_ring_hi, phys_high); - acc_reg_write(d, reg_addr->info_ring_lo, phys_low); - acc_reg_write(d, reg_addr->info_ring_en, ACC200_REG_IRQ_EN_ALL); - d->info_ring_head = (acc_reg_read(d, reg_addr->info_ring_ptr) & - 0xFFF) / sizeof(union acc_info_ring_data); - return 0; -} - - -/* Allocate 64MB memory used for all software rings. */ -static int -acc200_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id) -{ - uint32_t phys_low, phys_high, value; - struct acc_device *d = dev->data->dev_private; - const struct acc200_registry_addr *reg_addr; - int ret; - - if (d->pf_device && !d->acc_conf.pf_mode_en) { - rte_bbdev_log(NOTICE, - "%s has PF mode disabled. This PF can't be used.", - dev->data->name); - return -ENODEV; - } - if (!d->pf_device && d->acc_conf.pf_mode_en) { - rte_bbdev_log(NOTICE, - "%s has PF mode enabled. This VF can't be used.", - dev->data->name); - return -ENODEV; - } - - if (!acc200_check_device_enable(dev)) { - rte_bbdev_log(NOTICE, "%s has no queue enabled and can't be used.", - dev->data->name); - return -ENODEV; - } - - alloc_sw_rings_min_mem(dev, d, num_queues, socket_id); - - /* If minimal memory space approach failed, then allocate - * the 2 * 64MB block for the sw rings. - */ - if (d->sw_rings == NULL) - alloc_2x64mb_sw_rings_mem(dev, d, socket_id); - - if (d->sw_rings == NULL) { - rte_bbdev_log(NOTICE, - "Failure allocating sw_rings memory"); - return -ENOMEM; - } - - /* Configure ACC200 with the base address for DMA descriptor rings. - * Same descriptor rings used for UL and DL DMA Engines. - * Note : Assuming only VF0 bundle is used for PF mode. - */ - phys_high = (uint32_t)(d->sw_rings_iova >> 32); - phys_low = (uint32_t)(d->sw_rings_iova & ~(ACC_SIZE_64MBYTE-1)); - - /* Choose correct registry addresses for the device type. */ - if (d->pf_device) - reg_addr = &pf_reg_addr; - else - reg_addr = &vf_reg_addr; - - /* Read the populated cfg from ACC200 registers. */ - fetch_acc200_config(dev); - - /* Start Pmon */ - for (value = 0; value <= 2; value++) { - acc_reg_write(d, reg_addr->pmon_ctrl_a, value); - acc_reg_write(d, reg_addr->pmon_ctrl_b, value); - acc_reg_write(d, reg_addr->pmon_ctrl_c, value); - } - - /* Release AXI from PF. */ - if (d->pf_device) - acc_reg_write(d, HWPfDmaAxiControl, 1); - - acc_reg_write(d, reg_addr->dma_ring_ul5g_hi, phys_high); - acc_reg_write(d, reg_addr->dma_ring_ul5g_lo, phys_low); - acc_reg_write(d, reg_addr->dma_ring_dl5g_hi, phys_high); - acc_reg_write(d, reg_addr->dma_ring_dl5g_lo, phys_low); - acc_reg_write(d, reg_addr->dma_ring_ul4g_hi, phys_high); - acc_reg_write(d, reg_addr->dma_ring_ul4g_lo, phys_low); - acc_reg_write(d, reg_addr->dma_ring_dl4g_hi, phys_high); - acc_reg_write(d, reg_addr->dma_ring_dl4g_lo, phys_low); - acc_reg_write(d, reg_addr->dma_ring_fft_hi, phys_high); - acc_reg_write(d, reg_addr->dma_ring_fft_lo, phys_low); - /* - * Configure Ring Size to the max queue ring size - * (used for wrapping purpose). - */ - value = log2_basic(d->sw_ring_size / ACC_RING_SIZE_GRANULARITY); - acc_reg_write(d, reg_addr->ring_size, value); - - /* Configure tail pointer for use when SDONE enabled. */ - if (d->tail_ptrs == NULL) - d->tail_ptrs = rte_zmalloc_socket( - dev->device->driver->name, - ACC200_NUM_QGRPS * ACC200_NUM_AQS * sizeof(uint32_t), - RTE_CACHE_LINE_SIZE, socket_id); - if (d->tail_ptrs == NULL) { - rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u", - dev->device->driver->name, - dev->data->dev_id); - ret = -ENOMEM; - goto free_sw_rings; - } - d->tail_ptr_iova = rte_malloc_virt2iova(d->tail_ptrs); - - phys_high = (uint32_t)(d->tail_ptr_iova >> 32); - phys_low = (uint32_t)(d->tail_ptr_iova); - acc_reg_write(d, reg_addr->tail_ptrs_ul5g_hi, phys_high); - acc_reg_write(d, reg_addr->tail_ptrs_ul5g_lo, phys_low); - acc_reg_write(d, reg_addr->tail_ptrs_dl5g_hi, phys_high); - acc_reg_write(d, reg_addr->tail_ptrs_dl5g_lo, phys_low); - acc_reg_write(d, reg_addr->tail_ptrs_ul4g_hi, phys_high); - acc_reg_write(d, reg_addr->tail_ptrs_ul4g_lo, phys_low); - acc_reg_write(d, reg_addr->tail_ptrs_dl4g_hi, phys_high); - acc_reg_write(d, reg_addr->tail_ptrs_dl4g_lo, phys_low); - acc_reg_write(d, reg_addr->tail_ptrs_fft_hi, phys_high); - acc_reg_write(d, reg_addr->tail_ptrs_fft_lo, phys_low); - - ret = allocate_info_ring(dev); - if (ret < 0) { - rte_bbdev_log(ERR, "Failed to allocate info_ring for %s:%u", - dev->device->driver->name, - dev->data->dev_id); - /* Continue */ - } - - if (d->harq_layout == NULL) - d->harq_layout = rte_zmalloc_socket("HARQ Layout", - ACC_HARQ_LAYOUT * sizeof(*d->harq_layout), - RTE_CACHE_LINE_SIZE, dev->data->socket_id); - if (d->harq_layout == NULL) { - rte_bbdev_log(ERR, "Failed to allocate harq_layout for %s:%u", - dev->device->driver->name, - dev->data->dev_id); - ret = -ENOMEM; - goto free_tail_ptrs; - } - - /* Mark as configured properly */ - d->configured = true; - acc200_vf2pf(d, ACC_VF2PF_USING_VF); - - rte_bbdev_log_debug( - "ACC200 (%s) configured sw_rings = %p, sw_rings_iova = %#" - PRIx64, dev->data->name, d->sw_rings, d->sw_rings_iova); - return 0; - -free_tail_ptrs: - rte_free(d->tail_ptrs); - d->tail_ptrs = NULL; -free_sw_rings: - rte_free(d->sw_rings_base); - d->sw_rings = NULL; - - return ret; -} - -static int -acc200_intr_enable(struct rte_bbdev *dev) -{ - int ret; - struct acc_device *d = dev->data->dev_private; - /* - * MSI/MSI-X are supported. - * Option controlled by vfio-intr through EAL parameter. - */ - if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSI) { - - ret = allocate_info_ring(dev); - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't allocate info ring for device: %s", - dev->data->name); - return ret; - } - ret = rte_intr_enable(dev->intr_handle); - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't enable interrupts for device: %s", - dev->data->name); - rte_free(d->info_ring); - return ret; - } - ret = rte_intr_callback_register(dev->intr_handle, - acc200_dev_interrupt_handler, dev); - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't register interrupt callback for device: %s", - dev->data->name); - rte_free(d->info_ring); - return ret; - } - - return 0; - } else if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX) { - int i, max_queues; - struct acc_device *acc200_dev = dev->data->dev_private; - - ret = allocate_info_ring(dev); - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't allocate info ring for device: %s", - dev->data->name); - return ret; - } - - if (acc200_dev->pf_device) - max_queues = ACC200_MAX_PF_MSIX; - else - max_queues = ACC200_MAX_VF_MSIX; - - if (rte_intr_efd_enable(dev->intr_handle, max_queues)) { - rte_bbdev_log(ERR, "Failed to create fds for %u queues", - dev->data->num_queues); - return -1; - } - - for (i = 0; i < max_queues; ++i) { - if (rte_intr_efds_index_set(dev->intr_handle, i, - rte_intr_fd_get(dev->intr_handle))) - return -rte_errno; - } - - if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec", - dev->data->num_queues)) { - rte_bbdev_log(ERR, "Failed to allocate %u vectors", - dev->data->num_queues); - return -ENOMEM; - } - - ret = rte_intr_enable(dev->intr_handle); - - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't enable interrupts for device: %s", - dev->data->name); - rte_free(d->info_ring); - return ret; - } - ret = rte_intr_callback_register(dev->intr_handle, - acc200_dev_interrupt_handler, dev); - if (ret < 0) { - rte_bbdev_log(ERR, - "Couldn't register interrupt callback for device: %s", - dev->data->name); - rte_free(d->info_ring); - return ret; - } - - return 0; - } - - rte_bbdev_log(ERR, "ACC200 (%s) supports only VFIO MSI/MSI-X interrupts\n", - dev->data->name); - return -ENOTSUP; -} - -/* Free memory used for software rings. */ -static int -acc200_dev_close(struct rte_bbdev *dev) -{ - struct acc_device *d = dev->data->dev_private; - acc200_check_ir(d); - if (d->sw_rings_base != NULL) { - rte_free(d->tail_ptrs); - rte_free(d->info_ring); - rte_free(d->sw_rings_base); - rte_free(d->harq_layout); - d->tail_ptrs = NULL; - d->info_ring = NULL; - d->sw_rings_base = NULL; - d->harq_layout = NULL; - } - /* Ensure all in flight HW transactions are completed. */ - usleep(ACC_LONG_WAIT); - return 0; -} - -/** - * Report a ACC200 queue index which is free. - * Return 0 to 16k for a valid queue_idx or -1 when no queue is available. - * Note : Only supporting VF0 Bundle for PF mode. - */ -static int -acc200_find_free_queue_idx(struct rte_bbdev *dev, - const struct rte_bbdev_queue_conf *conf) -{ - struct acc_device *d = dev->data->dev_private; - int op_2_acc[6] = {0, UL_4G, DL_4G, UL_5G, DL_5G, FFT}; - int acc = op_2_acc[conf->op_type]; - struct rte_acc_queue_topology *qtop = NULL; - uint16_t group_idx; - uint64_t aq_idx; - - qtopFromAcc(&qtop, acc, &(d->acc_conf)); - if (qtop == NULL) - return -1; - /* Identify matching QGroup Index which are sorted in priority order. */ - group_idx = qtop->first_qgroup_index + conf->priority; - if (group_idx >= ACC200_NUM_QGRPS || - conf->priority >= qtop->num_qgroups) { - rte_bbdev_log(INFO, "Invalid Priority on %s, priority %u", - dev->data->name, conf->priority); - return -1; - } - /* Find a free AQ_idx. */ - for (aq_idx = 0; aq_idx < qtop->num_aqs_per_groups; aq_idx++) { - if (((d->q_assigned_bit_map[group_idx] >> aq_idx) & 0x1) == 0) { - /* Mark the Queue as assigned. */ - d->q_assigned_bit_map[group_idx] |= (1 << aq_idx); - /* Report the AQ Index. */ - return (group_idx << ACC200_GRP_ID_SHIFT) + aq_idx; - } - } - rte_bbdev_log(INFO, "Failed to find free queue on %s, priority %u", - dev->data->name, conf->priority); - return -1; -} - -/* Setup ACC200 queue. */ -static int -acc200_queue_setup(struct rte_bbdev *dev, uint16_t queue_id, - const struct rte_bbdev_queue_conf *conf) -{ - struct acc_device *d = dev->data->dev_private; - struct acc_queue *q; - int16_t q_idx; - int ret; - - if (d == NULL) { - rte_bbdev_log(ERR, "Undefined device"); - return -ENODEV; - } - /* Allocate the queue data structure. */ - q = rte_zmalloc_socket(dev->device->driver->name, sizeof(*q), - RTE_CACHE_LINE_SIZE, conf->socket); - if (q == NULL) { - rte_bbdev_log(ERR, "Failed to allocate queue memory"); - return -ENOMEM; - } - - q->d = d; - q->ring_addr = RTE_PTR_ADD(d->sw_rings, (d->sw_ring_size * queue_id)); - q->ring_addr_iova = d->sw_rings_iova + (d->sw_ring_size * queue_id); - - /* Prepare the Ring with default descriptor format. */ - union acc_dma_desc *desc = NULL; - unsigned int desc_idx, b_idx; - int fcw_len = (conf->op_type == RTE_BBDEV_OP_LDPC_ENC ? - ACC_FCW_LE_BLEN : (conf->op_type == RTE_BBDEV_OP_TURBO_DEC ? - ACC_FCW_TD_BLEN : (conf->op_type == RTE_BBDEV_OP_LDPC_DEC ? - ACC_FCW_LD_BLEN : ACC_FCW_FFT_BLEN))); - - for (desc_idx = 0; desc_idx < d->sw_ring_max_depth; desc_idx++) { - desc = q->ring_addr + desc_idx; - desc->req.word0 = ACC_DMA_DESC_TYPE; - desc->req.word1 = 0; /**< Timestamp. */ - desc->req.word2 = 0; - desc->req.word3 = 0; - uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET; - desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset; - desc->req.data_ptrs[0].blen = fcw_len; - desc->req.data_ptrs[0].blkid = ACC_DMA_BLKID_FCW; - desc->req.data_ptrs[0].last = 0; - desc->req.data_ptrs[0].dma_ext = 0; - for (b_idx = 1; b_idx < ACC_DMA_MAX_NUM_POINTERS - 1; - b_idx++) { - desc->req.data_ptrs[b_idx].blkid = ACC_DMA_BLKID_IN; - desc->req.data_ptrs[b_idx].last = 1; - desc->req.data_ptrs[b_idx].dma_ext = 0; - b_idx++; - desc->req.data_ptrs[b_idx].blkid = - ACC_DMA_BLKID_OUT_ENC; - desc->req.data_ptrs[b_idx].last = 1; - desc->req.data_ptrs[b_idx].dma_ext = 0; - } - /* Preset some fields of LDPC FCW. */ - desc->req.fcw_ld.FCWversion = ACC_FCW_VER; - desc->req.fcw_ld.gain_i = 1; - desc->req.fcw_ld.gain_h = 1; - } - - q->lb_in = rte_zmalloc_socket(dev->device->driver->name, - RTE_CACHE_LINE_SIZE, - RTE_CACHE_LINE_SIZE, conf->socket); - if (q->lb_in == NULL) { - rte_bbdev_log(ERR, "Failed to allocate lb_in memory"); - ret = -ENOMEM; - goto free_q; - } - q->lb_in_addr_iova = rte_malloc_virt2iova(q->lb_in); - q->lb_out = rte_zmalloc_socket(dev->device->driver->name, - RTE_CACHE_LINE_SIZE, - RTE_CACHE_LINE_SIZE, conf->socket); - if (q->lb_out == NULL) { - rte_bbdev_log(ERR, "Failed to allocate lb_out memory"); - ret = -ENOMEM; - goto free_lb_in; - } - q->lb_out_addr_iova = rte_malloc_virt2iova(q->lb_out); - q->companion_ring_addr = rte_zmalloc_socket(dev->device->driver->name, - d->sw_ring_max_depth * sizeof(*q->companion_ring_addr), - RTE_CACHE_LINE_SIZE, conf->socket); - if (q->companion_ring_addr == NULL) { - rte_bbdev_log(ERR, "Failed to allocate companion_ring memory"); - ret = -ENOMEM; - goto free_lb_out; - } - - /* - * Software queue ring wraps synchronously with the HW when it reaches - * the boundary of the maximum allocated queue size, no matter what the - * sw queue size is. This wrapping is guarded by setting the wrap_mask - * to represent the maximum queue size as allocated at the time when - * the device has been setup (in configure()). - * - * The queue depth is set to the queue size value (conf->queue_size). - * This limits the occupancy of the queue at any point of time, so that - * the queue does not get swamped with enqueue requests. - */ - q->sw_ring_depth = conf->queue_size; - q->sw_ring_wrap_mask = d->sw_ring_max_depth - 1; - - q->op_type = conf->op_type; - - q_idx = acc200_find_free_queue_idx(dev, conf); - if (q_idx == -1) { - ret = -EINVAL; - goto free_companion_ring_addr; - } - - q->qgrp_id = (q_idx >> ACC200_GRP_ID_SHIFT) & 0xF; - q->vf_id = (q_idx >> ACC200_VF_ID_SHIFT) & 0x3F; - q->aq_id = q_idx & 0xF; - q->aq_depth = 0; - if (conf->op_type == RTE_BBDEV_OP_TURBO_DEC) - q->aq_depth = (1 << d->acc_conf.q_ul_4g.aq_depth_log2); - else if (conf->op_type == RTE_BBDEV_OP_TURBO_ENC) - q->aq_depth = (1 << d->acc_conf.q_dl_4g.aq_depth_log2); - else if (conf->op_type == RTE_BBDEV_OP_LDPC_DEC) - q->aq_depth = (1 << d->acc_conf.q_ul_5g.aq_depth_log2); - else if (conf->op_type == RTE_BBDEV_OP_LDPC_ENC) - q->aq_depth = (1 << d->acc_conf.q_dl_5g.aq_depth_log2); - else if (conf->op_type == RTE_BBDEV_OP_FFT) - q->aq_depth = (1 << d->acc_conf.q_fft.aq_depth_log2); - - q->mmio_reg_enqueue = RTE_PTR_ADD(d->mmio_base, - queue_offset(d->pf_device, - q->vf_id, q->qgrp_id, q->aq_id)); - - rte_bbdev_log_debug( - "Setup dev%u q%u: qgrp_id=%u, vf_id=%u, aq_id=%u, aq_depth=%u, mmio_reg_enqueue=%p base %p\n", - dev->data->dev_id, queue_id, q->qgrp_id, q->vf_id, - q->aq_id, q->aq_depth, q->mmio_reg_enqueue, - d->mmio_base); - - dev->data->queues[queue_id].queue_private = q; - return 0; - -free_companion_ring_addr: - rte_free(q->companion_ring_addr); - q->companion_ring_addr = NULL; -free_lb_out: - rte_free(q->lb_out); - q->lb_out = NULL; -free_lb_in: - rte_free(q->lb_in); - q->lb_in = NULL; -free_q: - rte_free(q); - q = NULL; - - return ret; -} - -static inline void -acc200_print_op(struct rte_bbdev_dec_op *op, enum rte_bbdev_op_type op_type, - uint16_t index) -{ - if (op == NULL) - return; - if (op_type == RTE_BBDEV_OP_LDPC_DEC) - rte_bbdev_log(INFO, - " Op 5GUL %d %d %d %d %d %d %d %d %d %d %d %d", - index, - op->ldpc_dec.basegraph, op->ldpc_dec.z_c, - op->ldpc_dec.n_cb, op->ldpc_dec.q_m, - op->ldpc_dec.n_filler, op->ldpc_dec.cb_params.e, - op->ldpc_dec.op_flags, op->ldpc_dec.rv_index, - op->ldpc_dec.iter_max, op->ldpc_dec.iter_count, - op->ldpc_dec.harq_combined_input.length - ); - else if (op_type == RTE_BBDEV_OP_LDPC_ENC) { - struct rte_bbdev_enc_op *op_dl = (struct rte_bbdev_enc_op *) op; - rte_bbdev_log(INFO, - " Op 5GDL %d %d %d %d %d %d %d %d %d", - index, - op_dl->ldpc_enc.basegraph, op_dl->ldpc_enc.z_c, - op_dl->ldpc_enc.n_cb, op_dl->ldpc_enc.q_m, - op_dl->ldpc_enc.n_filler, op_dl->ldpc_enc.cb_params.e, - op_dl->ldpc_enc.op_flags, op_dl->ldpc_enc.rv_index - ); - } -} - -/* Stop ACC200 queue and clear counters. */ -static int -acc200_queue_stop(struct rte_bbdev *dev, uint16_t queue_id) -{ - struct acc_queue *q; - struct rte_bbdev_dec_op *op; - uint16_t i; - q = dev->data->queues[queue_id].queue_private; - rte_bbdev_log(INFO, "Queue Stop %d H/T/D %d %d %x OpType %d", - queue_id, q->sw_ring_head, q->sw_ring_tail, - q->sw_ring_depth, q->op_type); - for (i = 0; i < q->sw_ring_depth; ++i) { - op = (q->ring_addr + i)->req.op_addr; - acc200_print_op(op, q->op_type, i); - } - /* ignore all operations in flight and clear counters */ - q->sw_ring_tail = q->sw_ring_head; - q->aq_enqueued = 0; - q->aq_dequeued = 0; - dev->data->queues[queue_id].queue_stats.enqueued_count = 0; - dev->data->queues[queue_id].queue_stats.dequeued_count = 0; - dev->data->queues[queue_id].queue_stats.enqueue_err_count = 0; - dev->data->queues[queue_id].queue_stats.dequeue_err_count = 0; - dev->data->queues[queue_id].queue_stats.enqueue_warn_count = 0; - dev->data->queues[queue_id].queue_stats.dequeue_warn_count = 0; - return 0; -} - -/* Release ACC200 queue. */ -static int -acc200_queue_release(struct rte_bbdev *dev, uint16_t q_id) -{ - struct acc_device *d = dev->data->dev_private; - struct acc_queue *q = dev->data->queues[q_id].queue_private; - - if (q != NULL) { - /* Mark the Queue as un-assigned. */ - d->q_assigned_bit_map[q->qgrp_id] &= (~0ULL - (1 << (uint64_t) q->aq_id)); - rte_free(q->companion_ring_addr); - rte_free(q->lb_in); - rte_free(q->lb_out); - rte_free(q); - dev->data->queues[q_id].queue_private = NULL; - } - - return 0; -} - -/* Get ACC200 device info. */ -static void -acc200_dev_info_get(struct rte_bbdev *dev, - struct rte_bbdev_driver_info *dev_info) -{ - struct acc_device *d = dev->data->dev_private; - int i; - static const struct rte_bbdev_op_cap bbdev_capabilities[] = { - { - .type = RTE_BBDEV_OP_TURBO_DEC, - .cap.turbo_dec = { - .capability_flags = - RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE | - RTE_BBDEV_TURBO_CRC_TYPE_24B | - RTE_BBDEV_TURBO_EQUALIZER | - RTE_BBDEV_TURBO_SOFT_OUT_SATURATE | - RTE_BBDEV_TURBO_HALF_ITERATION_EVEN | - RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH | - RTE_BBDEV_TURBO_SOFT_OUTPUT | - RTE_BBDEV_TURBO_EARLY_TERMINATION | - RTE_BBDEV_TURBO_DEC_INTERRUPTS | - RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN | - RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT | - RTE_BBDEV_TURBO_MAP_DEC | - RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | - RTE_BBDEV_TURBO_DEC_SCATTER_GATHER, - .max_llr_modulus = INT8_MAX, - .num_buffers_src = - RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, - .num_buffers_hard_out = - RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, - .num_buffers_soft_out = - RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, - } - }, - { - .type = RTE_BBDEV_OP_TURBO_ENC, - .cap.turbo_enc = { - .capability_flags = - RTE_BBDEV_TURBO_CRC_24B_ATTACH | - RTE_BBDEV_TURBO_RV_INDEX_BYPASS | - RTE_BBDEV_TURBO_RATE_MATCH | - RTE_BBDEV_TURBO_ENC_INTERRUPTS | - RTE_BBDEV_TURBO_ENC_SCATTER_GATHER, - .num_buffers_src = - RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, - .num_buffers_dst = - RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, - } - }, - { - .type = RTE_BBDEV_OP_LDPC_ENC, - .cap.ldpc_enc = { - .capability_flags = - RTE_BBDEV_LDPC_RATE_MATCH | - RTE_BBDEV_LDPC_CRC_24B_ATTACH | - RTE_BBDEV_LDPC_INTERLEAVER_BYPASS | - RTE_BBDEV_LDPC_ENC_INTERRUPTS, - .num_buffers_src = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - .num_buffers_dst = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - } - }, - { - .type = RTE_BBDEV_OP_LDPC_DEC, - .cap.ldpc_dec = { - .capability_flags = - RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK | - RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP | - RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK | - RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK | - RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE | - RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE | - RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE | - RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS | - RTE_BBDEV_LDPC_DEC_SCATTER_GATHER | - RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION | - RTE_BBDEV_LDPC_LLR_COMPRESSION | - RTE_BBDEV_LDPC_DEC_INTERRUPTS, - .llr_size = 8, - .llr_decimals = 1, - .num_buffers_src = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - .num_buffers_hard_out = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - .num_buffers_soft_out = 0, - } - }, - { - .type = RTE_BBDEV_OP_FFT, - .cap.fft = { - .capability_flags = - RTE_BBDEV_FFT_WINDOWING | - RTE_BBDEV_FFT_CS_ADJUSTMENT | - RTE_BBDEV_FFT_DFT_BYPASS | - RTE_BBDEV_FFT_IDFT_BYPASS | - RTE_BBDEV_FFT_WINDOWING_BYPASS, - .num_buffers_src = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - .num_buffers_dst = - RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, - } - }, - RTE_BBDEV_END_OF_CAPABILITIES_LIST() - }; - - static struct rte_bbdev_queue_conf default_queue_conf; - default_queue_conf.socket = dev->data->socket_id; - default_queue_conf.queue_size = ACC_MAX_QUEUE_DEPTH; - - dev_info->driver_name = dev->device->driver->name; - - /* Read and save the populated config from ACC200 registers. */ - fetch_acc200_config(dev); - /* Check the status of device. */ - dev_info->device_status = acc200_device_status(dev); - - /* Exposed number of queues. */ - dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0; - dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = d->acc_conf.q_ul_4g.num_aqs_per_groups * - d->acc_conf.q_ul_4g.num_qgroups; - dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = d->acc_conf.q_dl_4g.num_aqs_per_groups * - d->acc_conf.q_dl_4g.num_qgroups; - dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_aqs_per_groups * - d->acc_conf.q_ul_5g.num_qgroups; - dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_aqs_per_groups * - d->acc_conf.q_dl_5g.num_qgroups; - dev_info->num_queues[RTE_BBDEV_OP_FFT] = d->acc_conf.q_fft.num_aqs_per_groups * - d->acc_conf.q_fft.num_qgroups; - dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d->acc_conf.q_ul_4g.num_qgroups; - dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = d->acc_conf.q_dl_4g.num_qgroups; - dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_qgroups; - dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_qgroups; - dev_info->queue_priority[RTE_BBDEV_OP_FFT] = d->acc_conf.q_fft.num_qgroups; - dev_info->max_num_queues = 0; - for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++) - dev_info->max_num_queues += dev_info->num_queues[i]; - dev_info->queue_size_lim = ACC_MAX_QUEUE_DEPTH; - dev_info->hardware_accelerated = true; - dev_info->max_dl_queue_priority = - d->acc_conf.q_dl_4g.num_qgroups - 1; - dev_info->max_ul_queue_priority = - d->acc_conf.q_ul_4g.num_qgroups - 1; - dev_info->default_queue_conf = default_queue_conf; - dev_info->cpu_flag_reqs = NULL; - dev_info->min_alignment = 1; - dev_info->capabilities = bbdev_capabilities; - dev_info->harq_buffer_size = 0; - - acc200_check_ir(d); -} - -static int -acc200_queue_intr_enable(struct rte_bbdev *dev, uint16_t queue_id) -{ - struct acc_queue *q = dev->data->queues[queue_id].queue_private; - - if (rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSI && - rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSIX) - return -ENOTSUP; - - q->irq_enable = 1; - return 0; -} - -static int -acc200_queue_intr_disable(struct rte_bbdev *dev, uint16_t queue_id) -{ - struct acc_queue *q = dev->data->queues[queue_id].queue_private; - - if (rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSI && - rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSIX) - return -ENOTSUP; - - q->irq_enable = 0; - return 0; -} - -static const struct rte_bbdev_ops acc200_bbdev_ops = { - .setup_queues = acc200_setup_queues, - .intr_enable = acc200_intr_enable, - .close = acc200_dev_close, - .info_get = acc200_dev_info_get, - .queue_setup = acc200_queue_setup, - .queue_release = acc200_queue_release, - .queue_stop = acc200_queue_stop, - .queue_intr_enable = acc200_queue_intr_enable, - .queue_intr_disable = acc200_queue_intr_disable -}; - -/* ACC200 PCI PF address map. */ -static struct rte_pci_id pci_id_acc200_pf_map[] = { - { - RTE_PCI_DEVICE(RTE_ACC200_VENDOR_ID, RTE_ACC200_PF_DEVICE_ID) - }, - {.device_id = 0}, -}; - -/* ACC200 PCI VF address map. */ -static struct rte_pci_id pci_id_acc200_vf_map[] = { - { - RTE_PCI_DEVICE(RTE_ACC200_VENDOR_ID, RTE_ACC200_VF_DEVICE_ID) - }, - {.device_id = 0}, -}; - -/* Fill in a frame control word for turbo decoding. */ -static inline void -acc200_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw) -{ - fcw->fcw_ver = 1; - fcw->num_maps = ACC_FCW_TD_AUTOMAP; - fcw->bypass_sb_deint = !check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE); - if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { - /* FIXME for TB block */ - fcw->k_pos = op->turbo_dec.tb_params.k_pos; - fcw->k_neg = op->turbo_dec.tb_params.k_neg; - } else { - fcw->k_pos = op->turbo_dec.cb_params.k; - fcw->k_neg = op->turbo_dec.cb_params.k; - } - fcw->c = 1; - fcw->c_neg = 1; - if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) { - fcw->soft_output_en = 1; - fcw->sw_soft_out_dis = 0; - fcw->sw_et_cont = check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH); - fcw->sw_soft_out_saturation = check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_SOFT_OUT_SATURATE); - if (check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_EQUALIZER)) { - fcw->bypass_teq = 0; - fcw->ea = op->turbo_dec.cb_params.e; - fcw->eb = op->turbo_dec.cb_params.e; - if (op->turbo_dec.rv_index == 0) - fcw->k0_start_col = ACC_FCW_TD_RVIDX_0; - else if (op->turbo_dec.rv_index == 1) - fcw->k0_start_col = ACC_FCW_TD_RVIDX_1; - else if (op->turbo_dec.rv_index == 2) - fcw->k0_start_col = ACC_FCW_TD_RVIDX_2; - else - fcw->k0_start_col = ACC_FCW_TD_RVIDX_3; - } else { - fcw->bypass_teq = 1; - fcw->eb = 64; /* avoid undefined value */ - } - } else { - fcw->soft_output_en = 0; - fcw->sw_soft_out_dis = 1; - fcw->bypass_teq = 0; - } - - fcw->code_block_mode = 1; /* FIXME */ - fcw->turbo_crc_type = check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_CRC_TYPE_24B); - - fcw->ext_td_cold_reg_en = 1; - fcw->raw_decoder_input_on = 0; - fcw->max_iter = RTE_MAX((uint8_t) op->turbo_dec.iter_max, 2); - fcw->min_iter = 2; - fcw->half_iter_on = check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_HALF_ITERATION_EVEN); - - fcw->early_stop_en = check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_EARLY_TERMINATION) & !fcw->soft_output_en; - fcw->ext_scale = 0xF; -} - -/* Fill in a frame control word for LDPC decoding. */ -static inline void -acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld *fcw, - union acc_harq_layout_data *harq_layout) -{ - uint16_t harq_out_length, harq_in_length, ncb_p, k0_p, parity_offset; - uint32_t harq_index; - uint32_t l; - - fcw->qm = op->ldpc_dec.q_m; - fcw->nfiller = op->ldpc_dec.n_filler; - fcw->BG = (op->ldpc_dec.basegraph - 1); - fcw->Zc = op->ldpc_dec.z_c; - fcw->ncb = op->ldpc_dec.n_cb; - fcw->k0 = get_k0(fcw->ncb, fcw->Zc, op->ldpc_dec.basegraph, - op->ldpc_dec.rv_index); - if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK) - fcw->rm_e = op->ldpc_dec.cb_params.e; - else - fcw->rm_e = (op->ldpc_dec.tb_params.r < - op->ldpc_dec.tb_params.cab) ? - op->ldpc_dec.tb_params.ea : - op->ldpc_dec.tb_params.eb; - - if (unlikely(check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) && - (op->ldpc_dec.harq_combined_input.length == 0))) { - rte_bbdev_log(WARNING, "Null HARQ input size provided"); - /* Disable HARQ input in that case to carry forward. */ - op->ldpc_dec.op_flags ^= RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE; - } - if (unlikely(fcw->rm_e == 0)) { - rte_bbdev_log(WARNING, "Null E input provided"); - fcw->rm_e = 2; - } - - fcw->hcin_en = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE); - fcw->hcout_en = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE); - fcw->crc_select = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK); - fcw->bypass_dec = 0; - fcw->bypass_intlv = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS); - if (op->ldpc_dec.q_m == 1) { - fcw->bypass_intlv = 1; - fcw->qm = 2; - } - fcw->hcin_decomp_mode = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION); - fcw->hcout_comp_mode = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION); - fcw->llr_pack_mode = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_LLR_COMPRESSION); - harq_index = hq_index(op->ldpc_dec.harq_combined_output.offset); - - if (fcw->hcin_en > 0) { - harq_in_length = op->ldpc_dec.harq_combined_input.length; - if (fcw->hcin_decomp_mode > 0) - harq_in_length = harq_in_length * 8 / 6; - harq_in_length = RTE_MIN(harq_in_length, op->ldpc_dec.n_cb - - op->ldpc_dec.n_filler); - harq_in_length = RTE_ALIGN_CEIL(harq_in_length, 64); - fcw->hcin_size0 = harq_in_length; - fcw->hcin_offset = 0; - fcw->hcin_size1 = 0; - } else { - fcw->hcin_size0 = 0; - fcw->hcin_offset = 0; - fcw->hcin_size1 = 0; - } - - fcw->itmax = op->ldpc_dec.iter_max; - fcw->itstop = check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE); - fcw->cnu_algo = ACC_ALGO_MSA; - fcw->synd_precoder = fcw->itstop; - /* - * These are all implicitly set: - * fcw->synd_post = 0; - * fcw->so_en = 0; - * fcw->so_bypass_rm = 0; - * fcw->so_bypass_intlv = 0; - * fcw->dec_convllr = 0; - * fcw->hcout_convllr = 0; - * fcw->hcout_size1 = 0; - * fcw->so_it = 0; - * fcw->hcout_offset = 0; - * fcw->negstop_th = 0; - * fcw->negstop_it = 0; - * fcw->negstop_en = 0; - * fcw->gain_i = 1; - * fcw->gain_h = 1; - */ - if (fcw->hcout_en > 0) { - parity_offset = (op->ldpc_dec.basegraph == 1 ? 20 : 8) - * op->ldpc_dec.z_c - op->ldpc_dec.n_filler; - k0_p = (fcw->k0 > parity_offset) ? fcw->k0 - op->ldpc_dec.n_filler : fcw->k0; - ncb_p = fcw->ncb - op->ldpc_dec.n_filler; - l = k0_p + fcw->rm_e; - harq_out_length = (uint16_t) fcw->hcin_size0; - harq_out_length = RTE_MIN(RTE_MAX(harq_out_length, l), ncb_p); - harq_out_length = RTE_ALIGN_CEIL(harq_out_length, 64); - fcw->hcout_size0 = harq_out_length; - fcw->hcout_size1 = 0; - fcw->hcout_offset = 0; - harq_layout[harq_index].offset = fcw->hcout_offset; - harq_layout[harq_index].size0 = fcw->hcout_size0; - } else { - fcw->hcout_size0 = 0; - fcw->hcout_size1 = 0; - fcw->hcout_offset = 0; - } - - fcw->tb_crc_select = 0; - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) - fcw->tb_crc_select = 2; - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK)) - fcw->tb_crc_select = 1; -} - -static inline int -acc200_dma_desc_td_fill(struct rte_bbdev_dec_op *op, - struct acc_dma_req_desc *desc, struct rte_mbuf **input, - struct rte_mbuf *h_output, struct rte_mbuf *s_output, - uint32_t *in_offset, uint32_t *h_out_offset, - uint32_t *s_out_offset, uint32_t *h_out_length, - uint32_t *s_out_length, uint32_t *mbuf_total_left, - uint32_t *seg_total_left, uint8_t r) -{ - int next_triplet = 1; /* FCW already done. */ - uint16_t k; - uint16_t crc24_overlap = 0; - uint32_t e, kw; - - desc->word0 = ACC_DMA_DESC_TYPE; - desc->word1 = 0; /**< Timestamp could be disabled. */ - desc->word2 = 0; - desc->word3 = 0; - desc->numCBs = 1; - - if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) { - k = (r < op->turbo_dec.tb_params.c_neg) - ? op->turbo_dec.tb_params.k_neg - : op->turbo_dec.tb_params.k_pos; - e = (r < op->turbo_dec.tb_params.cab) - ? op->turbo_dec.tb_params.ea - : op->turbo_dec.tb_params.eb; - } else { - k = op->turbo_dec.cb_params.k; - e = op->turbo_dec.cb_params.e; - } - - if ((op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - && !check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP)) - crc24_overlap = 24; - - /* Calculates circular buffer size. - * According to 3gpp 36.212 section 5.1.4.2 - * Kw = 3 * Kpi, - * where: - * Kpi = nCol * nRow - * where nCol is 32 and nRow can be calculated from: - * D =< nCol * nRow - * where D is the size of each output from turbo encoder block (k + 4). - */ - kw = RTE_ALIGN_CEIL(k + 4, 32) * 3; - - if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < kw))) { - rte_bbdev_log(ERR, - "Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u", - *mbuf_total_left, kw); - return -1; - } - - next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset, kw, - seg_total_left, next_triplet, - check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_DEC_SCATTER_GATHER)); - if (unlikely(next_triplet < 0)) { - rte_bbdev_log(ERR, - "Mismatch between data to process and mbuf data length in bbdev_op: %p", - op); - return -1; - } - desc->data_ptrs[next_triplet - 1].last = 1; - desc->m2dlen = next_triplet; - *mbuf_total_left -= kw; - *h_out_length = ((k - crc24_overlap) >> 3); - next_triplet = acc_dma_fill_blk_type( - desc, h_output, *h_out_offset, - *h_out_length, next_triplet, ACC_DMA_BLKID_OUT_HARD); - if (unlikely(next_triplet < 0)) { - rte_bbdev_log(ERR, - "Mismatch between data to process and mbuf data length in bbdev_op: %p", - op); - return -1; - } - - op->turbo_dec.hard_output.length += *h_out_length; - *h_out_offset += *h_out_length; - - /* Soft output. */ - if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) { - if (op->turbo_dec.soft_output.data == 0) { - rte_bbdev_log(ERR, "Soft output is not defined"); - return -1; - } - if (check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_EQUALIZER)) - *s_out_length = e; - else - *s_out_length = (k * 3) + 12; - - next_triplet = acc_dma_fill_blk_type(desc, s_output, - *s_out_offset, *s_out_length, next_triplet, - ACC_DMA_BLKID_OUT_SOFT); - if (unlikely(next_triplet < 0)) { - rte_bbdev_log(ERR, - "Mismatch between data to process and mbuf data length in bbdev_op: %p", - op); - return -1; - } - - op->turbo_dec.soft_output.length += *s_out_length; - *s_out_offset += *s_out_length; - } - - desc->data_ptrs[next_triplet - 1].last = 1; - desc->d2mlen = next_triplet - desc->m2dlen; - - desc->op_addr = op; - - return 0; -} - -static inline int -acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op, - struct acc_dma_req_desc *desc, - struct rte_mbuf **input, struct rte_mbuf *h_output, - uint32_t *in_offset, uint32_t *h_out_offset, - uint32_t *h_out_length, uint32_t *mbuf_total_left, - uint32_t *seg_total_left, struct acc_fcw_ld *fcw) -{ - struct rte_bbdev_op_ldpc_dec *dec = &op->ldpc_dec; - int next_triplet = 1; /* FCW already done. */ - uint32_t input_length; - uint16_t output_length, crc24_overlap = 0; - uint16_t sys_cols, K, h_p_size, h_np_size; - bool h_comp = check_bit(dec->op_flags, RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION); - - acc_header_init(desc); - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP)) - crc24_overlap = 24; - - /* Compute some LDPC BG lengths. */ - input_length = fcw->rm_e; - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_LLR_COMPRESSION)) - input_length = (input_length * 3 + 3) / 4; - sys_cols = (dec->basegraph == 1) ? 22 : 10; - K = sys_cols * dec->z_c; - output_length = K - dec->n_filler - crc24_overlap; - - if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < input_length))) { - rte_bbdev_log(ERR, - "Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u", - *mbuf_total_left, input_length); - return -1; - } - - next_triplet = acc_dma_fill_blk_type_in(desc, input, - in_offset, input_length, - seg_total_left, next_triplet, - check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)); - - if (unlikely(next_triplet < 0)) { - rte_bbdev_log(ERR, - "Mismatch between data to process and mbuf data length in bbdev_op: %p", - op); - return -1; - } - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) { - if (op->ldpc_dec.harq_combined_input.data == 0) { - rte_bbdev_log(ERR, "HARQ input is not defined"); - return -1; - } - h_p_size = fcw->hcin_size0 + fcw->hcin_size1; - if (h_comp) - h_p_size = (h_p_size * 3 + 3) / 4; - if (op->ldpc_dec.harq_combined_input.data == 0) { - rte_bbdev_log(ERR, "HARQ input is not defined"); - return -1; - } - acc_dma_fill_blk_type( - desc, - op->ldpc_dec.harq_combined_input.data, - op->ldpc_dec.harq_combined_input.offset, - h_p_size, - next_triplet, - ACC_DMA_BLKID_IN_HARQ); - next_triplet++; - } - - desc->data_ptrs[next_triplet - 1].last = 1; - desc->m2dlen = next_triplet; - *mbuf_total_left -= input_length; - - next_triplet = acc_dma_fill_blk_type(desc, h_output, - *h_out_offset, output_length >> 3, next_triplet, - ACC_DMA_BLKID_OUT_HARD); - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) { - if (op->ldpc_dec.harq_combined_output.data == 0) { - rte_bbdev_log(ERR, "HARQ output is not defined"); - return -1; - } - - /* Pruned size of the HARQ. */ - h_p_size = fcw->hcout_size0 + fcw->hcout_size1; - /* Non-Pruned size of the HARQ. */ - h_np_size = fcw->hcout_offset > 0 ? - fcw->hcout_offset + fcw->hcout_size1 : - h_p_size; - if (h_comp) { - h_np_size = (h_np_size * 3 + 3) / 4; - h_p_size = (h_p_size * 3 + 3) / 4; - } - dec->harq_combined_output.length = h_np_size; - acc_dma_fill_blk_type( - desc, - dec->harq_combined_output.data, - dec->harq_combined_output.offset, - h_p_size, - next_triplet, - ACC_DMA_BLKID_OUT_HARQ); - - next_triplet++; - } - - *h_out_length = output_length >> 3; - dec->hard_output.length += *h_out_length; - *h_out_offset += *h_out_length; - desc->data_ptrs[next_triplet - 1].last = 1; - desc->d2mlen = next_triplet - desc->m2dlen; - - desc->op_addr = op; - - return 0; -} - -static inline void -acc200_dma_desc_ld_update(struct rte_bbdev_dec_op *op, - struct acc_dma_req_desc *desc, - struct rte_mbuf *input, struct rte_mbuf *h_output, - uint32_t *in_offset, uint32_t *h_out_offset, - uint32_t *h_out_length, - union acc_harq_layout_data *harq_layout) -{ - int next_triplet = 1; /* FCW already done. */ - desc->data_ptrs[next_triplet].address = rte_pktmbuf_iova_offset(input, *in_offset); - next_triplet++; - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) { - struct rte_bbdev_op_data hi = op->ldpc_dec.harq_combined_input; - desc->data_ptrs[next_triplet].address = - rte_pktmbuf_iova_offset(hi.data, hi.offset); - next_triplet++; - } - - desc->data_ptrs[next_triplet].address = - rte_pktmbuf_iova_offset(h_output, *h_out_offset); - *h_out_length = desc->data_ptrs[next_triplet].blen; - next_triplet++; - - if (check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) { - /* Adjust based on previous operation. */ - struct rte_bbdev_dec_op *prev_op = desc->op_addr; - op->ldpc_dec.harq_combined_output.length = - prev_op->ldpc_dec.harq_combined_output.length; - uint32_t harq_idx = hq_index(op->ldpc_dec.harq_combined_output.offset); - uint32_t prev_harq_idx = hq_index(prev_op->ldpc_dec.harq_combined_output.offset); - harq_layout[harq_idx].val = harq_layout[prev_harq_idx].val; - struct rte_bbdev_op_data ho = op->ldpc_dec.harq_combined_output; - desc->data_ptrs[next_triplet].address = - rte_pktmbuf_iova_offset(ho.data, ho.offset); - next_triplet++; - } - - op->ldpc_dec.hard_output.length += *h_out_length; - desc->op_addr = op; -} - -/* Enqueue one encode operations for ACC200 device in CB mode */ -static inline int -enqueue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op *op, - uint16_t total_enqueued_cbs) -{ - union acc_dma_desc *desc = NULL; - int ret; - uint32_t in_offset, out_offset, out_length, mbuf_total_left, seg_total_left; - struct rte_mbuf *input, *output_head, *output; - - desc = acc_desc(q, total_enqueued_cbs); - acc_fcw_te_fill(op, &desc->req.fcw_te); - - input = op->turbo_enc.input.data; - output_head = output = op->turbo_enc.output.data; - in_offset = op->turbo_enc.input.offset; - out_offset = op->turbo_enc.output.offset; - out_length = 0; - mbuf_total_left = op->turbo_enc.input.length; - seg_total_left = rte_pktmbuf_data_len(op->turbo_enc.input.data) - in_offset; - - ret = acc_dma_desc_te_fill(op, &desc->req, &input, output, - &in_offset, &out_offset, &out_length, &mbuf_total_left, - &seg_total_left, 0); - - if (unlikely(ret < 0)) - return ret; - - mbuf_append(output_head, output, out_length); - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_te, - sizeof(desc->req.fcw_te) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - /* One CB (one op) was successfully prepared to enqueue */ - return 1; -} - -/* Enqueue one encode operations for ACC200 device in CB mode - * multiplexed on the same descriptor. - */ -static inline int -enqueue_ldpc_enc_n_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ops, - uint16_t total_enqueued_descs, int16_t num) -{ - union acc_dma_desc *desc = NULL; - uint32_t out_length; - struct rte_mbuf *output_head, *output; - int i, next_triplet; - uint16_t in_length_in_bytes; - struct rte_bbdev_op_ldpc_enc *enc = &ops[0]->ldpc_enc; - struct acc_ptrs *context_ptrs; - - desc = acc_desc(q, total_enqueued_descs); - acc_fcw_le_fill(ops[0], &desc->req.fcw_le, num, 0); - - /** This could be done at polling. */ - acc_header_init(&desc->req); - desc->req.numCBs = num; - - in_length_in_bytes = ops[0]->ldpc_enc.input.data->data_len; - out_length = (enc->cb_params.e + 7) >> 3; - desc->req.m2dlen = 1 + num; - desc->req.d2mlen = num; - next_triplet = 1; - - for (i = 0; i < num; i++) { - desc->req.data_ptrs[next_triplet].address = - rte_pktmbuf_iova_offset(ops[i]->ldpc_enc.input.data, 0); - desc->req.data_ptrs[next_triplet].blen = in_length_in_bytes; - next_triplet++; - desc->req.data_ptrs[next_triplet].address = rte_pktmbuf_iova_offset( - ops[i]->ldpc_enc.output.data, 0); - desc->req.data_ptrs[next_triplet].blen = out_length; - next_triplet++; - ops[i]->ldpc_enc.output.length = out_length; - output_head = output = ops[i]->ldpc_enc.output.data; - mbuf_append(output_head, output, out_length); - output->data_len = out_length; - } - - desc->req.op_addr = ops[0]; - /* Keep track of pointers even when multiplexed in single descriptor. */ - context_ptrs = q->companion_ring_addr + acc_desc_idx(q, total_enqueued_descs); - for (i = 0; i < num; i++) - context_ptrs->ptr[i].op_addr = ops[i]; - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_le, - sizeof(desc->req.fcw_le) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - - /* Number of compatible CBs/ops successfully prepared to enqueue. */ - return num; -} - -/* Enqueue one encode operations for ACC200 device for a partial TB - * all codes blocks have same configuration multiplexed on the same descriptor. - */ -static inline void -enqueue_ldpc_enc_part_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, - uint16_t total_enqueued_descs, int16_t num_cbs, uint32_t e, - uint16_t in_len_B, uint32_t out_len_B, uint32_t *in_offset, - uint32_t *out_offset) -{ - - union acc_dma_desc *desc = NULL; - struct rte_mbuf *output_head, *output; - int i, next_triplet; - struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc; - - desc = acc_desc(q, total_enqueued_descs); - acc_fcw_le_fill(op, &desc->req.fcw_le, num_cbs, e); - - /** This could be done at polling. */ - acc_header_init(&desc->req); - desc->req.numCBs = num_cbs; - - desc->req.m2dlen = 1 + num_cbs; - desc->req.d2mlen = num_cbs; - next_triplet = 1; - - for (i = 0; i < num_cbs; i++) { - desc->req.data_ptrs[next_triplet].address = rte_pktmbuf_iova_offset( - enc->input.data, *in_offset); - *in_offset += in_len_B; - desc->req.data_ptrs[next_triplet].blen = in_len_B; - next_triplet++; - desc->req.data_ptrs[next_triplet].address = rte_pktmbuf_iova_offset( - enc->output.data, *out_offset); - *out_offset += out_len_B; - desc->req.data_ptrs[next_triplet].blen = out_len_B; - next_triplet++; - enc->output.length += out_len_B; - output_head = output = enc->output.data; - mbuf_append(output_head, output, out_len_B); - } - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_le, - sizeof(desc->req.fcw_le) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - -} - -/* Enqueue one encode operations for ACC200 device in TB mode. */ -static inline int -enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, - uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) -{ - union acc_dma_desc *desc = NULL; - int ret; - uint8_t r, c; - uint32_t in_offset, out_offset, out_length, mbuf_total_left, - seg_total_left; - struct rte_mbuf *input, *output_head, *output; - uint16_t desc_idx, current_enqueued_cbs = 0; - uint64_t fcw_offset; - - desc_idx = acc_desc_idx(q, total_enqueued_cbs); - desc = q->ring_addr + desc_idx; - fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET; - acc_fcw_te_fill(op, &desc->req.fcw_te); - - input = op->turbo_enc.input.data; - output_head = output = op->turbo_enc.output.data; - in_offset = op->turbo_enc.input.offset; - out_offset = op->turbo_enc.output.offset; - out_length = 0; - mbuf_total_left = op->turbo_enc.input.length; - - c = op->turbo_enc.tb_params.c; - r = op->turbo_enc.tb_params.r; - - while (mbuf_total_left > 0 && r < c) { - if (unlikely((input == NULL) || (output == NULL))) - return -1; - - seg_total_left = rte_pktmbuf_data_len(input) - in_offset; - /* Set up DMA descriptor */ - desc = acc_desc(q, total_enqueued_cbs); - desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset; - desc->req.data_ptrs[0].blen = ACC_FCW_TE_BLEN; - - ret = acc_dma_desc_te_fill(op, &desc->req, &input, output, - &in_offset, &out_offset, &out_length, - &mbuf_total_left, &seg_total_left, r); - if (unlikely(ret < 0)) - return ret; - mbuf_append(output_head, output, out_length); - - /* Set total number of CBs in TB */ - desc->req.cbs_in_tb = cbs_in_tb; -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_te, - sizeof(desc->req.fcw_te) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - - if (seg_total_left == 0) { - /* Go to the next mbuf */ - input = input->next; - in_offset = 0; - output = output->next; - out_offset = 0; - } - - total_enqueued_cbs++; - current_enqueued_cbs++; - r++; - } - - /* In case the number of CB doesn't match, the configuration was invalid. */ - if (unlikely(current_enqueued_cbs != cbs_in_tb)) - return -1; - - /* Set SDone on last CB descriptor for TB mode. */ - desc->req.sdone_enable = 1; - - return current_enqueued_cbs; -} - -/* Enqueue one encode operations for ACC200 device in TB mode. - * returns the number of descs used. - */ -static inline int -enqueue_ldpc_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, - uint16_t enq_descs, uint8_t cbs_in_tb) -{ - uint8_t num_a, num_b; - uint16_t input_len_B, return_descs; - uint8_t r = op->ldpc_enc.tb_params.r; - uint8_t cab = op->ldpc_enc.tb_params.cab; - union acc_dma_desc *desc; - uint16_t init_enq_descs = enq_descs; - uint32_t in_offset = 0, out_offset = 0; - - input_len_B = ((op->ldpc_enc.basegraph == 1 ? 22 : 10) * op->ldpc_enc.z_c - - op->ldpc_enc.n_filler) >> 3; - - if (check_bit(op->ldpc_enc.op_flags, RTE_BBDEV_LDPC_CRC_24B_ATTACH)) - input_len_B -= 3; - - if (r < cab) { - num_a = cab - r; - num_b = cbs_in_tb - cab; - } else { - num_a = 0; - num_b = cbs_in_tb - r; - } - - while (num_a > 0) { - uint32_t e = op->ldpc_enc.tb_params.ea; - uint32_t out_len_B = (e + 7) >> 3; - uint8_t enq = RTE_MIN(num_a, ACC_MUX_5GDL_DESC); - num_a -= enq; - enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e, input_len_B, - out_len_B, &in_offset, &out_offset); - enq_descs++; - } - while (num_b > 0) { - uint32_t e = op->ldpc_enc.tb_params.eb; - uint32_t out_len_B = (e + 7) >> 3; - uint8_t enq = RTE_MIN(num_b, ACC_MUX_5GDL_DESC); - num_b -= enq; - enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e, input_len_B, - out_len_B, &in_offset, &out_offset); - enq_descs++; - } - - return_descs = enq_descs - init_enq_descs; - /* Keep total number of CBs in first TB. */ - desc = acc_desc(q, init_enq_descs); - desc->req.cbs_in_tb = return_descs; /** Actual number of descriptors. */ - desc->req.op_addr = op; - - /* Set SDone on last CB descriptor for TB mode. */ - desc = acc_desc(q, enq_descs - 1); - desc->req.sdone_enable = 1; - desc->req.op_addr = op; - return return_descs; -} - -/** Enqueue one decode operations for ACC200 device in CB mode. */ -static inline int -enqueue_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op, - uint16_t total_enqueued_cbs) -{ - union acc_dma_desc *desc = NULL; - int ret; - uint32_t in_offset, h_out_offset, s_out_offset, s_out_length, - h_out_length, mbuf_total_left, seg_total_left; - struct rte_mbuf *input, *h_output_head, *h_output, - *s_output_head, *s_output; - - desc = acc_desc(q, total_enqueued_cbs); - acc200_fcw_td_fill(op, &desc->req.fcw_td); - - input = op->turbo_dec.input.data; - h_output_head = h_output = op->turbo_dec.hard_output.data; - s_output_head = s_output = op->turbo_dec.soft_output.data; - in_offset = op->turbo_dec.input.offset; - h_out_offset = op->turbo_dec.hard_output.offset; - s_out_offset = op->turbo_dec.soft_output.offset; - h_out_length = s_out_length = 0; - mbuf_total_left = op->turbo_dec.input.length; - seg_total_left = rte_pktmbuf_data_len(input) - in_offset; - - /* Set up DMA descriptor */ - desc = acc_desc(q, total_enqueued_cbs); - - ret = acc200_dma_desc_td_fill(op, &desc->req, &input, h_output, - s_output, &in_offset, &h_out_offset, &s_out_offset, - &h_out_length, &s_out_length, &mbuf_total_left, - &seg_total_left, 0); - - if (unlikely(ret < 0)) - return ret; - - /* Hard output */ - mbuf_append(h_output_head, h_output, h_out_length); - - /* Soft output */ - if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) - mbuf_append(s_output_head, s_output, s_out_length); - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_td, - sizeof(desc->req.fcw_td)); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - - /* One CB (one op) was successfully prepared to enqueue */ - return 1; -} - -/** Enqueue one decode operations for ACC200 device in CB mode */ -static inline int -enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op, - uint16_t total_enqueued_cbs, bool same_op) -{ - int ret, hq_len; - union acc_dma_desc *desc; - struct rte_mbuf *input, *h_output_head, *h_output; - uint32_t in_offset, h_out_offset, mbuf_total_left, h_out_length = 0; - union acc_harq_layout_data *harq_layout; - - if (op->ldpc_dec.cb_params.e == 0) - return -EINVAL; - - desc = acc_desc(q, total_enqueued_cbs); - - input = op->ldpc_dec.input.data; - h_output_head = h_output = op->ldpc_dec.hard_output.data; - in_offset = op->ldpc_dec.input.offset; - h_out_offset = op->ldpc_dec.hard_output.offset; - mbuf_total_left = op->ldpc_dec.input.length; - harq_layout = q->d->harq_layout; - - if (same_op) { - union acc_dma_desc *prev_desc; - prev_desc = acc_desc(q, total_enqueued_cbs - 1); - uint8_t *prev_ptr = (uint8_t *) prev_desc; - uint8_t *new_ptr = (uint8_t *) desc; - /* Copy first 4 words and BDESCs. */ - rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0); - rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0, - prev_ptr + ACC_5GUL_OFFSET_0, - ACC_5GUL_SIZE_1); - desc->req.op_addr = prev_desc->req.op_addr; - /* Copy FCW. */ - rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET, - prev_ptr + ACC_DESC_FCW_OFFSET, - ACC_FCW_LD_BLEN); - acc200_dma_desc_ld_update(op, &desc->req, input, h_output, - &in_offset, &h_out_offset, - &h_out_length, harq_layout); - } else { - struct acc_fcw_ld *fcw; - uint32_t seg_total_left; - fcw = &desc->req.fcw_ld; - acc200_fcw_ld_fill(op, fcw, harq_layout); - - /* Special handling when using mbuf or not. */ - if (check_bit(op->ldpc_dec.op_flags, - RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)) - seg_total_left = rte_pktmbuf_data_len(input) - in_offset; - else - seg_total_left = fcw->rm_e; - - ret = acc200_dma_desc_ld_fill(op, &desc->req, &input, h_output, - &in_offset, &h_out_offset, - &h_out_length, &mbuf_total_left, - &seg_total_left, fcw); - if (unlikely(ret < 0)) - return ret; - } - - /* Hard output. */ - mbuf_append(h_output_head, h_output, h_out_length); - if (op->ldpc_dec.harq_combined_output.length > 0) { - /* Push the HARQ output into host memory. */ - struct rte_mbuf *hq_output_head, *hq_output; - hq_output_head = op->ldpc_dec.harq_combined_output.data; - hq_output = op->ldpc_dec.harq_combined_output.data; - hq_len = op->ldpc_dec.harq_combined_output.length; - if (unlikely(!mbuf_append(hq_output_head, hq_output, hq_len))) { - rte_bbdev_log(ERR, "HARQ output mbuf issue %d %d\n", - hq_output->buf_len, - hq_len); - return -1; - } - } - - if (op->ldpc_dec.soft_output.length > 0) - mbuf_append(op->ldpc_dec.soft_output.data, op->ldpc_dec.soft_output.data, - op->ldpc_dec.soft_output.length); - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_ld, - sizeof(desc->req.fcw_ld) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - - /* One CB (one op) was successfully prepared to enqueue. */ - return 1; -} - - -/* Enqueue one decode operations for ACC200 device in TB mode. */ -static inline int -enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, - uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) -{ - union acc_dma_desc *desc = NULL; - union acc_dma_desc *desc_first = NULL; - int ret; - uint8_t r, c; - uint32_t in_offset, h_out_offset, h_out_length, mbuf_total_left, seg_total_left; - struct rte_mbuf *input, *h_output_head, *h_output; - uint16_t current_enqueued_cbs = 0; - uint16_t desc_idx, sys_cols, trail_len = 0; - uint64_t fcw_offset; - union acc_harq_layout_data *harq_layout; - - desc_idx = acc_desc_idx(q, total_enqueued_cbs); - desc = q->ring_addr + desc_idx; - desc_first = desc; - fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET; - harq_layout = q->d->harq_layout; - acc200_fcw_ld_fill(op, &desc->req.fcw_ld, harq_layout); - - input = op->ldpc_dec.input.data; - h_output_head = h_output = op->ldpc_dec.hard_output.data; - in_offset = op->ldpc_dec.input.offset; - h_out_offset = op->ldpc_dec.hard_output.offset; - h_out_length = 0; - mbuf_total_left = op->ldpc_dec.input.length; - c = op->ldpc_dec.tb_params.c; - r = op->ldpc_dec.tb_params.r; - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) { - sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10; - trail_len = sys_cols * op->ldpc_dec.z_c - - op->ldpc_dec.n_filler - 24; - } - - while (mbuf_total_left > 0 && r < c) { - if (unlikely((input == NULL) || (h_output == NULL))) - return -1; - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)) - seg_total_left = rte_pktmbuf_data_len(input) - in_offset; - else - seg_total_left = op->ldpc_dec.input.length; - /* Set up DMA descriptor. */ - desc_idx = acc_desc_idx(q, total_enqueued_cbs); - desc = q->ring_addr + desc_idx; - fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET; - desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset; - desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN; - rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld, ACC_FCW_LD_BLEN); - desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len; - - ret = acc200_dma_desc_ld_fill(op, &desc->req, &input, - h_output, &in_offset, &h_out_offset, - &h_out_length, - &mbuf_total_left, &seg_total_left, - &desc->req.fcw_ld); - - if (unlikely(ret < 0)) - return ret; - - /* Hard output. */ - mbuf_append(h_output_head, h_output, h_out_length); - - /* Set total number of CBs in TB. */ - desc->req.cbs_in_tb = cbs_in_tb; -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_td, - sizeof(desc->req.fcw_td) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_DEC_SCATTER_GATHER) - && (seg_total_left == 0)) { - /* Go to the next mbuf. */ - input = input->next; - in_offset = 0; - h_output = h_output->next; - h_out_offset = 0; - } - total_enqueued_cbs++; - current_enqueued_cbs++; - r++; - } - - /* In case the number of CB doesn't match, the configuration was invalid. */ - if (unlikely(current_enqueued_cbs != cbs_in_tb)) - return -1; - -#ifdef RTE_LIBRTE_BBDEV_DEBUG - if (check_mbuf_total_left(mbuf_total_left) != 0) - return -EINVAL; -#endif - /* Set SDone on last CB descriptor for TB mode. */ - desc->req.sdone_enable = 1; - - return current_enqueued_cbs; -} - -/* Enqueue one decode operations for ACC200 device in TB mode */ -static inline int -enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, - uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) -{ - union acc_dma_desc *desc = NULL; - int ret; - uint8_t r, c; - uint32_t in_offset, h_out_offset, s_out_offset, s_out_length, - h_out_length, mbuf_total_left, seg_total_left; - struct rte_mbuf *input, *h_output_head, *h_output, - *s_output_head, *s_output; - uint16_t desc_idx, current_enqueued_cbs = 0; - uint64_t fcw_offset; - - desc_idx = acc_desc_idx(q, total_enqueued_cbs); - desc = q->ring_addr + desc_idx; - fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET; - acc200_fcw_td_fill(op, &desc->req.fcw_td); - - input = op->turbo_dec.input.data; - h_output_head = h_output = op->turbo_dec.hard_output.data; - s_output_head = s_output = op->turbo_dec.soft_output.data; - in_offset = op->turbo_dec.input.offset; - h_out_offset = op->turbo_dec.hard_output.offset; - s_out_offset = op->turbo_dec.soft_output.offset; - h_out_length = s_out_length = 0; - mbuf_total_left = op->turbo_dec.input.length; - c = op->turbo_dec.tb_params.c; - r = op->turbo_dec.tb_params.r; - - while (mbuf_total_left > 0 && r < c) { - if (unlikely((input == NULL) || (h_output == NULL))) - return -1; - - seg_total_left = rte_pktmbuf_data_len(input) - in_offset; - - /* Set up DMA descriptor */ - desc = acc_desc(q, total_enqueued_cbs); - desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset; - desc->req.data_ptrs[0].blen = ACC_FCW_TD_BLEN; - ret = acc200_dma_desc_td_fill(op, &desc->req, &input, - h_output, s_output, &in_offset, &h_out_offset, - &s_out_offset, &h_out_length, &s_out_length, - &mbuf_total_left, &seg_total_left, r); - - if (unlikely(ret < 0)) - return ret; - - /* Hard output */ - mbuf_append(h_output_head, h_output, h_out_length); - - /* Soft output */ - if (check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_SOFT_OUTPUT)) - mbuf_append(s_output_head, s_output, s_out_length); - - /* Set total number of CBs in TB */ - desc->req.cbs_in_tb = cbs_in_tb; -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_td, - sizeof(desc->req.fcw_td) - 8); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - - if (seg_total_left == 0) { - /* Go to the next mbuf */ - input = input->next; - in_offset = 0; - h_output = h_output->next; - h_out_offset = 0; - - if (check_bit(op->turbo_dec.op_flags, - RTE_BBDEV_TURBO_SOFT_OUTPUT)) { - s_output = s_output->next; - s_out_offset = 0; - } - } - - total_enqueued_cbs++; - current_enqueued_cbs++; - r++; - } - - /* In case the number of CB doesn't match, the configuration was invalid. */ - if (unlikely(current_enqueued_cbs != cbs_in_tb)) - return -1; - - /* Set SDone on last CB descriptor for TB mode */ - desc->req.sdone_enable = 1; - - return current_enqueued_cbs; -} - -/* Enqueue encode operations for ACC200 device in CB mode. */ -static uint16_t -acc200_enqueue_enc_cb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i; - int ret; - - for (i = 0; i < num; ++i) { - /* Check if there are available space for further processing */ - if (unlikely(avail - 1 < 0)) { - acc_enqueue_ring_full(q_data); - break; - } - avail -= 1; - - ret = enqueue_enc_one_op_cb(q, ops[i], i); - if (ret < 0) { - acc_enqueue_invalid(q_data); - break; - } - } - - if (unlikely(i == 0)) - return 0; /* Nothing to enqueue */ - - acc_dma_enqueue(q, i, &q_data->queue_stats); - - /* Update stats */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - return i; -} - -/** Enqueue encode operations for ACC200 device in CB mode. */ -static inline uint16_t -acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i = 0; - int ret, desc_idx = 0; - int16_t enq, left = num; - - while (left > 0) { - if (unlikely(avail < 1)) { - acc_enqueue_ring_full(q_data); - break; - } - avail--; - enq = RTE_MIN(left, ACC_MUX_5GDL_DESC); - enq = check_mux(&ops[i], enq); - ret = enqueue_ldpc_enc_n_op_cb(q, &ops[i], desc_idx, enq); - if (ret < 0) { - acc_enqueue_invalid(q_data); - break; - } - i += enq; - desc_idx++; - left = num - i; - } - - if (unlikely(i == 0)) - return 0; /* Nothing to enqueue. */ - - acc_dma_enqueue(q, desc_idx, &q_data->queue_stats); - - /* Update stats. */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - - return i; -} - -/* Enqueue encode operations for ACC200 device in TB mode. */ -static uint16_t -acc200_enqueue_enc_tb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i, enqueued_cbs = 0; - uint8_t cbs_in_tb; - int ret; - - for (i = 0; i < num; ++i) { - cbs_in_tb = get_num_cbs_in_tb_enc(&ops[i]->turbo_enc); - /* Check if there are available space for further processing */ - if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) { - acc_enqueue_ring_full(q_data); - break; - } - avail -= cbs_in_tb; - - ret = enqueue_enc_one_op_tb(q, ops[i], enqueued_cbs, cbs_in_tb); - if (ret <= 0) { - acc_enqueue_invalid(q_data); - break; - } - enqueued_cbs += ret; - } - if (unlikely(enqueued_cbs == 0)) - return 0; /* Nothing to enqueue */ - - acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats); - - /* Update stats */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - - return i; -} - -/* Enqueue LDPC encode operations for ACC200 device in TB mode. */ -static uint16_t -acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i, enqueued_descs = 0; - uint8_t cbs_in_tb; - int descs_used; - - for (i = 0; i < num; ++i) { - cbs_in_tb = get_num_cbs_in_tb_ldpc_enc(&ops[i]->ldpc_enc); - /* Check if there are available space for further processing. */ - if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) { - acc_enqueue_ring_full(q_data); - break; - } - - descs_used = enqueue_ldpc_enc_one_op_tb(q, ops[i], enqueued_descs, cbs_in_tb); - if (descs_used < 0) { - acc_enqueue_invalid(q_data); - break; - } - enqueued_descs += descs_used; - avail -= descs_used; - } - if (unlikely(enqueued_descs == 0)) - return 0; /* Nothing to enqueue. */ - - acc_dma_enqueue(q, enqueued_descs, &q_data->queue_stats); - - /* Update stats. */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - - return i; -} - -/* Enqueue encode operations for ACC200 device. */ -static uint16_t -acc200_enqueue_enc(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - int32_t aq_avail = acc_aq_avail(q_data, num); - if (unlikely((aq_avail <= 0) || (num == 0))) - return 0; - if (ops[0]->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - return acc200_enqueue_enc_tb(q_data, ops, num); - else - return acc200_enqueue_enc_cb(q_data, ops, num); -} - -/* Enqueue encode operations for ACC200 device. */ -static uint16_t -acc200_enqueue_ldpc_enc(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - int32_t aq_avail = acc_aq_avail(q_data, num); - if (unlikely((aq_avail <= 0) || (num == 0))) - return 0; - if (ops[0]->ldpc_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - return acc200_enqueue_ldpc_enc_tb(q_data, ops, num); - else - return acc200_enqueue_ldpc_enc_cb(q_data, ops, num); -} - - -/* Enqueue decode operations for ACC200 device in CB mode. */ -static uint16_t -acc200_enqueue_dec_cb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i; - int ret; - - for (i = 0; i < num; ++i) { - /* Check if there are available space for further processing. */ - if (unlikely(avail - 1 < 0)) - break; - avail -= 1; - - ret = enqueue_dec_one_op_cb(q, ops[i], i); - if (ret < 0) - break; - } - - if (unlikely(i == 0)) - return 0; /* Nothing to enqueue. */ - - acc_dma_enqueue(q, i, &q_data->queue_stats); - - /* Update stats. */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - - return i; -} - -/* Enqueue decode operations for ACC200 device in TB mode. */ -static uint16_t -acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i, enqueued_cbs = 0; - uint8_t cbs_in_tb; - int ret; - - for (i = 0; i < num; ++i) { - cbs_in_tb = get_num_cbs_in_tb_ldpc_dec(&ops[i]->ldpc_dec); - /* Check if there are available space for further processing. */ - if (unlikely((avail - cbs_in_tb < 0) || - (cbs_in_tb == 0))) - break; - avail -= cbs_in_tb; - - ret = enqueue_ldpc_dec_one_op_tb(q, ops[i], - enqueued_cbs, cbs_in_tb); - if (ret <= 0) - break; - enqueued_cbs += ret; - } - - acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats); - - /* Update stats. */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - return i; -} - -/* Enqueue decode operations for ACC200 device in CB mode. */ -static uint16_t -acc200_enqueue_ldpc_dec_cb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i; - int ret; - bool same_op = false; - - for (i = 0; i < num; ++i) { - /* Check if there are available space for further processing. */ - if (unlikely(avail < 1)) { - acc_enqueue_ring_full(q_data); - break; - } - avail -= 1; - - rte_bbdev_log(INFO, "Op %d %d %d %d %d %d %d %d %d %d %d %d\n", - i, ops[i]->ldpc_dec.op_flags, ops[i]->ldpc_dec.rv_index, - ops[i]->ldpc_dec.iter_max, ops[i]->ldpc_dec.iter_count, - ops[i]->ldpc_dec.basegraph, ops[i]->ldpc_dec.z_c, - ops[i]->ldpc_dec.n_cb, ops[i]->ldpc_dec.q_m, - ops[i]->ldpc_dec.n_filler, ops[i]->ldpc_dec.cb_params.e, - same_op); - ret = enqueue_ldpc_dec_one_op_cb(q, ops[i], i, same_op); - if (ret < 0) { - acc_enqueue_invalid(q_data); - break; - } - } - - if (unlikely(i == 0)) - return 0; /* Nothing to enqueue. */ - - acc_dma_enqueue(q, i, &q_data->queue_stats); - - /* Update stats. */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - return i; -} - - -/* Enqueue decode operations for ACC200 device in TB mode */ -static uint16_t -acc200_enqueue_dec_tb(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - int32_t avail = acc_ring_avail_enq(q); - uint16_t i, enqueued_cbs = 0; - uint8_t cbs_in_tb; - int ret; - - for (i = 0; i < num; ++i) { - cbs_in_tb = get_num_cbs_in_tb_dec(&ops[i]->turbo_dec); - /* Check if there are available space for further processing */ - if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) { - acc_enqueue_ring_full(q_data); - break; - } - avail -= cbs_in_tb; - - ret = enqueue_dec_one_op_tb(q, ops[i], enqueued_cbs, cbs_in_tb); - if (ret <= 0) { - acc_enqueue_invalid(q_data); - break; - } - enqueued_cbs += ret; - } - - acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats); - - /* Update stats */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - - return i; -} - -/* Enqueue decode operations for ACC200 device. */ -static uint16_t -acc200_enqueue_dec(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - int32_t aq_avail = acc_aq_avail(q_data, num); - if (unlikely((aq_avail <= 0) || (num == 0))) - return 0; - if (ops[0]->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - return acc200_enqueue_dec_tb(q_data, ops, num); - else - return acc200_enqueue_dec_cb(q_data, ops, num); -} - -/* Enqueue decode operations for ACC200 device. */ -static uint16_t -acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - int32_t aq_avail = acc_aq_avail(q_data, num); - if (unlikely((aq_avail <= 0) || (num == 0))) - return 0; - if (ops[0]->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - return acc200_enqueue_ldpc_dec_tb(q_data, ops, num); - else - return acc200_enqueue_ldpc_dec_cb(q_data, ops, num); -} - - -/* Dequeue one encode operations from ACC200 device in CB mode. */ -static inline int -dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op, - uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs, - uint16_t max_requested_ops) -{ - union acc_dma_desc *desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_enc_op *op; - int i; - struct acc_ptrs *context_ptrs; - uint16_t desc_idx; - - desc_idx = acc_desc_idx_tail(q, *dequeued_descs); - desc = q->ring_addr + desc_idx; - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - if (*dequeued_ops + desc->req.numCBs > max_requested_ops) - return -1; - - /* Check fdone bit. */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - rsp.val = atom_desc.rsp.val; - rte_bbdev_log_debug("Resp. desc %p: %x", desc, rsp.val); - - /* Dequeue. */ - op = desc->req.op_addr; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - op->status |= ((rsp.input_err) ? (1 << RTE_BBDEV_DATA_ERROR) : 0); - op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; /* Reserved bits. */ - desc->rsp.add_info_1 = 0; /* Reserved bits. */ - - ref_op[0] = op; - context_ptrs = q->companion_ring_addr + desc_idx; - for (i = 1 ; i < desc->req.numCBs; i++) - ref_op[i] = context_ptrs->ptr[i].op_addr; - - /* One op was successfully dequeued. */ - (*dequeued_descs)++; - *dequeued_ops += desc->req.numCBs; - return desc->req.numCBs; -} - -/* Dequeue one LDPC encode operations from ACC200 device in TB mode. - * That operation may cover multiple descriptors. - */ -static inline int -dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op, - uint16_t *dequeued_ops, uint32_t *aq_dequeued, - uint16_t *dequeued_descs, uint16_t max_requested_ops) -{ - union acc_dma_desc *desc, *last_desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_enc_op *op; - uint8_t i = 0; - uint16_t current_dequeued_descs = 0, descs_in_tb; - - desc = acc_desc_tail(q, *dequeued_descs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - if (*dequeued_ops + 1 > max_requested_ops) - return -1; - - /* Check fdone bit. */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - /* Get number of CBs in dequeued TB. */ - descs_in_tb = desc->req.cbs_in_tb; - /* Get last CB */ - last_desc = acc_desc_tail(q, *dequeued_descs + descs_in_tb - 1); - /* Check if last CB in TB is ready to dequeue (and thus - * the whole TB) - checking sdone bit. If not return. - */ - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc, __ATOMIC_RELAXED); - if (!(atom_desc.rsp.val & ACC_SDONE)) - return -1; - - /* Dequeue. */ - op = desc->req.op_addr; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - - while (i < descs_in_tb) { - desc = acc_desc_tail(q, *dequeued_descs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - rsp.val = atom_desc.rsp.val; - rte_bbdev_log_debug("Resp. desc %p: %x", desc, rsp.val); - - op->status |= ((rsp.input_err) ? (1 << RTE_BBDEV_DATA_ERROR) : 0); - op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; - desc->rsp.add_info_1 = 0; - (*dequeued_descs)++; - current_dequeued_descs++; - i++; - } - - *ref_op = op; - (*dequeued_ops)++; - return current_dequeued_descs; -} - -/* Dequeue one decode operation from ACC200 device in CB mode. */ -static inline int -dequeue_dec_one_op_cb(struct rte_bbdev_queue_data *q_data, - struct acc_queue *q, struct rte_bbdev_dec_op **ref_op, - uint16_t dequeued_cbs, uint32_t *aq_dequeued) -{ - union acc_dma_desc *desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_dec_op *op; - - desc = acc_desc_tail(q, dequeued_cbs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - /* Check fdone bit. */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - rsp.val = atom_desc.rsp.val; - rte_bbdev_log_debug("Resp. desc %p: %x\n", desc, rsp.val); - - /* Dequeue. */ - op = desc->req.op_addr; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - op->status |= ((rsp.input_err) ? (1 << RTE_BBDEV_DATA_ERROR) : 0); - op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - if (op->status != 0) { - /* These errors are not expected. */ - q_data->queue_stats.dequeue_err_count++; - acc200_check_ir(q->d); - } - - /* CRC invalid if error exists. */ - if (!op->status) - op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR; - op->turbo_dec.iter_count = (uint8_t) rsp.iter_cnt; - /* Check if this is the last desc in batch (Atomic Queue). */ - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; - desc->rsp.add_info_1 = 0; - *ref_op = op; - - /* One CB (op) was successfully dequeued. */ - return 1; -} - -/* Dequeue one decode operations from ACC200 device in CB mode. */ -static inline int -dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data, - struct acc_queue *q, struct rte_bbdev_dec_op **ref_op, - uint16_t dequeued_cbs, uint32_t *aq_dequeued) -{ - union acc_dma_desc *desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_dec_op *op; - - desc = acc_desc_tail(q, dequeued_cbs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - /* Check fdone bit. */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - rsp.val = atom_desc.rsp.val; - rte_bbdev_log_debug("Resp. desc %p: %x %x %x\n", desc, rsp.val, desc->rsp.add_info_0, - desc->rsp.add_info_1); - - /* Dequeue. */ - op = desc->req.op_addr; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR; - op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR; - op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR; - if (op->status != 0) - q_data->queue_stats.dequeue_err_count++; - - op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR; - if (op->ldpc_dec.hard_output.length > 0 && !rsp.synd_ok) - op->status |= 1 << RTE_BBDEV_SYNDROME_ERROR; - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK) || - check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK)) { - if (desc->rsp.add_info_1 != 0) - op->status |= 1 << RTE_BBDEV_CRC_ERROR; - } - - op->ldpc_dec.iter_count = (uint8_t) rsp.iter_cnt; - - if (op->status & (1 << RTE_BBDEV_DRV_ERROR)) - acc200_check_ir(q->d); - - /* Check if this is the last desc in batch (Atomic Queue). */ - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; - desc->rsp.add_info_1 = 0; - - *ref_op = op; - - /* One CB (op) was successfully dequeued. */ - return 1; -} - -/* Dequeue one decode operations from device in TB mode for 4G or 5G. */ -static inline int -dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op, - uint16_t dequeued_cbs, uint32_t *aq_dequeued) -{ - union acc_dma_desc *desc, *last_desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_dec_op *op; - uint8_t cbs_in_tb = 1, cb_idx = 0; - uint32_t tb_crc_check = 0; - - desc = acc_desc_tail(q, dequeued_cbs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - /* Check fdone bit. */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - /* Dequeue. */ - op = desc->req.op_addr; - - /* Get number of CBs in dequeued TB. */ - cbs_in_tb = desc->req.cbs_in_tb; - /* Get last CB. */ - last_desc = acc_desc_tail(q, dequeued_cbs + cbs_in_tb - 1); - /* Check if last CB in TB is ready to dequeue (and thus the whole TB) - checking sdone bit. - * If not return. - */ - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc, __ATOMIC_RELAXED); - if (!(atom_desc.rsp.val & ACC_SDONE)) - return -1; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - - /* Read remaining CBs if exists. */ - while (cb_idx < cbs_in_tb) { - desc = acc_desc_tail(q, dequeued_cbs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - rsp.val = atom_desc.rsp.val; - rte_bbdev_log_debug("Resp. desc %p: %x %x %x", desc, - rsp.val, desc->rsp.add_info_0, - desc->rsp.add_info_1); - - op->status |= ((rsp.input_err) ? (1 << RTE_BBDEV_DATA_ERROR) : 0); - op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0); - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) - tb_crc_check ^= desc->rsp.add_info_1; - - /* CRC invalid if error exists. */ - if (!op->status) - op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR; - if (q->op_type == RTE_BBDEV_OP_LDPC_DEC) - op->ldpc_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt, - op->ldpc_dec.iter_count); - else - op->turbo_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt, - op->turbo_dec.iter_count); - - /* Check if this is the last desc in batch (Atomic Queue). */ - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; - desc->rsp.add_info_1 = 0; - dequeued_cbs++; - cb_idx++; - } - - if (check_bit(op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) { - rte_bbdev_log_debug("TB-CRC Check %x\n", tb_crc_check); - if (tb_crc_check > 0) - op->status |= 1 << RTE_BBDEV_CRC_ERROR; - } - - *ref_op = op; - - return cb_idx; -} - -/* Dequeue encode operations from ACC200 device. */ -static uint16_t -acc200_dequeue_enc(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - uint32_t avail = acc_ring_avail_deq(q); - uint32_t aq_dequeued = 0; - uint16_t i, dequeued_ops = 0, dequeued_descs = 0; - int ret, cbm; - struct rte_bbdev_enc_op *op; - if (avail == 0) - return 0; - op = acc_op_tail(q, 0); - - cbm = op->turbo_enc.code_block_mode; - - for (i = 0; i < avail; i++) { - if (cbm == RTE_BBDEV_TRANSPORT_BLOCK) - ret = dequeue_enc_one_op_tb(q, &ops[dequeued_ops], - &dequeued_ops, &aq_dequeued, - &dequeued_descs, num); - else - ret = dequeue_enc_one_op_cb(q, &ops[dequeued_ops], - &dequeued_ops, &aq_dequeued, - &dequeued_descs, num); - if (ret < 0) - break; - } - - q->aq_dequeued += aq_dequeued; - q->sw_ring_tail += dequeued_descs; - - /* Update enqueue stats. */ - q_data->queue_stats.dequeued_count += dequeued_ops; - - return dequeued_ops; -} - -/* Dequeue LDPC encode operations from ACC200 device. */ -static uint16_t -acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_enc_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - uint32_t avail = acc_ring_avail_deq(q); - uint32_t aq_dequeued = 0; - uint16_t i, dequeued_ops = 0, dequeued_descs = 0; - int ret, cbm; - struct rte_bbdev_enc_op *op; - if (avail == 0) - return 0; - op = acc_op_tail(q, 0); - cbm = op->ldpc_enc.code_block_mode; - - for (i = 0; i < avail; i++) { - if (cbm == RTE_BBDEV_TRANSPORT_BLOCK) - ret = dequeue_enc_one_op_tb(q, &ops[dequeued_ops], - &dequeued_ops, &aq_dequeued, - &dequeued_descs, num); - else - ret = dequeue_enc_one_op_cb(q, &ops[dequeued_ops], - &dequeued_ops, &aq_dequeued, - &dequeued_descs, num); - if (ret < 0) - break; - } - - q->aq_dequeued += aq_dequeued; - q->sw_ring_tail += dequeued_descs; - - /* Update enqueue stats. */ - q_data->queue_stats.dequeued_count += dequeued_ops; - - return dequeued_ops; -} - -/* Dequeue decode operations from ACC200 device. */ -static uint16_t -acc200_dequeue_dec(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - uint16_t dequeue_num; - uint32_t avail = acc_ring_avail_deq(q); - uint32_t aq_dequeued = 0; - uint16_t i; - uint16_t dequeued_cbs = 0; - struct rte_bbdev_dec_op *op; - int ret; - - dequeue_num = (avail < num) ? avail : num; - - for (i = 0; i < dequeue_num; ++i) { - op = acc_op_tail(q, dequeued_cbs); - if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs, - &aq_dequeued); - else - ret = dequeue_dec_one_op_cb(q_data, q, &ops[i], - dequeued_cbs, &aq_dequeued); - - if (ret <= 0) - break; - dequeued_cbs += ret; - } - - q->aq_dequeued += aq_dequeued; - q->sw_ring_tail += dequeued_cbs; - - /* Update enqueue stats */ - q_data->queue_stats.dequeued_count += i; - - return i; -} - -/* Dequeue decode operations from ACC200 device. */ -static uint16_t -acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_dec_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - uint16_t dequeue_num; - uint32_t avail = acc_ring_avail_deq(q); - uint32_t aq_dequeued = 0; - uint16_t i; - uint16_t dequeued_cbs = 0; - struct rte_bbdev_dec_op *op; - int ret; - - dequeue_num = RTE_MIN(avail, num); - - for (i = 0; i < dequeue_num; ++i) { - op = acc_op_tail(q, dequeued_cbs); - if (op->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) - ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs, - &aq_dequeued); - else - ret = dequeue_ldpc_dec_one_op_cb( - q_data, q, &ops[i], dequeued_cbs, - &aq_dequeued); - - if (ret <= 0) - break; - dequeued_cbs += ret; - } - - q->aq_dequeued += aq_dequeued; - q->sw_ring_tail += dequeued_cbs; - - /* Update enqueue stats. */ - q_data->queue_stats.dequeued_count += i; - - return i; -} - -/* Fill in a frame control word for FFT processing. */ -static inline void -acc200_fcw_fft_fill(struct rte_bbdev_fft_op *op, struct acc_fcw_fft *fcw) -{ - fcw->in_frame_size = op->fft.input_sequence_size; - fcw->leading_pad_size = op->fft.input_leading_padding; - fcw->out_frame_size = op->fft.output_sequence_size; - fcw->leading_depad_size = op->fft.output_leading_depadding; - fcw->cs_window_sel = op->fft.window_index[0] + - (op->fft.window_index[1] << 8) + - (op->fft.window_index[2] << 16) + - (op->fft.window_index[3] << 24); - fcw->cs_window_sel2 = op->fft.window_index[4] + - (op->fft.window_index[5] << 8); - fcw->cs_enable_bmap = op->fft.cs_bitmap; - fcw->num_antennas = op->fft.num_antennas_log2; - fcw->idft_size = op->fft.idft_log2; - fcw->dft_size = op->fft.dft_log2; - fcw->cs_offset = op->fft.cs_time_adjustment; - fcw->idft_shift = op->fft.idft_shift; - fcw->dft_shift = op->fft.dft_shift; - fcw->cs_multiplier = op->fft.ncs_reciprocal; - if (check_bit(op->fft.op_flags, RTE_BBDEV_FFT_IDFT_BYPASS)) { - if (check_bit(op->fft.op_flags, RTE_BBDEV_FFT_WINDOWING_BYPASS)) - fcw->bypass = 2; - else - fcw->bypass = 1; - } else if (check_bit(op->fft.op_flags, RTE_BBDEV_FFT_DFT_BYPASS)) - fcw->bypass = 3; - else - fcw->bypass = 0; -} - -static inline int -acc200_dma_desc_fft_fill(struct rte_bbdev_fft_op *op, - struct acc_dma_req_desc *desc, - struct rte_mbuf *input, struct rte_mbuf *output, - uint32_t *in_offset, uint32_t *out_offset) -{ - /* FCW already done. */ - acc_header_init(desc); - desc->data_ptrs[1].address = rte_pktmbuf_iova_offset(input, *in_offset); - desc->data_ptrs[1].blen = op->fft.input_sequence_size * 4; - desc->data_ptrs[1].blkid = ACC_DMA_BLKID_IN; - desc->data_ptrs[1].last = 1; - desc->data_ptrs[1].dma_ext = 0; - desc->data_ptrs[2].address = rte_pktmbuf_iova_offset(output, *out_offset); - desc->data_ptrs[2].blen = op->fft.output_sequence_size * 4; - desc->data_ptrs[2].blkid = ACC_DMA_BLKID_OUT_HARD; - desc->data_ptrs[2].last = 1; - desc->data_ptrs[2].dma_ext = 0; - desc->m2dlen = 2; - desc->d2mlen = 1; - desc->ib_ant_offset = op->fft.input_sequence_size; - desc->num_ant = op->fft.num_antennas_log2 - 3; - int num_cs = 0, i; - for (i = 0; i < 12; i++) - if (check_bit(op->fft.cs_bitmap, 1 << i)) - num_cs++; - desc->num_cs = num_cs; - desc->ob_cyc_offset = op->fft.output_sequence_size; - desc->ob_ant_offset = op->fft.output_sequence_size * num_cs; - desc->op_addr = op; - return 0; -} - - -/** Enqueue one FFT operation for ACC200 device. */ -static inline int -enqueue_fft_one_op(struct acc_queue *q, struct rte_bbdev_fft_op *op, - uint16_t total_enqueued_cbs) -{ - union acc_dma_desc *desc; - struct rte_mbuf *input, *output; - uint32_t in_offset, out_offset; - struct acc_fcw_fft *fcw; - - desc = acc_desc(q, total_enqueued_cbs); - input = op->fft.base_input.data; - output = op->fft.base_output.data; - in_offset = op->fft.base_input.offset; - out_offset = op->fft.base_output.offset; - fcw = &desc->req.fcw_fft; - - acc200_fcw_fft_fill(op, fcw); - acc200_dma_desc_fft_fill(op, &desc->req, input, output, &in_offset, &out_offset); -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "FCW", &desc->req.fcw_fft, - sizeof(desc->req.fcw_fft)); - rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); -#endif - return 1; -} - -/* Enqueue decode operations for ACC200 device. */ -static uint16_t -acc200_enqueue_fft(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_fft_op **ops, uint16_t num) -{ - struct acc_queue *q; - int32_t aq_avail, avail; - uint16_t i; - int ret; - - aq_avail = acc_aq_avail(q_data, num); - if (unlikely((aq_avail <= 0) || (num == 0))) - return 0; - q = q_data->queue_private; - avail = acc_ring_avail_enq(q); - - for (i = 0; i < num; ++i) { - /* Check if there are available space for further processing. */ - if (unlikely(avail < 1)) - break; - avail -= 1; - ret = enqueue_fft_one_op(q, ops[i], i); - if (ret < 0) - break; - } - - if (unlikely(i == 0)) - return 0; /* Nothing to enqueue. */ - - acc_dma_enqueue(q, i, &q_data->queue_stats); - - /* Update stats */ - q_data->queue_stats.enqueued_count += i; - q_data->queue_stats.enqueue_err_count += num - i; - return i; -} - - -/* Dequeue one FFT operations from ACC200 device. */ -static inline int -dequeue_fft_one_op(struct rte_bbdev_queue_data *q_data, - struct acc_queue *q, struct rte_bbdev_fft_op **ref_op, - uint16_t dequeued_cbs, uint32_t *aq_dequeued) -{ - union acc_dma_desc *desc, atom_desc; - union acc_dma_rsp_desc rsp; - struct rte_bbdev_fft_op *op; - - desc = acc_desc_tail(q, dequeued_cbs); - atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED); - - /* Check fdone bit */ - if (!(atom_desc.rsp.val & ACC_FDONE)) - return -1; - - rsp.val = atom_desc.rsp.val; -#ifdef RTE_LIBRTE_BBDEV_DEBUG - rte_memdump(stderr, "Resp", &desc->rsp.val, - sizeof(desc->rsp.val)); -#endif - /* Dequeue. */ - op = desc->req.op_addr; - - /* Clearing status, it will be set based on response. */ - op->status = 0; - op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR; - op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR; - op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR; - if (op->status != 0) - q_data->queue_stats.dequeue_err_count++; - - if (op->status & (1 << RTE_BBDEV_DRV_ERROR)) - acc200_check_ir(q->d); - - /* Check if this is the last desc in batch (Atomic Queue). */ - if (desc->req.last_desc_in_batch) { - (*aq_dequeued)++; - desc->req.last_desc_in_batch = 0; - } - desc->rsp.val = ACC_DMA_DESC_TYPE; - desc->rsp.add_info_0 = 0; - *ref_op = op; - /* One CB (op) was successfully dequeued. */ - return 1; -} - - -/* Dequeue FFT operations from ACC200 device. */ -static uint16_t -acc200_dequeue_fft(struct rte_bbdev_queue_data *q_data, - struct rte_bbdev_fft_op **ops, uint16_t num) -{ - struct acc_queue *q = q_data->queue_private; - uint16_t dequeue_num, i, dequeued_cbs = 0; - uint32_t avail = acc_ring_avail_deq(q); - uint32_t aq_dequeued = 0; - int ret; - - dequeue_num = RTE_MIN(avail, num); - - for (i = 0; i < dequeue_num; ++i) { - ret = dequeue_fft_one_op(q_data, q, &ops[i], dequeued_cbs, &aq_dequeued); - if (ret <= 0) - break; - dequeued_cbs += ret; - } - - q->aq_dequeued += aq_dequeued; - q->sw_ring_tail += dequeued_cbs; - /* Update enqueue stats. */ - q_data->queue_stats.dequeued_count += i; - return i; -} - -/* Initialization Function */ -static void -acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv) -{ - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device); - - dev->dev_ops = &acc200_bbdev_ops; - dev->enqueue_enc_ops = acc200_enqueue_enc; - dev->enqueue_dec_ops = acc200_enqueue_dec; - dev->dequeue_enc_ops = acc200_dequeue_enc; - dev->dequeue_dec_ops = acc200_dequeue_dec; - dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc; - dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec; - dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc; - dev->dequeue_ldpc_dec_ops = acc200_dequeue_ldpc_dec; - dev->enqueue_fft_ops = acc200_enqueue_fft; - dev->dequeue_fft_ops = acc200_dequeue_fft; - - ((struct acc_device *) dev->data->dev_private)->pf_device = - !strcmp(drv->driver.name, - RTE_STR(ACC200PF_DRIVER_NAME)); - ((struct acc_device *) dev->data->dev_private)->mmio_base = - pci_dev->mem_resource[0].addr; - - rte_bbdev_log_debug("Init device %s [%s] @ vaddr %p paddr %#"PRIx64"", - drv->driver.name, dev->data->name, - (void *)pci_dev->mem_resource[0].addr, - pci_dev->mem_resource[0].phys_addr); -} - -static int acc200_pci_probe(struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev) -{ - struct rte_bbdev *bbdev = NULL; - char dev_name[RTE_BBDEV_NAME_MAX_LEN]; - - if (pci_dev == NULL) { - rte_bbdev_log(ERR, "NULL PCI device"); - return -EINVAL; - } - - rte_pci_device_name(&pci_dev->addr, dev_name, sizeof(dev_name)); - - /* Allocate memory to be used privately by drivers. */ - bbdev = rte_bbdev_allocate(pci_dev->device.name); - if (bbdev == NULL) - return -ENODEV; - - /* allocate device private memory. */ - bbdev->data->dev_private = rte_zmalloc_socket(dev_name, - sizeof(struct acc_device), RTE_CACHE_LINE_SIZE, - pci_dev->device.numa_node); - - if (bbdev->data->dev_private == NULL) { - rte_bbdev_log(CRIT, - "Allocate of %zu bytes for device \"%s\" failed", - sizeof(struct acc_device), dev_name); - rte_bbdev_release(bbdev); - return -ENOMEM; - } - - /* Fill HW specific part of device structure. */ - bbdev->device = &pci_dev->device; - bbdev->intr_handle = pci_dev->intr_handle; - bbdev->data->socket_id = pci_dev->device.numa_node; - - /* Invoke ACC200 device initialization function. */ - acc200_bbdev_init(bbdev, pci_drv); - - rte_bbdev_log_debug("Initialised bbdev %s (id = %u)", - dev_name, bbdev->data->dev_id); - return 0; -} - -static struct rte_pci_driver acc200_pci_pf_driver = { - .probe = acc200_pci_probe, - .remove = acc_pci_remove, - .id_table = pci_id_acc200_pf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING -}; - -static struct rte_pci_driver acc200_pci_vf_driver = { - .probe = acc200_pci_probe, - .remove = acc_pci_remove, - .id_table = pci_id_acc200_vf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING -}; - -RTE_PMD_REGISTER_PCI(ACC200PF_DRIVER_NAME, acc200_pci_pf_driver); -RTE_PMD_REGISTER_PCI_TABLE(ACC200PF_DRIVER_NAME, pci_id_acc200_pf_map); -RTE_PMD_REGISTER_PCI(ACC200VF_DRIVER_NAME, acc200_pci_vf_driver); -RTE_PMD_REGISTER_PCI_TABLE(ACC200VF_DRIVER_NAME, pci_id_acc200_vf_map); - -/* Initial configuration of a ACC200 device prior to running configure(). */ -int -acc200_configure(const char *dev_name, struct rte_acc_conf *conf) -{ - rte_bbdev_log(INFO, "acc200_configure"); - uint32_t value, address, status; - int qg_idx, template_idx, vf_idx, acc, i, rlim, alen, timestamp, totalQgs, numEngines; - int numQgs, numQqsAcc; - struct rte_bbdev *bbdev = rte_bbdev_get_named_dev(dev_name); - - /* Compile time checks. */ - RTE_BUILD_BUG_ON(sizeof(struct acc_dma_req_desc) != 256); - RTE_BUILD_BUG_ON(sizeof(union acc_dma_desc) != 256); - RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_td) != 24); - RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_te) != 32); - - if (bbdev == NULL) { - rte_bbdev_log(ERR, - "Invalid dev_name (%s), or device is not yet initialised", - dev_name); - return -ENODEV; - } - struct acc_device *d = bbdev->data->dev_private; - - /* Store configuration. */ - rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf)); - - /* Check we are already out of PG. */ - status = acc_reg_read(d, HWPfHiSectionPowerGatingAck); - if (status > 0) { - if (status != ACC200_PG_MASK_0) { - rte_bbdev_log(ERR, "Unexpected status %x %x", - status, ACC200_PG_MASK_0); - return -ENODEV; - } - /* Clock gate sections that will be un-PG. */ - acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_DIS); - /* Un-PG required sections. */ - acc_reg_write(d, HWPfHiSectionPowerGatingReq, - ACC200_PG_MASK_1); - status = acc_reg_read(d, HWPfHiSectionPowerGatingAck); - if (status != ACC200_PG_MASK_1) { - rte_bbdev_log(ERR, "Unexpected status %x %x", - status, ACC200_PG_MASK_1); - return -ENODEV; - } - acc_reg_write(d, HWPfHiSectionPowerGatingReq, - ACC200_PG_MASK_2); - status = acc_reg_read(d, HWPfHiSectionPowerGatingAck); - if (status != ACC200_PG_MASK_2) { - rte_bbdev_log(ERR, "Unexpected status %x %x", - status, ACC200_PG_MASK_2); - return -ENODEV; - } - acc_reg_write(d, HWPfHiSectionPowerGatingReq, - ACC200_PG_MASK_3); - status = acc_reg_read(d, HWPfHiSectionPowerGatingAck); - if (status != ACC200_PG_MASK_3) { - rte_bbdev_log(ERR, "Unexpected status %x %x", - status, ACC200_PG_MASK_3); - return -ENODEV; - } - /* Enable clocks for all sections. */ - acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_EN); - } - - /* Explicitly releasing AXI as this may be stopped after PF FLR/BME. */ - address = HWPfDmaAxiControl; - value = 1; - acc_reg_write(d, address, value); - - /* Set the fabric mode. */ - address = HWPfFabricM2iBufferReg; - value = ACC200_FABRIC_MODE; - acc_reg_write(d, address, value); - - /* Set default descriptor signature. */ - address = HWPfDmaDescriptorSignatuture; - value = 0; - acc_reg_write(d, address, value); - - /* Enable the Error Detection in DMA. */ - value = ACC200_CFG_DMA_ERROR; - address = HWPfDmaErrorDetectionEn; - acc_reg_write(d, address, value); - - /* AXI Cache configuration. */ - value = ACC200_CFG_AXI_CACHE; - address = HWPfDmaAxcacheReg; - acc_reg_write(d, address, value); - - /* AXI Response configuration. */ - acc_reg_write(d, HWPfDmaCfgRrespBresp, 0x0); - - /* Default DMA Configuration (Qmgr Enabled). */ - address = HWPfDmaConfig0Reg; - value = 0; - acc_reg_write(d, address, value); - address = HWPfDmaQmanen; - value = 0; - acc_reg_write(d, address, value); - - /* Default RLIM/ALEN configuration. */ - rlim = 0; - alen = 1; - timestamp = 0; - address = HWPfDmaConfig1Reg; - value = (1 << 31) + (rlim << 8) + (timestamp << 6) + alen; - acc_reg_write(d, address, value); - - /* Default FFT configuration. */ - address = HWPfFftConfig0; - value = ACC200_FFT_CFG_0; - acc_reg_write(d, address, value); - - /* Configure DMA Qmanager addresses. */ - address = HWPfDmaQmgrAddrReg; - value = HWPfQmgrEgressQueuesTemplate; - acc_reg_write(d, address, value); - - /* ===== Qmgr Configuration ===== */ - /* Configuration of the AQueue Depth QMGR_GRP_0_DEPTH_LOG2 for UL. */ - totalQgs = conf->q_ul_4g.num_qgroups + - conf->q_ul_5g.num_qgroups + - conf->q_dl_4g.num_qgroups + - conf->q_dl_5g.num_qgroups + - conf->q_fft.num_qgroups; - for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) { - address = HWPfQmgrDepthLog2Grp + - ACC_BYTES_IN_WORD * qg_idx; - value = aqDepth(qg_idx, conf); - acc_reg_write(d, address, value); - address = HWPfQmgrTholdGrp + - ACC_BYTES_IN_WORD * qg_idx; - value = (1 << 16) + (1 << (aqDepth(qg_idx, conf) - 1)); - acc_reg_write(d, address, value); - } - - /* Template Priority in incremental order. */ - for (template_idx = 0; template_idx < ACC_NUM_TMPL; - template_idx++) { - address = HWPfQmgrGrpTmplateReg0Indx + ACC_BYTES_IN_WORD * template_idx; - value = ACC_TMPL_PRI_0; - acc_reg_write(d, address, value); - address = HWPfQmgrGrpTmplateReg1Indx + ACC_BYTES_IN_WORD * template_idx; - value = ACC_TMPL_PRI_1; - acc_reg_write(d, address, value); - address = HWPfQmgrGrpTmplateReg2indx + ACC_BYTES_IN_WORD * template_idx; - value = ACC_TMPL_PRI_2; - acc_reg_write(d, address, value); - address = HWPfQmgrGrpTmplateReg3Indx + ACC_BYTES_IN_WORD * template_idx; - value = ACC_TMPL_PRI_3; - acc_reg_write(d, address, value); - } - - address = HWPfQmgrGrpPriority; - value = ACC200_CFG_QMGR_HI_P; - acc_reg_write(d, address, value); - - /* Template Configuration. */ - for (template_idx = 0; template_idx < ACC_NUM_TMPL; - template_idx++) { - value = 0; - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - acc_reg_write(d, address, value); - } - /* 4GUL */ - numQgs = conf->q_ul_4g.num_qgroups; - numQqsAcc = 0; - value = 0; - for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++) - value |= (1 << qg_idx); - for (template_idx = ACC200_SIG_UL_4G; - template_idx <= ACC200_SIG_UL_4G_LAST; - template_idx++) { - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - acc_reg_write(d, address, value); - } - /* 5GUL */ - numQqsAcc += numQgs; - numQgs = conf->q_ul_5g.num_qgroups; - value = 0; - numEngines = 0; - for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++) - value |= (1 << qg_idx); - for (template_idx = ACC200_SIG_UL_5G; - template_idx <= ACC200_SIG_UL_5G_LAST; - template_idx++) { - /* Check engine power-on status */ - address = HwPfFecUl5gIbDebugReg + ACC_ENGINE_OFFSET * template_idx; - status = (acc_reg_read(d, address) >> 4) & 0x7; - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - if (status == 1) { - acc_reg_write(d, address, value); - numEngines++; - } else - acc_reg_write(d, address, 0); - } - printf("Number of 5GUL engines %d\n", numEngines); - /* 4GDL */ - numQqsAcc += numQgs; - numQgs = conf->q_dl_4g.num_qgroups; - value = 0; - for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++) - value |= (1 << qg_idx); - for (template_idx = ACC200_SIG_DL_4G; - template_idx <= ACC200_SIG_DL_4G_LAST; - template_idx++) { - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - acc_reg_write(d, address, value); - } - /* 5GDL */ - numQqsAcc += numQgs; - numQgs = conf->q_dl_5g.num_qgroups; - value = 0; - for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++) - value |= (1 << qg_idx); - for (template_idx = ACC200_SIG_DL_5G; - template_idx <= ACC200_SIG_DL_5G_LAST; - template_idx++) { - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - acc_reg_write(d, address, value); - } - /* FFT */ - numQqsAcc += numQgs; - numQgs = conf->q_fft.num_qgroups; - value = 0; - for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++) - value |= (1 << qg_idx); - for (template_idx = ACC200_SIG_FFT; - template_idx <= ACC200_SIG_FFT_LAST; - template_idx++) { - address = HWPfQmgrGrpTmplateReg4Indx - + ACC_BYTES_IN_WORD * template_idx; - acc_reg_write(d, address, value); - } - - /* Queue Group Function mapping. */ - int qman_func_id[8] = {0, 2, 1, 3, 4, 0, 0, 0}; - value = 0; - for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) { - acc = accFromQgid(qg_idx, conf); - value |= qman_func_id[acc] << (qg_idx * 4); - } - acc_reg_write(d, HWPfQmgrGrpFunction0, value); - value = 0; - for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) { - acc = accFromQgid(qg_idx + ACC_NUM_QGRPS_PER_WORD, conf); - value |= qman_func_id[acc] << (qg_idx * 4); - } - acc_reg_write(d, HWPfQmgrGrpFunction1, value); - - /* Configuration of the Arbitration QGroup depth to 1. */ - for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) { - address = HWPfQmgrArbQDepthGrp + - ACC_BYTES_IN_WORD * qg_idx; - value = 0; - acc_reg_write(d, address, value); - } - - /* This pointer to ARAM (256kB) is shifted by 2 (4B per register). */ - uint32_t aram_address = 0; - for (qg_idx = 0; qg_idx < totalQgs; qg_idx++) { - for (vf_idx = 0; vf_idx < conf->num_vf_bundles; vf_idx++) { - address = HWPfQmgrVfBaseAddr + vf_idx - * ACC_BYTES_IN_WORD + qg_idx - * ACC_BYTES_IN_WORD * 64; - value = aram_address; - acc_reg_write(d, address, value); - /* Offset ARAM Address for next memory bank - increment of 4B. */ - aram_address += aqNum(qg_idx, conf) * - (1 << aqDepth(qg_idx, conf)); - } - } - - if (aram_address > ACC200_WORDS_IN_ARAM_SIZE) { - rte_bbdev_log(ERR, "ARAM Configuration not fitting %d %d\n", - aram_address, ACC200_WORDS_IN_ARAM_SIZE); - return -EINVAL; - } - - /* Performance tuning. */ - acc_reg_write(d, HWPfFabricI2Mdma_weight, 0x0FFF); - acc_reg_write(d, HWPfDma4gdlIbThld, 0x1f10); - - /* ==== HI Configuration ==== */ - - /* No Info Ring/MSI by default. */ - address = HWPfHiInfoRingIntWrEnRegPf; - value = 0; - acc_reg_write(d, address, value); - address = HWPfHiCfgMsiIntWrEnRegPf; - value = 0xFFFFFFFF; - acc_reg_write(d, address, value); - /* Prevent Block on Transmit Error. */ - address = HWPfHiBlockTransmitOnErrorEn; - value = 0; - acc_reg_write(d, address, value); - /* Prevents to drop MSI. */ - address = HWPfHiMsiDropEnableReg; - value = 0; - acc_reg_write(d, address, value); - /* Set the PF Mode register. */ - address = HWPfHiPfMode; - value = (conf->pf_mode_en) ? ACC_PF_VAL : 0; - acc_reg_write(d, address, value); - - /* QoS overflow init. */ - value = 1; - address = HWPfQosmonAEvalOverflow0; - acc_reg_write(d, address, value); - address = HWPfQosmonBEvalOverflow0; - acc_reg_write(d, address, value); - - /* Configure the FFT RAM LUT. */ - uint32_t fft_lut[ACC200_FFT_RAM_SIZE] = { - 0x1FFFF, 0x1FFFF, 0x1FFFE, 0x1FFFA, 0x1FFF6, 0x1FFF1, 0x1FFEA, 0x1FFE2, - 0x1FFD9, 0x1FFCE, 0x1FFC2, 0x1FFB5, 0x1FFA7, 0x1FF98, 0x1FF87, 0x1FF75, - 0x1FF62, 0x1FF4E, 0x1FF38, 0x1FF21, 0x1FF09, 0x1FEF0, 0x1FED6, 0x1FEBA, - 0x1FE9D, 0x1FE7F, 0x1FE5F, 0x1FE3F, 0x1FE1D, 0x1FDFA, 0x1FDD5, 0x1FDB0, - 0x1FD89, 0x1FD61, 0x1FD38, 0x1FD0D, 0x1FCE1, 0x1FCB4, 0x1FC86, 0x1FC57, - 0x1FC26, 0x1FBF4, 0x1FBC1, 0x1FB8D, 0x1FB58, 0x1FB21, 0x1FAE9, 0x1FAB0, - 0x1FA75, 0x1FA3A, 0x1F9FD, 0x1F9BF, 0x1F980, 0x1F93F, 0x1F8FD, 0x1F8BA, - 0x1F876, 0x1F831, 0x1F7EA, 0x1F7A3, 0x1F75A, 0x1F70F, 0x1F6C4, 0x1F677, - 0x1F629, 0x1F5DA, 0x1F58A, 0x1F539, 0x1F4E6, 0x1F492, 0x1F43D, 0x1F3E7, - 0x1F38F, 0x1F337, 0x1F2DD, 0x1F281, 0x1F225, 0x1F1C8, 0x1F169, 0x1F109, - 0x1F0A8, 0x1F046, 0x1EFE2, 0x1EF7D, 0x1EF18, 0x1EEB0, 0x1EE48, 0x1EDDF, - 0x1ED74, 0x1ED08, 0x1EC9B, 0x1EC2D, 0x1EBBE, 0x1EB4D, 0x1EADB, 0x1EA68, - 0x1E9F4, 0x1E97F, 0x1E908, 0x1E891, 0x1E818, 0x1E79E, 0x1E722, 0x1E6A6, - 0x1E629, 0x1E5AA, 0x1E52A, 0x1E4A9, 0x1E427, 0x1E3A3, 0x1E31F, 0x1E299, - 0x1E212, 0x1E18A, 0x1E101, 0x1E076, 0x1DFEB, 0x1DF5E, 0x1DED0, 0x1DE41, - 0x1DDB1, 0x1DD20, 0x1DC8D, 0x1DBFA, 0x1DB65, 0x1DACF, 0x1DA38, 0x1D9A0, - 0x1D907, 0x1D86C, 0x1D7D1, 0x1D734, 0x1D696, 0x1D5F7, 0x1D557, 0x1D4B6, - 0x1D413, 0x1D370, 0x1D2CB, 0x1D225, 0x1D17E, 0x1D0D6, 0x1D02D, 0x1CF83, - 0x1CED8, 0x1CE2B, 0x1CD7E, 0x1CCCF, 0x1CC1F, 0x1CB6E, 0x1CABC, 0x1CA09, - 0x1C955, 0x1C89F, 0x1C7E9, 0x1C731, 0x1C679, 0x1C5BF, 0x1C504, 0x1C448, - 0x1C38B, 0x1C2CD, 0x1C20E, 0x1C14E, 0x1C08C, 0x1BFCA, 0x1BF06, 0x1BE42, - 0x1BD7C, 0x1BCB5, 0x1BBED, 0x1BB25, 0x1BA5B, 0x1B990, 0x1B8C4, 0x1B7F6, - 0x1B728, 0x1B659, 0x1B589, 0x1B4B7, 0x1B3E5, 0x1B311, 0x1B23D, 0x1B167, - 0x1B091, 0x1AFB9, 0x1AEE0, 0x1AE07, 0x1AD2C, 0x1AC50, 0x1AB73, 0x1AA95, - 0x1A9B6, 0x1A8D6, 0x1A7F6, 0x1A714, 0x1A631, 0x1A54D, 0x1A468, 0x1A382, - 0x1A29A, 0x1A1B2, 0x1A0C9, 0x19FDF, 0x19EF4, 0x19E08, 0x19D1B, 0x19C2D, - 0x19B3E, 0x19A4E, 0x1995D, 0x1986B, 0x19778, 0x19684, 0x1958F, 0x19499, - 0x193A2, 0x192AA, 0x191B1, 0x190B8, 0x18FBD, 0x18EC1, 0x18DC4, 0x18CC7, - 0x18BC8, 0x18AC8, 0x189C8, 0x188C6, 0x187C4, 0x186C1, 0x185BC, 0x184B7, - 0x183B1, 0x182AA, 0x181A2, 0x18099, 0x17F8F, 0x17E84, 0x17D78, 0x17C6C, - 0x17B5E, 0x17A4F, 0x17940, 0x17830, 0x1771E, 0x1760C, 0x174F9, 0x173E5, - 0x172D1, 0x171BB, 0x170A4, 0x16F8D, 0x16E74, 0x16D5B, 0x16C41, 0x16B26, - 0x16A0A, 0x168ED, 0x167CF, 0x166B1, 0x16592, 0x16471, 0x16350, 0x1622E, - 0x1610B, 0x15FE8, 0x15EC3, 0x15D9E, 0x15C78, 0x15B51, 0x15A29, 0x15900, - 0x157D7, 0x156AC, 0x15581, 0x15455, 0x15328, 0x151FB, 0x150CC, 0x14F9D, - 0x14E6D, 0x14D3C, 0x14C0A, 0x14AD8, 0x149A4, 0x14870, 0x1473B, 0x14606, - 0x144CF, 0x14398, 0x14260, 0x14127, 0x13FEE, 0x13EB3, 0x13D78, 0x13C3C, - 0x13B00, 0x139C2, 0x13884, 0x13745, 0x13606, 0x134C5, 0x13384, 0x13242, - 0x130FF, 0x12FBC, 0x12E78, 0x12D33, 0x12BEE, 0x12AA7, 0x12960, 0x12819, - 0x126D0, 0x12587, 0x1243D, 0x122F3, 0x121A8, 0x1205C, 0x11F0F, 0x11DC2, - 0x11C74, 0x11B25, 0x119D6, 0x11886, 0x11735, 0x115E3, 0x11491, 0x1133F, - 0x111EB, 0x11097, 0x10F42, 0x10DED, 0x10C97, 0x10B40, 0x109E9, 0x10891, - 0x10738, 0x105DF, 0x10485, 0x1032B, 0x101D0, 0x10074, 0x0FF18, 0x0FDBB, - 0x0FC5D, 0x0FAFF, 0x0F9A0, 0x0F841, 0x0F6E1, 0x0F580, 0x0F41F, 0x0F2BD, - 0x0F15B, 0x0EFF8, 0x0EE94, 0x0ED30, 0x0EBCC, 0x0EA67, 0x0E901, 0x0E79A, - 0x0E633, 0x0E4CC, 0x0E364, 0x0E1FB, 0x0E092, 0x0DF29, 0x0DDBE, 0x0DC54, - 0x0DAE9, 0x0D97D, 0x0D810, 0x0D6A4, 0x0D536, 0x0D3C8, 0x0D25A, 0x0D0EB, - 0x0CF7C, 0x0CE0C, 0x0CC9C, 0x0CB2B, 0x0C9B9, 0x0C847, 0x0C6D5, 0x0C562, - 0x0C3EF, 0x0C27B, 0x0C107, 0x0BF92, 0x0BE1D, 0x0BCA8, 0x0BB32, 0x0B9BB, - 0x0B844, 0x0B6CD, 0x0B555, 0x0B3DD, 0x0B264, 0x0B0EB, 0x0AF71, 0x0ADF7, - 0x0AC7D, 0x0AB02, 0x0A987, 0x0A80B, 0x0A68F, 0x0A513, 0x0A396, 0x0A219, - 0x0A09B, 0x09F1D, 0x09D9E, 0x09C20, 0x09AA1, 0x09921, 0x097A1, 0x09621, - 0x094A0, 0x0931F, 0x0919E, 0x0901C, 0x08E9A, 0x08D18, 0x08B95, 0x08A12, - 0x0888F, 0x0870B, 0x08587, 0x08402, 0x0827E, 0x080F9, 0x07F73, 0x07DEE, - 0x07C68, 0x07AE2, 0x0795B, 0x077D4, 0x0764D, 0x074C6, 0x0733E, 0x071B6, - 0x0702E, 0x06EA6, 0x06D1D, 0x06B94, 0x06A0B, 0x06881, 0x066F7, 0x0656D, - 0x063E3, 0x06258, 0x060CE, 0x05F43, 0x05DB7, 0x05C2C, 0x05AA0, 0x05914, - 0x05788, 0x055FC, 0x0546F, 0x052E3, 0x05156, 0x04FC9, 0x04E3B, 0x04CAE, - 0x04B20, 0x04992, 0x04804, 0x04676, 0x044E8, 0x04359, 0x041CB, 0x0403C, - 0x03EAD, 0x03D1D, 0x03B8E, 0x039FF, 0x0386F, 0x036DF, 0x0354F, 0x033BF, - 0x0322F, 0x0309F, 0x02F0F, 0x02D7E, 0x02BEE, 0x02A5D, 0x028CC, 0x0273B, - 0x025AA, 0x02419, 0x02288, 0x020F7, 0x01F65, 0x01DD4, 0x01C43, 0x01AB1, - 0x0191F, 0x0178E, 0x015FC, 0x0146A, 0x012D8, 0x01147, 0x00FB5, 0x00E23, - 0x00C91, 0x00AFF, 0x0096D, 0x007DB, 0x00648, 0x004B6, 0x00324, 0x00192}; - - acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_EN + 64); - for (i = 0; i < ACC200_FFT_RAM_SIZE; i++) - acc_reg_write(d, HWPfFftRamOff + i * 4, fft_lut[i]); - acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_DIS); - - /* Enabling AQueues through the Queue hierarchy. */ - for (vf_idx = 0; vf_idx < ACC200_NUM_VFS; vf_idx++) { - for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) { - value = 0; - if (vf_idx < conf->num_vf_bundles && qg_idx < totalQgs) - value = (1 << aqNum(qg_idx, conf)) - 1; - address = HWPfQmgrAqEnableVf + vf_idx * ACC_BYTES_IN_WORD; - value += (qg_idx << 16); - acc_reg_write(d, address, value); - } - } - - rte_bbdev_log_debug("PF Tip configuration complete for %s", dev_name); - return 0; -} diff --git a/dpdk/drivers/common/idpf/base/virtchnl.h b/dpdk/drivers/common/idpf/base/virtchnl.h deleted file mode 100644 index ea798e397..000000000 --- a/dpdk/drivers/common/idpf/base/virtchnl.h +++ /dev/null @@ -1,2866 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2001-2022 Intel Corporation - */ - -#ifndef _VIRTCHNL_H_ -#define _VIRTCHNL_H_ - -/* Description: - * This header file describes the Virtual Function (VF) - Physical Function - * (PF) communication protocol used by the drivers for all devices starting - * from our 40G product line - * - * Admin queue buffer usage: - * desc->opcode is always aqc_opc_send_msg_to_pf - * flags, retval, datalen, and data addr are all used normally. - * The Firmware copies the cookie fields when sending messages between the - * PF and VF, but uses all other fields internally. Due to this limitation, - * we must send all messages as "indirect", i.e. using an external buffer. - * - * All the VSI indexes are relative to the VF. Each VF can have maximum of - * three VSIs. All the queue indexes are relative to the VSI. Each VF can - * have a maximum of sixteen queues for all of its VSIs. - * - * The PF is required to return a status code in v_retval for all messages - * except RESET_VF, which does not require any response. The returned value - * is of virtchnl_status_code type, defined here. - * - * In general, VF driver initialization should roughly follow the order of - * these opcodes. The VF driver must first validate the API version of the - * PF driver, then request a reset, then get resources, then configure - * queues and interrupts. After these operations are complete, the VF - * driver may start its queues, optionally add MAC and VLAN filters, and - * process traffic. - */ - -/* START GENERIC DEFINES - * Need to ensure the following enums and defines hold the same meaning and - * value in current and future projects - */ - -#define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6 - -/* These macros are used to generate compilation errors if a structure/union - * is not exactly the correct length. It gives a divide by zero error if the - * structure/union is not of the correct size, otherwise it creates an enum - * that is never used. - */ -#define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \ - { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) } -#define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \ - { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) } - - -/* Error Codes - * Note that many older versions of various iAVF drivers convert the reported - * status code directly into an iavf_status enumeration. For this reason, it - * is important that the values of these enumerations line up. - */ -enum virtchnl_status_code { - VIRTCHNL_STATUS_SUCCESS = 0, - VIRTCHNL_STATUS_ERR_PARAM = -5, - VIRTCHNL_STATUS_ERR_NO_MEMORY = -18, - VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38, - VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39, - VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40, - VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53, - VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64, -}; - -/* Backward compatibility */ -#define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM -#define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED - -#define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0 -#define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1 -#define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2 -#define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3 -#define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4 -#define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5 -#define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6 -#define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7 - -enum virtchnl_link_speed { - VIRTCHNL_LINK_SPEED_UNKNOWN = 0, - VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT), - VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT), - VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT), - VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT), - VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT), - VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT), - VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT), - VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT), -}; - -/* for hsplit_0 field of Rx HMC context */ -/* deprecated with AVF 1.0 */ -enum virtchnl_rx_hsplit { - VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0, - VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1, - VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2, - VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4, - VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8, -}; - -enum virtchnl_bw_limit_type { - VIRTCHNL_BW_SHAPER = 0, -}; -/* END GENERIC DEFINES */ - -/* Opcodes for VF-PF communication. These are placed in the v_opcode field - * of the virtchnl_msg structure. - */ -enum virtchnl_ops { -/* The PF sends status change events to VFs using - * the VIRTCHNL_OP_EVENT opcode. - * VFs send requests to the PF using the other ops. - * Use of "advanced opcode" features must be negotiated as part of capabilities - * exchange and are not considered part of base mode feature set. - * - */ - VIRTCHNL_OP_UNKNOWN = 0, - VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ - VIRTCHNL_OP_RESET_VF = 2, - VIRTCHNL_OP_GET_VF_RESOURCES = 3, - VIRTCHNL_OP_CONFIG_TX_QUEUE = 4, - VIRTCHNL_OP_CONFIG_RX_QUEUE = 5, - VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6, - VIRTCHNL_OP_CONFIG_IRQ_MAP = 7, - VIRTCHNL_OP_ENABLE_QUEUES = 8, - VIRTCHNL_OP_DISABLE_QUEUES = 9, - VIRTCHNL_OP_ADD_ETH_ADDR = 10, - VIRTCHNL_OP_DEL_ETH_ADDR = 11, - VIRTCHNL_OP_ADD_VLAN = 12, - VIRTCHNL_OP_DEL_VLAN = 13, - VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14, - VIRTCHNL_OP_GET_STATS = 15, - VIRTCHNL_OP_RSVD = 16, - VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */ - /* opcode 19 is reserved */ - /* opcodes 20, 21, and 22 are reserved */ - VIRTCHNL_OP_CONFIG_RSS_KEY = 23, - VIRTCHNL_OP_CONFIG_RSS_LUT = 24, - VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25, - VIRTCHNL_OP_SET_RSS_HENA = 26, - VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27, - VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28, - VIRTCHNL_OP_REQUEST_QUEUES = 29, - VIRTCHNL_OP_ENABLE_CHANNELS = 30, - VIRTCHNL_OP_DISABLE_CHANNELS = 31, - VIRTCHNL_OP_ADD_CLOUD_FILTER = 32, - VIRTCHNL_OP_DEL_CLOUD_FILTER = 33, - /* opcode 34 is reserved */ - /* opcodes 38, 39, 40, 41, 42 and 43 are reserved */ - /* opcode 44 is reserved */ - VIRTCHNL_OP_ADD_RSS_CFG = 45, - VIRTCHNL_OP_DEL_RSS_CFG = 46, - VIRTCHNL_OP_ADD_FDIR_FILTER = 47, - VIRTCHNL_OP_DEL_FDIR_FILTER = 48, - VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50, - VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51, - VIRTCHNL_OP_ADD_VLAN_V2 = 52, - VIRTCHNL_OP_DEL_VLAN_V2 = 53, - VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54, - VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55, - VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56, - VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57, - VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58, - VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59, - VIRTCHNL_OP_1588_PTP_GET_CAPS = 60, - VIRTCHNL_OP_1588_PTP_GET_TIME = 61, - VIRTCHNL_OP_1588_PTP_SET_TIME = 62, - VIRTCHNL_OP_1588_PTP_ADJ_TIME = 63, - VIRTCHNL_OP_1588_PTP_ADJ_FREQ = 64, - VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP = 65, - VIRTCHNL_OP_GET_QOS_CAPS = 66, - VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67, - VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS = 68, - VIRTCHNL_OP_1588_PTP_SET_PIN_CFG = 69, - VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP = 70, - VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107, - VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108, - VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111, - VIRTCHNL_OP_CONFIG_QUEUE_BW = 112, - VIRTCHNL_OP_CONFIG_QUANTA = 113, - VIRTCHNL_OP_MAX, -}; - -static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode) -{ - switch (v_opcode) { - case VIRTCHNL_OP_UNKNOWN: - return "VIRTCHNL_OP_UNKNOWN"; - case VIRTCHNL_OP_VERSION: - return "VIRTCHNL_OP_VERSION"; - case VIRTCHNL_OP_RESET_VF: - return "VIRTCHNL_OP_RESET_VF"; - case VIRTCHNL_OP_GET_VF_RESOURCES: - return "VIRTCHNL_OP_GET_VF_RESOURCES"; - case VIRTCHNL_OP_CONFIG_TX_QUEUE: - return "VIRTCHNL_OP_CONFIG_TX_QUEUE"; - case VIRTCHNL_OP_CONFIG_RX_QUEUE: - return "VIRTCHNL_OP_CONFIG_RX_QUEUE"; - case VIRTCHNL_OP_CONFIG_VSI_QUEUES: - return "VIRTCHNL_OP_CONFIG_VSI_QUEUES"; - case VIRTCHNL_OP_CONFIG_IRQ_MAP: - return "VIRTCHNL_OP_CONFIG_IRQ_MAP"; - case VIRTCHNL_OP_ENABLE_QUEUES: - return "VIRTCHNL_OP_ENABLE_QUEUES"; - case VIRTCHNL_OP_DISABLE_QUEUES: - return "VIRTCHNL_OP_DISABLE_QUEUES"; - case VIRTCHNL_OP_ADD_ETH_ADDR: - return "VIRTCHNL_OP_ADD_ETH_ADDR"; - case VIRTCHNL_OP_DEL_ETH_ADDR: - return "VIRTCHNL_OP_DEL_ETH_ADDR"; - case VIRTCHNL_OP_ADD_VLAN: - return "VIRTCHNL_OP_ADD_VLAN"; - case VIRTCHNL_OP_DEL_VLAN: - return "VIRTCHNL_OP_DEL_VLAN"; - case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: - return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE"; - case VIRTCHNL_OP_GET_STATS: - return "VIRTCHNL_OP_GET_STATS"; - case VIRTCHNL_OP_RSVD: - return "VIRTCHNL_OP_RSVD"; - case VIRTCHNL_OP_EVENT: - return "VIRTCHNL_OP_EVENT"; - case VIRTCHNL_OP_CONFIG_RSS_KEY: - return "VIRTCHNL_OP_CONFIG_RSS_KEY"; - case VIRTCHNL_OP_CONFIG_RSS_LUT: - return "VIRTCHNL_OP_CONFIG_RSS_LUT"; - case VIRTCHNL_OP_GET_RSS_HENA_CAPS: - return "VIRTCHNL_OP_GET_RSS_HENA_CAPS"; - case VIRTCHNL_OP_SET_RSS_HENA: - return "VIRTCHNL_OP_SET_RSS_HENA"; - case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: - return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING"; - case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: - return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING"; - case VIRTCHNL_OP_REQUEST_QUEUES: - return "VIRTCHNL_OP_REQUEST_QUEUES"; - case VIRTCHNL_OP_ENABLE_CHANNELS: - return "VIRTCHNL_OP_ENABLE_CHANNELS"; - case VIRTCHNL_OP_DISABLE_CHANNELS: - return "VIRTCHNL_OP_DISABLE_CHANNELS"; - case VIRTCHNL_OP_ADD_CLOUD_FILTER: - return "VIRTCHNL_OP_ADD_CLOUD_FILTER"; - case VIRTCHNL_OP_DEL_CLOUD_FILTER: - return "VIRTCHNL_OP_DEL_CLOUD_FILTER"; - case VIRTCHNL_OP_ADD_RSS_CFG: - return "VIRTCHNL_OP_ADD_RSS_CFG"; - case VIRTCHNL_OP_DEL_RSS_CFG: - return "VIRTCHNL_OP_DEL_RSS_CFG"; - case VIRTCHNL_OP_ADD_FDIR_FILTER: - return "VIRTCHNL_OP_ADD_FDIR_FILTER"; - case VIRTCHNL_OP_DEL_FDIR_FILTER: - return "VIRTCHNL_OP_DEL_FDIR_FILTER"; - case VIRTCHNL_OP_GET_MAX_RSS_QREGION: - return "VIRTCHNL_OP_GET_MAX_RSS_QREGION"; - case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS: - return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS"; - case VIRTCHNL_OP_ADD_VLAN_V2: - return "VIRTCHNL_OP_ADD_VLAN_V2"; - case VIRTCHNL_OP_DEL_VLAN_V2: - return "VIRTCHNL_OP_DEL_VLAN_V2"; - case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2: - return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2"; - case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2: - return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2"; - case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2: - return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2"; - case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2: - return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2"; - case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2: - return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2"; - case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2: - return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2"; - case VIRTCHNL_OP_1588_PTP_GET_CAPS: - return "VIRTCHNL_OP_1588_PTP_GET_CAPS"; - case VIRTCHNL_OP_1588_PTP_GET_TIME: - return "VIRTCHNL_OP_1588_PTP_GET_TIME"; - case VIRTCHNL_OP_1588_PTP_SET_TIME: - return "VIRTCHNL_OP_1588_PTP_SET_TIME"; - case VIRTCHNL_OP_1588_PTP_ADJ_TIME: - return "VIRTCHNL_OP_1588_PTP_ADJ_TIME"; - case VIRTCHNL_OP_1588_PTP_ADJ_FREQ: - return "VIRTCHNL_OP_1588_PTP_ADJ_FREQ"; - case VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP: - return "VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP"; - case VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS: - return "VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS"; - case VIRTCHNL_OP_1588_PTP_SET_PIN_CFG: - return "VIRTCHNL_OP_1588_PTP_SET_PIN_CFG"; - case VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP: - return "VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP"; - case VIRTCHNL_OP_ENABLE_QUEUES_V2: - return "VIRTCHNL_OP_ENABLE_QUEUES_V2"; - case VIRTCHNL_OP_DISABLE_QUEUES_V2: - return "VIRTCHNL_OP_DISABLE_QUEUES_V2"; - case VIRTCHNL_OP_MAP_QUEUE_VECTOR: - return "VIRTCHNL_OP_MAP_QUEUE_VECTOR"; - case VIRTCHNL_OP_MAX: - return "VIRTCHNL_OP_MAX"; - default: - return "Unsupported (update virtchnl.h)"; - } -} - -static inline const char *virtchnl_stat_str(enum virtchnl_status_code v_status) -{ - switch (v_status) { - case VIRTCHNL_STATUS_SUCCESS: - return "VIRTCHNL_STATUS_SUCCESS"; - case VIRTCHNL_STATUS_ERR_PARAM: - return "VIRTCHNL_STATUS_ERR_PARAM"; - case VIRTCHNL_STATUS_ERR_NO_MEMORY: - return "VIRTCHNL_STATUS_ERR_NO_MEMORY"; - case VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH: - return "VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH"; - case VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR: - return "VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR"; - case VIRTCHNL_STATUS_ERR_INVALID_VF_ID: - return "VIRTCHNL_STATUS_ERR_INVALID_VF_ID"; - case VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR: - return "VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR"; - case VIRTCHNL_STATUS_ERR_NOT_SUPPORTED: - return "VIRTCHNL_STATUS_ERR_NOT_SUPPORTED"; - default: - return "Unknown status code (update virtchnl.h)"; - } -} - -/* Virtual channel message descriptor. This overlays the admin queue - * descriptor. All other data is passed in external buffers. - */ - -struct virtchnl_msg { - u8 pad[8]; /* AQ flags/opcode/len/retval fields */ - - /* avoid confusion with desc->opcode */ - enum virtchnl_ops v_opcode; - - /* ditto for desc->retval */ - enum virtchnl_status_code v_retval; - u32 vfid; /* used by PF when sending to VF */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg); - -/* Message descriptions and data structures. */ - -/* VIRTCHNL_OP_VERSION - * VF posts its version number to the PF. PF responds with its version number - * in the same format, along with a return code. - * Reply from PF has its major/minor versions also in param0 and param1. - * If there is a major version mismatch, then the VF cannot operate. - * If there is a minor version mismatch, then the VF can operate but should - * add a warning to the system log. - * - * This enum element MUST always be specified as == 1, regardless of other - * changes in the API. The PF must always respond to this message without - * error regardless of version mismatch. - */ -#define VIRTCHNL_VERSION_MAJOR 1 -#define VIRTCHNL_VERSION_MINOR 1 -#define VIRTCHNL_VERSION_MAJOR_2 2 -#define VIRTCHNL_VERSION_MINOR_0 0 -#define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0 - -struct virtchnl_version_info { - u32 major; - u32 minor; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info); - -#define VF_IS_V10(_ver) (((_ver)->major == 1) && ((_ver)->minor == 0)) -#define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1)) -#define VF_IS_V20(_ver) (((_ver)->major == 2) && ((_ver)->minor == 0)) - -/* VIRTCHNL_OP_RESET_VF - * VF sends this request to PF with no parameters - * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register - * until reset completion is indicated. The admin queue must be reinitialized - * after this operation. - * - * When reset is complete, PF must ensure that all queues in all VSIs associated - * with the VF are stopped, all queue configurations in the HMC are set to 0, - * and all MAC and VLAN filters (except the default MAC address) on all VSIs - * are cleared. - */ - -/* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV - * vsi_type should always be 6 for backward compatibility. Add other fields - * as needed. - */ -enum virtchnl_vsi_type { - VIRTCHNL_VSI_TYPE_INVALID = 0, - VIRTCHNL_VSI_SRIOV = 6, -}; - -/* VIRTCHNL_OP_GET_VF_RESOURCES - * Version 1.0 VF sends this request to PF with no parameters - * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities - * PF responds with an indirect message containing - * virtchnl_vf_resource and one or more - * virtchnl_vsi_resource structures. - */ - -struct virtchnl_vsi_resource { - u16 vsi_id; - u16 num_queue_pairs; - - /* see enum virtchnl_vsi_type */ - s32 vsi_type; - u16 qset_handle; - u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource); - -/* VF capability flags - * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including - * TX/RX Checksum offloading and TSO for non-tunnelled packets. - */ -#define VIRTCHNL_VF_OFFLOAD_L2 BIT(0) -#define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1) -#define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_IWARP -#define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3) -#define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4) -#define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5) -#define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6) -/* used to negotiate communicating link speeds in Mbps */ -#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) - /* BIT(8) is reserved */ -#define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9) -#define VIRTCHNL_VF_OFFLOAD_CRC BIT(10) -#define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15) -#define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16) -#define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17) -#define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18) -#define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19) -#define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20) -#define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21) -#define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22) -#define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23) -#define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24) -#define VIRTCHNL_VF_OFFLOAD_USO BIT(25) - /* BIT(26) is reserved */ -#define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27) -#define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28) -#define VIRTCHNL_VF_OFFLOAD_QOS BIT(29) - /* BIT(30) is reserved */ -#define VIRTCHNL_VF_CAP_PTP BIT(31) - -#define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \ - VIRTCHNL_VF_OFFLOAD_VLAN | \ - VIRTCHNL_VF_OFFLOAD_RSS_PF) - -struct virtchnl_vf_resource { - u16 num_vsis; - u16 num_queue_pairs; - u16 max_vectors; - u16 max_mtu; - - u32 vf_cap_flags; - u32 rss_key_size; - u32 rss_lut_size; - - struct virtchnl_vsi_resource vsi_res[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource); - -/* VIRTCHNL_OP_CONFIG_TX_QUEUE - * VF sends this message to set up parameters for one TX queue. - * External data buffer contains one instance of virtchnl_txq_info. - * PF configures requested queue and returns a status code. - */ - -/* Tx queue config info */ -struct virtchnl_txq_info { - u16 vsi_id; - u16 queue_id; - u16 ring_len; /* number of descriptors, multiple of 8 */ - u16 headwb_enabled; /* deprecated with AVF 1.0 */ - u64 dma_ring_addr; - u64 dma_headwb_addr; /* deprecated with AVF 1.0 */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info); - -/* RX descriptor IDs (range from 0 to 63) */ -enum virtchnl_rx_desc_ids { - VIRTCHNL_RXDID_0_16B_BASE = 0, - VIRTCHNL_RXDID_1_32B_BASE = 1, - VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2, - VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3, - VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4, - VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5, - VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6, - VIRTCHNL_RXDID_7_HW_RSVD = 7, - /* 8 through 15 are reserved */ - VIRTCHNL_RXDID_16_COMMS_GENERIC = 16, - VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17, - VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18, - VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19, - VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20, - VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21, - /* 22 through 63 are reserved */ -}; - -/* RX descriptor ID bitmasks */ -enum virtchnl_rx_desc_id_bitmasks { - VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE), - VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE), - VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC), - VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW), - VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB), - VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL), - VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2), - VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD), - /* 9 through 15 are reserved */ - VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC), - VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN), - VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4), - VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6), - VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW), - VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP), - /* 22 through 63 are reserved */ -}; - -/* virtchnl_rxq_info_flags - * - * Definition of bits in the flags field of the virtchnl_rxq_info structure. - */ -enum virtchnl_rxq_info_flags { - /* If the VIRTCHNL_PTP_RX_TSTAMP bit of the flag field is set, this is - * a request to enable Rx timestamp. Other flag bits are currently - * reserved and they may be extended in the future. - */ - VIRTCHNL_PTP_RX_TSTAMP = BIT(0), -}; - -/* VIRTCHNL_OP_CONFIG_RX_QUEUE - * VF sends this message to set up parameters for one RX queue. - * External data buffer contains one instance of virtchnl_rxq_info. - * PF configures requested queue and returns a status code. The - * crc_disable flag disables CRC stripping on the VF. Setting - * the crc_disable flag to 1 will disable CRC stripping for each - * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC - * offload must have been set prior to sending this info or the PF - * will ignore the request. This flag should be set the same for - * all of the queues for a VF. - */ - -/* Rx queue config info */ -struct virtchnl_rxq_info { - u16 vsi_id; - u16 queue_id; - u32 ring_len; /* number of descriptors, multiple of 32 */ - u16 hdr_size; - u16 splithdr_enabled; /* deprecated with AVF 1.0 */ - u32 databuffer_size; - u32 max_pkt_size; - u8 crc_disable; - u8 pad1[3]; - u64 dma_ring_addr; - - /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */ - s32 rx_split_pos; - u32 pad2; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info); - -/* VIRTCHNL_OP_CONFIG_VSI_QUEUES - * VF sends this message to set parameters for active TX and RX queues - * associated with the specified VSI. - * PF configures queues and returns status. - * If the number of queues specified is greater than the number of queues - * associated with the VSI, an error is returned and no queues are configured. - * NOTE: The VF is not required to configure all queues in a single request. - * It may send multiple messages. PF drivers must correctly handle all VF - * requests. - */ -struct virtchnl_queue_pair_info { - /* NOTE: vsi_id and queue_id should be identical for both queues. */ - struct virtchnl_txq_info txq; - struct virtchnl_rxq_info rxq; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info); - -struct virtchnl_vsi_queue_config_info { - u16 vsi_id; - u16 num_queue_pairs; - u32 pad; - struct virtchnl_queue_pair_info qpair[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info); - -/* VIRTCHNL_OP_REQUEST_QUEUES - * VF sends this message to request the PF to allocate additional queues to - * this VF. Each VF gets a guaranteed number of queues on init but asking for - * additional queues must be negotiated. This is a best effort request as it - * is possible the PF does not have enough queues left to support the request. - * If the PF cannot support the number requested it will respond with the - * maximum number it is able to support. If the request is successful, PF will - * then reset the VF to institute required changes. - */ - -/* VF resource request */ -struct virtchnl_vf_res_request { - u16 num_queue_pairs; -}; - -/* VIRTCHNL_OP_CONFIG_IRQ_MAP - * VF uses this message to map vectors to queues. - * The rxq_map and txq_map fields are bitmaps used to indicate which queues - * are to be associated with the specified vector. - * The "other" causes are always mapped to vector 0. The VF may not request - * that vector 0 be used for traffic. - * PF configures interrupt mapping and returns status. - * NOTE: due to hardware requirements, all active queues (both TX and RX) - * should be mapped to interrupts, even if the driver intends to operate - * only in polling mode. In this case the interrupt may be disabled, but - * the ITR timer will still run to trigger writebacks. - */ -struct virtchnl_vector_map { - u16 vsi_id; - u16 vector_id; - u16 rxq_map; - u16 txq_map; - u16 rxitr_idx; - u16 txitr_idx; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map); - -struct virtchnl_irq_map_info { - u16 num_vectors; - struct virtchnl_vector_map vecmap[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info); - -/* VIRTCHNL_OP_ENABLE_QUEUES - * VIRTCHNL_OP_DISABLE_QUEUES - * VF sends these message to enable or disable TX/RX queue pairs. - * The queues fields are bitmaps indicating which queues to act upon. - * (Currently, we only support 16 queues per VF, but we make the field - * u32 to allow for expansion.) - * PF performs requested action and returns status. - * NOTE: The VF is not required to enable/disable all queues in a single - * request. It may send multiple messages. - * PF drivers must correctly handle all VF requests. - */ -struct virtchnl_queue_select { - u16 vsi_id; - u16 pad; - u32 rx_queues; - u32 tx_queues; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select); - -/* VIRTCHNL_OP_GET_MAX_RSS_QREGION - * - * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES - * then this op must be supported. - * - * VF sends this message in order to query the max RSS queue region - * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled. - * This information should be used when configuring the RSS LUT and/or - * configuring queue region based filters. - * - * The maximum RSS queue region is 2^qregion_width. So, a qregion_width - * of 6 would inform the VF that the PF supports a maximum RSS queue region - * of 64. - * - * A queue region represents a range of queues that can be used to configure - * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue - * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able - * to configure the RSS LUT with queue indices from 0 to 15. However, other - * filters can be used to direct packets to queues >15 via specifying a queue - * base/offset and queue region width. - */ -struct virtchnl_max_rss_qregion { - u16 vport_id; - u16 qregion_width; - u8 pad[4]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion); - -/* VIRTCHNL_OP_ADD_ETH_ADDR - * VF sends this message in order to add one or more unicast or multicast - * address filters for the specified VSI. - * PF adds the filters and returns status. - */ - -/* VIRTCHNL_OP_DEL_ETH_ADDR - * VF sends this message in order to remove one or more unicast or multicast - * filters for the specified VSI. - * PF removes the filters and returns status. - */ - -/* VIRTCHNL_ETHER_ADDR_LEGACY - * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad - * bytes. Moving forward all VF drivers should not set type to - * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy - * behavior. The control plane function (i.e. PF) can use a best effort method - * of tracking the primary/device unicast in this case, but there is no - * guarantee and functionality depends on the implementation of the PF. - */ - -/* VIRTCHNL_ETHER_ADDR_PRIMARY - * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the - * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and - * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane - * function (i.e. PF) to accurately track and use this MAC address for - * displaying on the host and for VM/function reset. - */ - -/* VIRTCHNL_ETHER_ADDR_EXTRA - * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra - * unicast and/or multicast filters that are being added/deleted via - * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively. - */ -struct virtchnl_ether_addr { - u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; - u8 type; -#define VIRTCHNL_ETHER_ADDR_LEGACY 0 -#define VIRTCHNL_ETHER_ADDR_PRIMARY 1 -#define VIRTCHNL_ETHER_ADDR_EXTRA 2 -#define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */ - u8 pad; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr); - -struct virtchnl_ether_addr_list { - u16 vsi_id; - u16 num_elements; - struct virtchnl_ether_addr list[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list); - -/* VIRTCHNL_OP_ADD_VLAN - * VF sends this message to add one or more VLAN tag filters for receives. - * PF adds the filters and returns status. - * If a port VLAN is configured by the PF, this operation will return an - * error to the VF. - */ - -/* VIRTCHNL_OP_DEL_VLAN - * VF sends this message to remove one or more VLAN tag filters for receives. - * PF removes the filters and returns status. - * If a port VLAN is configured by the PF, this operation will return an - * error to the VF. - */ - -struct virtchnl_vlan_filter_list { - u16 vsi_id; - u16 num_elements; - u16 vlan_id[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list); - -/* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related - * structures and opcodes. - * - * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver - * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED. - * - * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype. - * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype. - * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype. - * - * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported - * by the PF concurrently. For example, if the PF can support - * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it - * would OR the following bits: - * - * VIRTHCNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_AND; - * - * The VF would interpret this as VLAN filtering can be supported on both 0x8100 - * and 0x88A8 VLAN ethertypes. - * - * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported - * by the PF concurrently. For example if the PF can support - * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping - * offload it would OR the following bits: - * - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_XOR; - * - * The VF would interpret this as VLAN stripping can be supported on either - * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via - * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override - * the previously set value. - * - * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or - * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors. - * - * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware - * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor. - * - * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware - * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor. - * - * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for - * VLAN filtering if the underlying PF supports it. - * - * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a - * certain VLAN capability can be toggled. For example if the underlying PF/CP - * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should - * set this bit along with the supported ethertypes. - */ -enum virtchnl_vlan_support { - VIRTCHNL_VLAN_UNSUPPORTED = 0, - VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001, - VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002, - VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004, - VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100, - VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200, - VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400, - VIRTCHNL_VLAN_PRIO = 0x01000000, - VIRTCHNL_VLAN_FILTER_MASK = 0x10000000, - VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000, - VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000, - VIRTCHNL_VLAN_TOGGLE = 0x80000000 -}; - -/* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS - * for filtering, insertion, and stripping capabilities. - * - * If only outer capabilities are supported (for filtering, insertion, and/or - * stripping) then this refers to the outer most or single VLAN from the VF's - * perspective. - * - * If only inner capabilities are supported (for filtering, insertion, and/or - * stripping) then this refers to the outer most or single VLAN from the VF's - * perspective. Functionally this is the same as if only outer capabilities are - * supported. The VF driver is just forced to use the inner fields when - * adding/deleting filters and enabling/disabling offloads (if supported). - * - * If both outer and inner capabilities are supported (for filtering, insertion, - * and/or stripping) then outer refers to the outer most or single VLAN and - * inner refers to the second VLAN, if it exists, in the packet. - * - * There is no support for tunneled VLAN offloads, so outer or inner are never - * referring to a tunneled packet from the VF's perspective. - */ -struct virtchnl_vlan_supported_caps { - u32 outer; - u32 inner; -}; - -/* The PF populates these fields based on the supported VLAN filtering. If a - * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will - * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using - * the unsupported fields. - * - * Also, a VF is only allowed to toggle its VLAN filtering setting if the - * VIRTCHNL_VLAN_TOGGLE bit is set. - * - * The ethertype(s) specified in the ethertype_init field are the ethertypes - * enabled for VLAN filtering. VLAN filtering in this case refers to the outer - * most VLAN from the VF's perspective. If both inner and outer filtering are - * allowed then ethertype_init only refers to the outer most VLAN as only - * VLAN ethertype supported for inner VLAN filtering is - * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled - * when both inner and outer filtering are allowed. - * - * The max_filters field tells the VF how many VLAN filters it's allowed to have - * at any one time. If it exceeds this amount and tries to add another filter, - * then the request will be rejected by the PF. To prevent failures, the VF - * should keep track of how many VLAN filters it has added and not attempt to - * add more than max_filters. - */ -struct virtchnl_vlan_filtering_caps { - struct virtchnl_vlan_supported_caps filtering_support; - u32 ethertype_init; - u16 max_filters; - u8 pad[2]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps); - -/* This enum is used for the virtchnl_vlan_offload_caps structure to specify - * if the PF supports a different ethertype for stripping and insertion. - * - * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified - * for stripping affect the ethertype(s) specified for insertion and visa versa - * as well. If the VF tries to configure VLAN stripping via - * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then - * that will be the ethertype for both stripping and insertion. - * - * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for - * stripping do not affect the ethertype(s) specified for insertion and visa - * versa. - */ -enum virtchnl_vlan_ethertype_match { - VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0, - VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1, -}; - -/* The PF populates these fields based on the supported VLAN offloads. If a - * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will - * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or - * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields. - * - * Also, a VF is only allowed to toggle its VLAN offload setting if the - * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set. - * - * The VF driver needs to be aware of how the tags are stripped by hardware and - * inserted by the VF driver based on the level of offload support. The PF will - * populate these fields based on where the VLAN tags are expected to be - * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to - * interpret these fields. See the definition of the - * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support - * enumeration. - */ -struct virtchnl_vlan_offload_caps { - struct virtchnl_vlan_supported_caps stripping_support; - struct virtchnl_vlan_supported_caps insertion_support; - u32 ethertype_init; - u8 ethertype_match; - u8 pad[3]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps); - -/* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS - * VF sends this message to determine its VLAN capabilities. - * - * PF will mark which capabilities it supports based on hardware support and - * current configuration. For example, if a port VLAN is configured the PF will - * not allow outer VLAN filtering, stripping, or insertion to be configured so - * it will block these features from the VF. - * - * The VF will need to cross reference its capabilities with the PFs - * capabilities in the response message from the PF to determine the VLAN - * support. - */ -struct virtchnl_vlan_caps { - struct virtchnl_vlan_filtering_caps filtering; - struct virtchnl_vlan_offload_caps offloads; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps); - -struct virtchnl_vlan { - u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */ - u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in - * filtering caps - */ - u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in - * filtering caps. Note that tpid here does not refer to - * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the - * actual 2-byte VLAN TPID - */ - u8 pad[2]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan); - -struct virtchnl_vlan_filter { - struct virtchnl_vlan inner; - struct virtchnl_vlan outer; - u8 pad[16]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter); - -/* VIRTCHNL_OP_ADD_VLAN_V2 - * VIRTCHNL_OP_DEL_VLAN_V2 - * - * VF sends these messages to add/del one or more VLAN tag filters for Rx - * traffic. - * - * The PF attempts to add the filters and returns status. - * - * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the - * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS. - */ -struct virtchnl_vlan_filter_list_v2 { - u16 vport_id; - u16 num_elements; - u8 pad[4]; - struct virtchnl_vlan_filter filters[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2); - -/* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 - * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 - * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 - * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 - * - * VF sends this message to enable or disable VLAN stripping or insertion. It - * also needs to specify an ethertype. The VF knows which VLAN ethertypes are - * allowed and whether or not it's allowed to enable/disable the specific - * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to - * parse the virtchnl_vlan_caps.offloads fields to determine which offload - * messages are allowed. - * - * For example, if the PF populates the virtchnl_vlan_caps.offloads in the - * following manner the VF will be allowed to enable and/or disable 0x8100 inner - * VLAN insertion and/or stripping via the opcodes listed above. Inner in this - * case means the outer most or single VLAN from the VF's perspective. This is - * because no outer offloads are supported. See the comments above the - * virtchnl_vlan_supported_caps structure for more details. - * - * virtchnl_vlan_caps.offloads.stripping_support.inner = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100; - * - * virtchnl_vlan_caps.offloads.insertion_support.inner = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100; - * - * In order to enable inner (again note that in this case inner is the outer - * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100 - * VLANs, the VF would populate the virtchnl_vlan_setting structure in the - * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. - * - * virtchnl_vlan_setting.inner_ethertype_setting = - * VIRTCHNL_VLAN_ETHERTYPE_8100; - * - * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on - * initialization. - * - * The reason that VLAN TPID(s) are not being used for the - * outer_ethertype_setting and inner_ethertype_setting fields is because it's - * possible a device could support VLAN insertion and/or stripping offload on - * multiple ethertypes concurrently, so this method allows a VF to request - * multiple ethertypes in one message using the virtchnl_vlan_support - * enumeration. - * - * For example, if the PF populates the virtchnl_vlan_caps.offloads in the - * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer - * VLAN insertion and stripping simultaneously. The - * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be - * populated based on what the PF can support. - * - * virtchnl_vlan_caps.offloads.stripping_support.outer = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_AND; - * - * virtchnl_vlan_caps.offloads.insertion_support.outer = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_AND; - * - * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF - * would populate the virthcnl_vlan_offload_structure in the following manner - * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. - * - * virtchnl_vlan_setting.outer_ethertype_setting = - * VIRTHCNL_VLAN_ETHERTYPE_8100 | - * VIRTHCNL_VLAN_ETHERTYPE_88A8; - * - * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on - * initialization. - * - * There is also the case where a PF and the underlying hardware can support - * VLAN offloads on multiple ethertypes, but not concurrently. For example, if - * the PF populates the virtchnl_vlan_caps.offloads in the following manner the - * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN - * offloads. The ethertypes must match for stripping and insertion. - * - * virtchnl_vlan_caps.offloads.stripping_support.outer = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_XOR; - * - * virtchnl_vlan_caps.offloads.insertion_support.outer = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_XOR; - * - * virtchnl_vlan_caps.offloads.ethertype_match = - * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION; - * - * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would - * populate the virtchnl_vlan_setting structure in the following manner and send - * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the - * ethertype for VLAN insertion if it's enabled. So, for completeness, a - * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent. - * - * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8; - * - * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on - * initialization. - * - * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 - * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 - * - * VF sends this message to enable or disable VLAN filtering. It also needs to - * specify an ethertype. The VF knows which VLAN ethertypes are allowed and - * whether or not it's allowed to enable/disable filtering via the - * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to - * parse the virtchnl_vlan_caps.filtering fields to determine which, if any, - * filtering messages are allowed. - * - * For example, if the PF populates the virtchnl_vlan_caps.filtering in the - * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8 - * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND - * means that all filtering ethertypes will to be enabled and disabled together - * regardless of the request from the VF. This means that the underlying - * hardware only supports VLAN filtering for all VLAN the specified ethertypes - * or none of them. - * - * virtchnl_vlan_caps.filtering.filtering_support.outer = - * VIRTCHNL_VLAN_TOGGLE | - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTHCNL_VLAN_ETHERTYPE_88A8 | - * VIRTCHNL_VLAN_ETHERTYPE_9100 | - * VIRTCHNL_VLAN_ETHERTYPE_AND; - * - * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100 - * VLANs aren't supported by the VF driver), the VF would populate the - * virtchnl_vlan_setting structure in the following manner and send the - * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used - * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the - * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used. - * - * virtchnl_vlan_setting.outer_ethertype_setting = - * VIRTCHNL_VLAN_ETHERTYPE_8100 | - * VIRTCHNL_VLAN_ETHERTYPE_88A8; - * - */ -struct virtchnl_vlan_setting { - u32 outer_ethertype_setting; - u32 inner_ethertype_setting; - u16 vport_id; - u8 pad[6]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting); - -/* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE - * VF sends VSI id and flags. - * PF returns status code in retval. - * Note: we assume that broadcast accept mode is always enabled. - */ -struct virtchnl_promisc_info { - u16 vsi_id; - u16 flags; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info); - -#define FLAG_VF_UNICAST_PROMISC 0x00000001 -#define FLAG_VF_MULTICAST_PROMISC 0x00000002 - -/* VIRTCHNL_OP_GET_STATS - * VF sends this message to request stats for the selected VSI. VF uses - * the virtchnl_queue_select struct to specify the VSI. The queue_id - * field is ignored by the PF. - * - * PF replies with struct virtchnl_eth_stats in an external buffer. - */ - -struct virtchnl_eth_stats { - u64 rx_bytes; /* received bytes */ - u64 rx_unicast; /* received unicast pkts */ - u64 rx_multicast; /* received multicast pkts */ - u64 rx_broadcast; /* received broadcast pkts */ - u64 rx_discards; - u64 rx_unknown_protocol; - u64 tx_bytes; /* transmitted bytes */ - u64 tx_unicast; /* transmitted unicast pkts */ - u64 tx_multicast; /* transmitted multicast pkts */ - u64 tx_broadcast; /* transmitted broadcast pkts */ - u64 tx_discards; - u64 tx_errors; -}; - -/* VIRTCHNL_OP_CONFIG_RSS_KEY - * VIRTCHNL_OP_CONFIG_RSS_LUT - * VF sends these messages to configure RSS. Only supported if both PF - * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during - * configuration negotiation. If this is the case, then the RSS fields in - * the VF resource struct are valid. - * Both the key and LUT are initialized to 0 by the PF, meaning that - * RSS is effectively disabled until set up by the VF. - */ -struct virtchnl_rss_key { - u16 vsi_id; - u16 key_len; - u8 key[1]; /* RSS hash key, packed bytes */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key); - -struct virtchnl_rss_lut { - u16 vsi_id; - u16 lut_entries; - u8 lut[1]; /* RSS lookup table */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut); - -/* enum virthcnl_hash_filter - * - * Bits defining the hash filters in the hena field of the virtchnl_rss_hena - * structure. Each bit indicates a specific hash filter for RSS. - * - * Note that not all bits are supported on all hardware. The VF should use - * VIRTCHNL_OP_GET_RSS_HENA_CAPS to determine which bits the PF is capable of - * before using VIRTCHNL_OP_SET_RSS_HENA to enable specific filters. - */ -enum virtchnl_hash_filter { - /* Bits 0 through 28 are reserved for future use */ - /* Bit 29, 30, and 32 are not supported on XL710 a X710 */ - VIRTCHNL_HASH_FILTER_UNICAST_IPV4_UDP = 29, - VIRTCHNL_HASH_FILTER_MULTICAST_IPV4_UDP = 30, - VIRTCHNL_HASH_FILTER_IPV4_UDP = 31, - VIRTCHNL_HASH_FILTER_IPV4_TCP_SYN_NO_ACK = 32, - VIRTCHNL_HASH_FILTER_IPV4_TCP = 33, - VIRTCHNL_HASH_FILTER_IPV4_SCTP = 34, - VIRTCHNL_HASH_FILTER_IPV4_OTHER = 35, - VIRTCHNL_HASH_FILTER_FRAG_IPV4 = 36, - /* Bits 37 and 38 are reserved for future use */ - /* Bit 39, 40, and 42 are not supported on XL710 a X710 */ - VIRTCHNL_HASH_FILTER_UNICAST_IPV6_UDP = 39, - VIRTCHNL_HASH_FILTER_MULTICAST_IPV6_UDP = 40, - VIRTCHNL_HASH_FILTER_IPV6_UDP = 41, - VIRTCHNL_HASH_FILTER_IPV6_TCP_SYN_NO_ACK = 42, - VIRTCHNL_HASH_FILTER_IPV6_TCP = 43, - VIRTCHNL_HASH_FILTER_IPV6_SCTP = 44, - VIRTCHNL_HASH_FILTER_IPV6_OTHER = 45, - VIRTCHNL_HASH_FILTER_FRAG_IPV6 = 46, - /* Bit 37 is reserved for future use */ - VIRTCHNL_HASH_FILTER_FCOE_OX = 48, - VIRTCHNL_HASH_FILTER_FCOE_RX = 49, - VIRTCHNL_HASH_FILTER_FCOE_OTHER = 50, - /* Bits 51 through 62 are reserved for future use */ - VIRTCHNL_HASH_FILTER_L2_PAYLOAD = 63, -}; - -#define VIRTCHNL_HASH_FILTER_INVALID (0) - -/* VIRTCHNL_OP_GET_RSS_HENA_CAPS - * VIRTCHNL_OP_SET_RSS_HENA - * VF sends these messages to get and set the hash filter enable bits for RSS. - * By default, the PF sets these to all possible traffic types that the - * hardware supports. The VF can query this value if it wants to change the - * traffic types that are hashed by the hardware. - */ -struct virtchnl_rss_hena { - /* see enum virtchnl_hash_filter */ - u64 hena; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena); - -/* Type of RSS algorithm */ -enum virtchnl_rss_algorithm { - VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0, - VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1, - VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2, - VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3, -}; - -/* This is used by PF driver to enforce how many channels can be supported. - * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise - * PF driver will allow only max 4 channels - */ -#define VIRTCHNL_MAX_ADQ_CHANNELS 4 -#define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16 - -/* VIRTCHNL_OP_ENABLE_CHANNELS - * VIRTCHNL_OP_DISABLE_CHANNELS - * VF sends these messages to enable or disable channels based on - * the user specified queue count and queue offset for each traffic class. - * This struct encompasses all the information that the PF needs from - * VF to create a channel. - */ -struct virtchnl_channel_info { - u16 count; /* number of queues in a channel */ - u16 offset; /* queues in a channel start from 'offset' */ - u32 pad; - u64 max_tx_rate; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info); - -struct virtchnl_tc_info { - u32 num_tc; - u32 pad; - struct virtchnl_channel_info list[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info); - -/* VIRTCHNL_ADD_CLOUD_FILTER - * VIRTCHNL_DEL_CLOUD_FILTER - * VF sends these messages to add or delete a cloud filter based on the - * user specified match and action filters. These structures encompass - * all the information that the PF needs from the VF to add/delete a - * cloud filter. - */ - -struct virtchnl_l4_spec { - u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; - u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; - /* vlan_prio is part of this 16 bit field even from OS perspective - * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio - * in future, when decided to offload vlan_prio, pass that information - * as part of the "vlan_id" field, Bit14..12 - */ - __be16 vlan_id; - __be16 pad; /* reserved for future use */ - __be32 src_ip[4]; - __be32 dst_ip[4]; - __be16 src_port; - __be16 dst_port; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec); - -union virtchnl_flow_spec { - struct virtchnl_l4_spec tcp_spec; - u8 buffer[128]; /* reserved for future use */ -}; - -VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec); - -enum virtchnl_action { - /* action types */ - VIRTCHNL_ACTION_DROP = 0, - VIRTCHNL_ACTION_TC_REDIRECT, - VIRTCHNL_ACTION_PASSTHRU, - VIRTCHNL_ACTION_QUEUE, - VIRTCHNL_ACTION_Q_REGION, - VIRTCHNL_ACTION_MARK, - VIRTCHNL_ACTION_COUNT, -}; - -enum virtchnl_flow_type { - /* flow types */ - VIRTCHNL_TCP_V4_FLOW = 0, - VIRTCHNL_TCP_V6_FLOW, - VIRTCHNL_UDP_V4_FLOW, - VIRTCHNL_UDP_V6_FLOW, -}; - -struct virtchnl_filter { - union virtchnl_flow_spec data; - union virtchnl_flow_spec mask; - - /* see enum virtchnl_flow_type */ - s32 flow_type; - - /* see enum virtchnl_action */ - s32 action; - u32 action_meta; - u8 field_flags; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter); - -struct virtchnl_shaper_bw { - /* Unit is Kbps */ - u32 committed; - u32 peak; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw); - - - -/* VIRTCHNL_OP_EVENT - * PF sends this message to inform the VF driver of events that may affect it. - * No direct response is expected from the VF, though it may generate other - * messages in response to this one. - */ -enum virtchnl_event_codes { - VIRTCHNL_EVENT_UNKNOWN = 0, - VIRTCHNL_EVENT_LINK_CHANGE, - VIRTCHNL_EVENT_RESET_IMPENDING, - VIRTCHNL_EVENT_PF_DRIVER_CLOSE, -}; - -#define PF_EVENT_SEVERITY_INFO 0 -#define PF_EVENT_SEVERITY_ATTENTION 1 -#define PF_EVENT_SEVERITY_ACTION_REQUIRED 2 -#define PF_EVENT_SEVERITY_CERTAIN_DOOM 255 - -struct virtchnl_pf_event { - /* see enum virtchnl_event_codes */ - s32 event; - union { - /* If the PF driver does not support the new speed reporting - * capabilities then use link_event else use link_event_adv to - * get the speed and link information. The ability to understand - * new speeds is indicated by setting the capability flag - * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter - * in virtchnl_vf_resource struct and can be used to determine - * which link event struct to use below. - */ - struct { - enum virtchnl_link_speed link_speed; - bool link_status; - u8 pad[3]; - } link_event; - struct { - /* link_speed provided in Mbps */ - u32 link_speed; - u8 link_status; - u8 pad[3]; - } link_event_adv; - } event_data; - - s32 severity; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event); - - -/* VF reset states - these are written into the RSTAT register: - * VFGEN_RSTAT on the VF - * When the PF initiates a reset, it writes 0 - * When the reset is complete, it writes 1 - * When the PF detects that the VF has recovered, it writes 2 - * VF checks this register periodically to determine if a reset has occurred, - * then polls it to know when the reset is complete. - * If either the PF or VF reads the register while the hardware - * is in a reset state, it will return DEADBEEF, which, when masked - * will result in 3. - */ -enum virtchnl_vfr_states { - VIRTCHNL_VFR_INPROGRESS = 0, - VIRTCHNL_VFR_COMPLETED, - VIRTCHNL_VFR_VFACTIVE, -}; - -#define VIRTCHNL_MAX_NUM_PROTO_HDRS 32 -#define VIRTCHNL_MAX_SIZE_RAW_PACKET 1024 -#define PROTO_HDR_SHIFT 5 -#define PROTO_HDR_FIELD_START(proto_hdr_type) \ - (proto_hdr_type << PROTO_HDR_SHIFT) -#define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1) - -/* VF use these macros to configure each protocol header. - * Specify which protocol headers and protocol header fields base on - * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field. - * @param hdr: a struct of virtchnl_proto_hdr - * @param hdr_type: ETH/IPV4/TCP, etc - * @param field: SRC/DST/TEID/SPI, etc - */ -#define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \ - ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK)) -#define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \ - ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK)) -#define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \ - ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK)) -#define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector) - -#define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ - (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \ - VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) -#define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ - (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \ - VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) - -#define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \ - ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type) -#define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \ - (((hdr)->type) >> PROTO_HDR_SHIFT) -#define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \ - ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT))) -#define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \ - (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \ - VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val)) - -/* Protocol header type within a packet segment. A segment consists of one or - * more protocol headers that make up a logical group of protocol headers. Each - * logical group of protocol headers encapsulates or is encapsulated using/by - * tunneling or encapsulation protocols for network virtualization. - */ -enum virtchnl_proto_hdr_type { - VIRTCHNL_PROTO_HDR_NONE, - VIRTCHNL_PROTO_HDR_ETH, - VIRTCHNL_PROTO_HDR_S_VLAN, - VIRTCHNL_PROTO_HDR_C_VLAN, - VIRTCHNL_PROTO_HDR_IPV4, - VIRTCHNL_PROTO_HDR_IPV6, - VIRTCHNL_PROTO_HDR_TCP, - VIRTCHNL_PROTO_HDR_UDP, - VIRTCHNL_PROTO_HDR_SCTP, - VIRTCHNL_PROTO_HDR_GTPU_IP, - VIRTCHNL_PROTO_HDR_GTPU_EH, - VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN, - VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP, - VIRTCHNL_PROTO_HDR_PPPOE, - VIRTCHNL_PROTO_HDR_L2TPV3, - VIRTCHNL_PROTO_HDR_ESP, - VIRTCHNL_PROTO_HDR_AH, - VIRTCHNL_PROTO_HDR_PFCP, - VIRTCHNL_PROTO_HDR_GTPC, - VIRTCHNL_PROTO_HDR_ECPRI, - VIRTCHNL_PROTO_HDR_L2TPV2, - VIRTCHNL_PROTO_HDR_PPP, - /* IPv4 and IPv6 Fragment header types are only associated to - * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively, - * cannot be used independently. - */ - VIRTCHNL_PROTO_HDR_IPV4_FRAG, - VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, - VIRTCHNL_PROTO_HDR_GRE, -}; - -/* Protocol header field within a protocol header. */ -enum virtchnl_proto_hdr_field { - /* ETHER */ - VIRTCHNL_PROTO_HDR_ETH_SRC = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH), - VIRTCHNL_PROTO_HDR_ETH_DST, - VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE, - /* S-VLAN */ - VIRTCHNL_PROTO_HDR_S_VLAN_ID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN), - /* C-VLAN */ - VIRTCHNL_PROTO_HDR_C_VLAN_ID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN), - /* IPV4 */ - VIRTCHNL_PROTO_HDR_IPV4_SRC = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4), - VIRTCHNL_PROTO_HDR_IPV4_DST, - VIRTCHNL_PROTO_HDR_IPV4_DSCP, - VIRTCHNL_PROTO_HDR_IPV4_TTL, - VIRTCHNL_PROTO_HDR_IPV4_PROT, - VIRTCHNL_PROTO_HDR_IPV4_CHKSUM, - /* IPV6 */ - VIRTCHNL_PROTO_HDR_IPV6_SRC = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6), - VIRTCHNL_PROTO_HDR_IPV6_DST, - VIRTCHNL_PROTO_HDR_IPV6_TC, - VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT, - VIRTCHNL_PROTO_HDR_IPV6_PROT, - /* IPV6 Prefix */ - VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC, - VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST, - /* TCP */ - VIRTCHNL_PROTO_HDR_TCP_SRC_PORT = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP), - VIRTCHNL_PROTO_HDR_TCP_DST_PORT, - VIRTCHNL_PROTO_HDR_TCP_CHKSUM, - /* UDP */ - VIRTCHNL_PROTO_HDR_UDP_SRC_PORT = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP), - VIRTCHNL_PROTO_HDR_UDP_DST_PORT, - VIRTCHNL_PROTO_HDR_UDP_CHKSUM, - /* SCTP */ - VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP), - VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, - VIRTCHNL_PROTO_HDR_SCTP_CHKSUM, - /* GTPU_IP */ - VIRTCHNL_PROTO_HDR_GTPU_IP_TEID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP), - /* GTPU_EH */ - VIRTCHNL_PROTO_HDR_GTPU_EH_PDU = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH), - VIRTCHNL_PROTO_HDR_GTPU_EH_QFI, - /* PPPOE */ - VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE), - /* L2TPV3 */ - VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3), - /* ESP */ - VIRTCHNL_PROTO_HDR_ESP_SPI = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP), - /* AH */ - VIRTCHNL_PROTO_HDR_AH_SPI = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH), - /* PFCP */ - VIRTCHNL_PROTO_HDR_PFCP_S_FIELD = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP), - VIRTCHNL_PROTO_HDR_PFCP_SEID, - /* GTPC */ - VIRTCHNL_PROTO_HDR_GTPC_TEID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC), - /* ECPRI */ - VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI), - VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID, - /* IPv4 Dummy Fragment */ - VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG), - /* IPv6 Extension Fragment */ - VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG), - /* GTPU_DWN/UP */ - VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN), - VIRTCHNL_PROTO_HDR_GTPU_UP_QFI = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP), - /* L2TPv2 */ - VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID = - PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV2), - VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID, -}; - -struct virtchnl_proto_hdr { - /* see enum virtchnl_proto_hdr_type */ - s32 type; - u32 field_selector; /* a bit mask to select field for header type */ - u8 buffer[64]; - /** - * binary buffer in network order for specific header type. - * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4 - * header is expected to be copied into the buffer. - */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr); - -struct virtchnl_proto_hdrs { - u8 tunnel_level; - /** - * specify where protocol header start from. - * must be 0 when sending a raw packet request. - * 0 - from the outer layer - * 1 - from the first inner layer - * 2 - from the second inner layer - * .... - */ - int count; - /** - * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS - * must be 0 for a raw packet request. - */ - union { - struct virtchnl_proto_hdr - proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS]; - struct { - u16 pkt_len; - u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET]; - u8 mask[VIRTCHNL_MAX_SIZE_RAW_PACKET]; - } raw; - }; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs); - -struct virtchnl_rss_cfg { - struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */ - - /* see enum virtchnl_rss_algorithm; rss algorithm type */ - s32 rss_algorithm; - u8 reserved[128]; /* reserve for future */ -}; - -VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg); - -/* action configuration for FDIR */ -struct virtchnl_filter_action { - /* see enum virtchnl_action type */ - s32 type; - union { - /* used for queue and qgroup action */ - struct { - u16 index; - u8 region; - } queue; - /* used for count action */ - struct { - /* share counter ID with other flow rules */ - u8 shared; - u32 id; /* counter ID */ - } count; - /* used for mark action */ - u32 mark_id; - u8 reserve[32]; - } act_conf; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); - -#define VIRTCHNL_MAX_NUM_ACTIONS 8 - -struct virtchnl_filter_action_set { - /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ - int count; - struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set); - -/* pattern and action for FDIR rule */ -struct virtchnl_fdir_rule { - struct virtchnl_proto_hdrs proto_hdrs; - struct virtchnl_filter_action_set action_set; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule); - -/* Status returned to VF after VF requests FDIR commands - * VIRTCHNL_FDIR_SUCCESS - * VF FDIR related request is successfully done by PF - * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER. - * - * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE - * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource. - * - * VIRTCHNL_FDIR_FAILURE_RULE_EXIST - * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed. - * - * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT - * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule. - * - * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST - * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist. - * - * VIRTCHNL_FDIR_FAILURE_RULE_INVALID - * OP_ADD_FDIR_FILTER request is failed due to parameters validation - * or HW doesn't support. - * - * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT - * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out - * for programming. - * - * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID - * OP_QUERY_FDIR_FILTER request is failed due to parameters validation, - * for example, VF query counter of a rule who has no counter action. - */ -enum virtchnl_fdir_prgm_status { - VIRTCHNL_FDIR_SUCCESS = 0, - VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE, - VIRTCHNL_FDIR_FAILURE_RULE_EXIST, - VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT, - VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST, - VIRTCHNL_FDIR_FAILURE_RULE_INVALID, - VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT, - VIRTCHNL_FDIR_FAILURE_QUERY_INVALID, -}; - -/* VIRTCHNL_OP_ADD_FDIR_FILTER - * VF sends this request to PF by filling out vsi_id, - * validate_only and rule_cfg. PF will return flow_id - * if the request is successfully done and return add_status to VF. - */ -struct virtchnl_fdir_add { - u16 vsi_id; /* INPUT */ - /* - * 1 for validating a fdir rule, 0 for creating a fdir rule. - * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER. - */ - u16 validate_only; /* INPUT */ - u32 flow_id; /* OUTPUT */ - struct virtchnl_fdir_rule rule_cfg; /* INPUT */ - - /* see enum virtchnl_fdir_prgm_status; OUTPUT */ - s32 status; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add); - -/* VIRTCHNL_OP_DEL_FDIR_FILTER - * VF sends this request to PF by filling out vsi_id - * and flow_id. PF will return del_status to VF. - */ -struct virtchnl_fdir_del { - u16 vsi_id; /* INPUT */ - u16 pad; - u32 flow_id; /* INPUT */ - - /* see enum virtchnl_fdir_prgm_status; OUTPUT */ - s32 status; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del); - -/* VIRTCHNL_OP_GET_QOS_CAPS - * VF sends this message to get its QoS Caps, such as - * TC number, Arbiter and Bandwidth. - */ -struct virtchnl_qos_cap_elem { - u8 tc_num; - u8 tc_prio; -#define VIRTCHNL_ABITER_STRICT 0 -#define VIRTCHNL_ABITER_ETS 2 - u8 arbiter; -#define VIRTCHNL_STRICT_WEIGHT 1 - u8 weight; - enum virtchnl_bw_limit_type type; - union { - struct virtchnl_shaper_bw shaper; - u8 pad2[32]; - }; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem); - -struct virtchnl_qos_cap_list { - u16 vsi_id; - u16 num_elem; - struct virtchnl_qos_cap_elem cap[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list); - -/* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP - * VF sends message virtchnl_queue_tc_mapping to set queue to tc - * mapping for all the Tx and Rx queues with a specified VSI, and - * would get response about bitmap of valid user priorities - * associated with queues. - */ -struct virtchnl_queue_tc_mapping { - u16 vsi_id; - u16 num_tc; - u16 num_queue_pairs; - u8 pad[2]; - union { - struct { - u16 start_queue_id; - u16 queue_count; - } req; - struct { -#define VIRTCHNL_USER_PRIO_TYPE_UP 0 -#define VIRTCHNL_USER_PRIO_TYPE_DSCP 1 - u16 prio_type; - u16 valid_prio_bitmap; - } resp; - } tc[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping); - -/* VIRTCHNL_OP_CONFIG_QUEUE_BW */ -struct virtchnl_queue_bw { - u16 queue_id; - u8 tc; - u8 pad; - struct virtchnl_shaper_bw shaper; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_bw); - -struct virtchnl_queues_bw_cfg { - u16 vsi_id; - u16 num_queues; - struct virtchnl_queue_bw cfg[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queues_bw_cfg); - -/* queue types */ -enum virtchnl_queue_type { - VIRTCHNL_QUEUE_TYPE_TX = 0, - VIRTCHNL_QUEUE_TYPE_RX = 1, -}; - -/* structure to specify a chunk of contiguous queues */ -struct virtchnl_queue_chunk { - /* see enum virtchnl_queue_type */ - s32 type; - u16 start_queue_id; - u16 num_queues; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk); - -/* structure to specify several chunks of contiguous queues */ -struct virtchnl_queue_chunks { - u16 num_chunks; - u16 rsvd; - struct virtchnl_queue_chunk chunks[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks); - -/* VIRTCHNL_OP_ENABLE_QUEUES_V2 - * VIRTCHNL_OP_DISABLE_QUEUES_V2 - * - * These opcodes can be used if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in - * VIRTCHNL_OP_GET_VF_RESOURCES - * - * VF sends virtchnl_ena_dis_queues struct to specify the queues to be - * enabled/disabled in chunks. Also applicable to single queue RX or - * TX. PF performs requested action and returns status. - */ -struct virtchnl_del_ena_dis_queues { - u16 vport_id; - u16 pad; - struct virtchnl_queue_chunks chunks; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues); - -/* Virtchannel interrupt throttling rate index */ -enum virtchnl_itr_idx { - VIRTCHNL_ITR_IDX_0 = 0, - VIRTCHNL_ITR_IDX_1 = 1, - VIRTCHNL_ITR_IDX_NO_ITR = 3, -}; - -/* Queue to vector mapping */ -struct virtchnl_queue_vector { - u16 queue_id; - u16 vector_id; - u8 pad[4]; - - /* see enum virtchnl_itr_idx */ - s32 itr_idx; - - /* see enum virtchnl_queue_type */ - s32 queue_type; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector); - -/* VIRTCHNL_OP_MAP_QUEUE_VECTOR - * - * This opcode can be used only if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated - * in VIRTCHNL_OP_GET_VF_RESOURCES - * - * VF sends this message to map queues to vectors and ITR index registers. - * External data buffer contains virtchnl_queue_vector_maps structure - * that contains num_qv_maps of virtchnl_queue_vector structures. - * PF maps the requested queue vector maps after validating the queue and vector - * ids and returns a status code. - */ -struct virtchnl_queue_vector_maps { - u16 vport_id; - u16 num_qv_maps; - u8 pad[4]; - struct virtchnl_queue_vector qv_maps[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps); - -struct virtchnl_quanta_cfg { - u16 quanta_size; - struct virtchnl_queue_chunk queue_select; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg); - -/* VIRTCHNL_VF_CAP_PTP - * VIRTCHNL_OP_1588_PTP_GET_CAPS - * VIRTCHNL_OP_1588_PTP_GET_TIME - * VIRTCHNL_OP_1588_PTP_SET_TIME - * VIRTCHNL_OP_1588_PTP_ADJ_TIME - * VIRTCHNL_OP_1588_PTP_ADJ_FREQ - * VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP - * VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS - * VIRTCHNL_OP_1588_PTP_SET_PIN_CFG - * VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP - * - * Support for offloading control of the device PTP hardware clock (PHC) is enabled - * by VIRTCHNL_VF_CAP_PTP. This capability allows a VF to request that PF - * enable Tx and Rx timestamps, and request access to read and/or write the - * PHC on the device, as well as query if the VF has direct access to the PHC - * time registers. - * - * The VF must set VIRTCHNL_VF_CAP_PTP in its capabilities when requesting - * resources. If the capability is set in reply, the VF must then send - * a VIRTCHNL_OP_1588_PTP_GET_CAPS request during initialization. The VF indicates - * what extended capabilities it wants by setting the appropriate flags in the - * caps field. The PF reply will indicate what features are enabled for - * that VF. - */ -#define VIRTCHNL_1588_PTP_CAP_TX_TSTAMP BIT(0) -#define VIRTCHNL_1588_PTP_CAP_RX_TSTAMP BIT(1) -#define VIRTCHNL_1588_PTP_CAP_READ_PHC BIT(2) -#define VIRTCHNL_1588_PTP_CAP_WRITE_PHC BIT(3) -#define VIRTCHNL_1588_PTP_CAP_PHC_REGS BIT(4) -#define VIRTCHNL_1588_PTP_CAP_PIN_CFG BIT(5) - -/** - * virtchnl_phc_regs - * - * Structure defines how the VF should access PHC related registers. The VF - * must request VIRTCHNL_1588_PTP_CAP_PHC_REGS. If the VF has access to PHC - * registers, the PF will reply with the capability flag set, and with this - * structure detailing what PCIe region and what offsets to use. If direct - * access is not available, this entire structure is reserved and the fields - * will be zero. - * - * If necessary in a future extension, a separate capability mutually - * exclusive with VIRTCHNL_1588_PTP_CAP_PHC_REGS might be used to change the - * entire format of this structure within virtchnl_ptp_caps. - * - * @clock_hi: Register offset of the high 32 bits of clock time - * @clock_lo: Register offset of the low 32 bits of clock time - * @pcie_region: The PCIe region the registers are located in. - * @rsvd: Reserved bits for future extension - */ -struct virtchnl_phc_regs { - u32 clock_hi; - u32 clock_lo; - u8 pcie_region; - u8 rsvd[15]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_phc_regs); - -/* timestamp format enumeration - * - * VIRTCHNL_1588_PTP_TSTAMP_40BIT - * - * This format indicates a timestamp that uses the 40bit format from the - * flexible Rx descriptors. It is also the default Tx timestamp format used - * today. - * - * Such a timestamp has the following 40bit format: - * - * *--------------------------------*-------------------------------*-----------* - * | 32 bits of time in nanoseconds | 7 bits of sub-nanosecond time | valid bit | - * *--------------------------------*-------------------------------*-----------* - * - * The timestamp is passed in a u64, with the upper 24bits of the field - * reserved as zero. - * - * With this format, in order to report a full 64bit timestamp to userspace - * applications, the VF is responsible for performing timestamp extension by - * carefully comparing the timestamp with the PHC time. This can correctly - * be achieved with a recent cached copy of the PHC time by doing delta - * comparison between the 32bits of nanoseconds in the timestamp with the - * lower 32 bits of the clock time. For this to work, the cached PHC time - * must be from within 2^31 nanoseconds (~2.1 seconds) of when the timestamp - * was captured. - * - * VIRTCHNL_1588_PTP_TSTAMP_64BIT_NS - * - * This format indicates a timestamp that is 64 bits of nanoseconds. - */ -enum virtchnl_ptp_tstamp_format { - VIRTCHNL_1588_PTP_TSTAMP_40BIT = 0, - VIRTCHNL_1588_PTP_TSTAMP_64BIT_NS = 1, -}; - -/** - * virtchnl_ptp_caps - * - * Structure that defines the PTP capabilities available to the VF. The VF - * sends VIRTCHNL_OP_1588_PTP_GET_CAPS, and must fill in the ptp_caps field - * indicating what capabilities it is requesting. The PF will respond with the - * same message with the virtchnl_ptp_caps structure indicating what is - * enabled for the VF. - * - * @phc_regs: If VIRTCHNL_1588_PTP_CAP_PHC_REGS is set, contains information - * on the PHC related registers available to the VF. - * @caps: On send, VF sets what capabilities it requests. On reply, PF - * indicates what has been enabled for this VF. The PF shall not set - * bits which were not requested by the VF. - * @max_adj: The maximum adjustment capable of being requested by - * VIRTCHNL_OP_1588_PTP_ADJ_FREQ, in parts per billion. Note that 1 ppb - * is approximately 65.5 scaled_ppm. The PF shall clamp any - * frequency adjustment in VIRTCHNL_op_1588_ADJ_FREQ to +/- max_adj. - * Use of ppb in this field allows fitting the value into 4 bytes - * instead of potentially requiring 8 if scaled_ppm units were used. - * @tx_tstamp_idx: The Tx timestamp index to set in the transmit descriptor - * when requesting a timestamp for an outgoing packet. - * Reserved if VIRTCHNL_1588_PTP_CAP_TX_TSTAMP is not enabled. - * @n_ext_ts: Number of external timestamp functions available. Reserved - * if VIRTCHNL_1588_PTP_CAP_PIN_CFG is not enabled. - * @n_per_out: Number of periodic output functions available. Reserved if - * VIRTCHNL_1588_PTP_CAP_PIN_CFG is not enabled. - * @n_pins: Number of physical programmable pins able to be controlled. - * Reserved if VIRTCHNL_1588_PTP_CAP_PIN_CFG is not enabled. - * @tx_tstamp_format: Format of the Tx timestamps. Valid formats are defined - * by the virtchnl_ptp_tstamp enumeration. Note that Rx - * timestamps are tied to the descriptor format, and do not - * have a separate format field. - * @rsvd: Reserved bits for future extension. - * - * PTP capabilities - * - * VIRTCHNL_1588_PTP_CAP_TX_TSTAMP indicates that the VF can request transmit - * timestamps for packets in its transmit descriptors. If this is unset, - * transmit timestamp requests are ignored. Note that only one outstanding Tx - * timestamp request will be honored at a time. The PF shall handle receipt of - * the timestamp from the hardware, and will forward this to the VF by sending - * a VIRTCHNL_OP_1588_TX_TIMESTAMP message. - * - * VIRTCHNL_1588_PTP_CAP_RX_TSTAMP indicates that the VF receive queues have - * receive timestamps enabled in the flexible descriptors. Note that this - * requires a VF to also negotiate to enable advanced flexible descriptors in - * the receive path instead of the default legacy descriptor format. - * - * For a detailed description of the current Tx and Rx timestamp format, see - * the section on virtchnl_phc_tx_tstamp. Future extensions may indicate - * timestamp format in the capability structure. - * - * VIRTCHNL_1588_PTP_CAP_READ_PHC indicates that the VF may read the PHC time - * via the VIRTCHNL_OP_1588_PTP_GET_TIME command, or by directly reading PHC - * registers if VIRTCHNL_1588_PTP_CAP_PHC_REGS is also set. - * - * VIRTCHNL_1588_PTP_CAP_WRITE_PHC indicates that the VF may request updates - * to the PHC time via VIRTCHNL_OP_1588_PTP_SET_TIME, - * VIRTCHNL_OP_1588_PTP_ADJ_TIME, and VIRTCHNL_OP_1588_PTP_ADJ_FREQ. - * - * VIRTCHNL_1588_PTP_CAP_PHC_REGS indicates that the VF has direct access to - * certain PHC related registers, primarily for lower latency access to the - * PHC time. If this is set, the VF shall read the virtchnl_phc_regs section - * of the capabilities to determine the location of the clock registers. If - * this capability is not set, the entire 24 bytes of virtchnl_phc_regs is - * reserved as zero. Future extensions define alternative formats for this - * data, in which case they will be mutually exclusive with this capability. - * - * VIRTCHNL_1588_PTP_CAP_PIN_CFG indicates that the VF has the capability to - * control software defined pins. These pins can be assigned either as an - * input to timestamp external events, or as an output to cause a periodic - * signal output. - * - * Note that in the future, additional capability flags may be added which - * indicate additional extended support. All fields marked as reserved by this - * header will be set to zero. VF implementations should verify this to ensure - * that future extensions do not break compatibility. - */ -struct virtchnl_ptp_caps { - struct virtchnl_phc_regs phc_regs; - u32 caps; - s32 max_adj; - u8 tx_tstamp_idx; - u8 n_ext_ts; - u8 n_per_out; - u8 n_pins; - /* see enum virtchnl_ptp_tstamp_format */ - u8 tx_tstamp_format; - u8 rsvd[11]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_ptp_caps); - -/** - * virtchnl_phc_time - * @time: PHC time in nanoseconds - * @rsvd: Reserved for future extension - * - * Structure sent with VIRTCHNL_OP_1588_PTP_SET_TIME and received with - * VIRTCHNL_OP_1588_PTP_GET_TIME. Contains the 64bits of PHC clock time in - * nanoseconds. - * - * VIRTCHNL_OP_1588_PTP_SET_TIME may be sent by the VF if - * VIRTCHNL_1588_PTP_CAP_WRITE_PHC is set. This will request that the PHC time - * be set to the requested value. This operation is non-atomic and thus does - * not adjust for the delay between request and completion. It is recommended - * that the VF use VIRTCHNL_OP_1588_PTP_ADJ_TIME and - * VIRTCHNL_OP_1588_PTP_ADJ_FREQ when possible to steer the PHC clock. - * - * VIRTCHNL_OP_1588_PTP_GET_TIME may be sent to request the current time of - * the PHC. This op is available in case direct access via the PHC registers - * is not available. - */ -struct virtchnl_phc_time { - u64 time; - u8 rsvd[8]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_phc_time); - -/** - * virtchnl_phc_adj_time - * @delta: offset requested to adjust clock by - * @rsvd: reserved for future extension - * - * Sent with VIRTCHNL_OP_1588_PTP_ADJ_TIME. Used to request an adjustment of - * the clock time by the provided delta, with negative values representing - * subtraction. VIRTCHNL_OP_1588_PTP_ADJ_TIME may not be sent unless - * VIRTCHNL_1588_PTP_CAP_WRITE_PHC is set. - * - * The atomicity of this operation is not guaranteed. The PF should perform an - * atomic update using appropriate mechanisms if possible. However, this is - * not guaranteed. - */ -struct virtchnl_phc_adj_time { - s64 delta; - u8 rsvd[8]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_phc_adj_time); - -/** - * virtchnl_phc_adj_freq - * @scaled_ppm: frequency adjustment represented in scaled parts per million - * @rsvd: Reserved for future extension - * - * Sent with the VIRTCHNL_OP_1588_PTP_ADJ_FREQ to request an adjustment to the - * clock frequency. The adjustment is in scaled_ppm, which is parts per - * million with a 16bit binary fractional portion. 1 part per billion is - * approximately 65.5 scaled_ppm. - * - * ppm = scaled_ppm / 2^16 - * - * ppb = scaled_ppm * 1000 / 2^16 or - * - * ppb = scaled_ppm * 125 / 2^13 - * - * The PF shall clamp any adjustment request to plus or minus the specified - * max_adj in the PTP capabilities. - * - * Requests for adjustment are always based off of nominal clock frequency and - * not compounding. To reset clock frequency, send a request with a scaled_ppm - * of 0. - */ -struct virtchnl_phc_adj_freq { - s64 scaled_ppm; - u8 rsvd[8]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_phc_adj_freq); - -/** - * virtchnl_phc_tx_stamp - * @tstamp: timestamp value - * @rsvd: Reserved for future extension - * - * Sent along with VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP from the PF when a Tx - * timestamp for the index associated with this VF in the tx_tstamp_idx field - * is captured by hardware. - * - * If VIRTCHNL_1588_PTP_CAP_TX_TSTAMP is set, the VF may request a timestamp - * for a packet in its transmit context descriptor by setting the appropriate - * flag and setting the timestamp index provided by the PF. On transmission, - * the timestamp will be captured and sent to the PF. The PF will forward this - * timestamp to the VF via the VIRTCHNL_1588_PTP_CAP_TX_TSTAMP op. - * - * The timestamp format is defined by the tx_tstamp_format field of the - * virtchnl_ptp_caps structure. - */ -struct virtchnl_phc_tx_tstamp { - u64 tstamp; - u8 rsvd[8]; -}; -VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_phc_tx_tstamp); - -enum virtchnl_phc_pin_func { - VIRTCHNL_PHC_PIN_FUNC_NONE = 0, /* Not assigned to any function */ - VIRTCHNL_PHC_PIN_FUNC_EXT_TS = 1, /* Assigned to external timestamp */ - VIRTCHNL_PHC_PIN_FUNC_PER_OUT = 2, /* Assigned to periodic output */ -}; - -/* Length of the pin configuration data. All pin configurations belong within - * the same union and *must* have this length in bytes. - */ -#define VIRTCHNL_PIN_CFG_LEN 64 - -/* virtchnl_phc_ext_ts_mode - * - * Mode of the external timestamp, indicating which edges of the input signal - * to timestamp. - */ -enum virtchnl_phc_ext_ts_mode { - VIRTCHNL_PHC_EXT_TS_NONE = 0, - VIRTCHNL_PHC_EXT_TS_RISING_EDGE = 1, - VIRTCHNL_PHC_EXT_TS_FALLING_EDGE = 2, - VIRTCHNL_PHC_EXT_TS_BOTH_EDGES = 3, -}; - -/** - * virtchnl_phc_ext_ts - * @mode: mode of external timestamp request - * @rsvd: reserved for future extension - * - * External timestamp configuration. Defines the configuration for this - * external timestamp function. - * - * If mode is VIRTCHNL_PHC_EXT_TS_NONE, the function is essentially disabled, - * timestamping nothing. - * - * If mode is VIRTCHNL_PHC_EXT_TS_RISING_EDGE, the function shall timestamp - * the rising edge of the input when it transitions from low to high signal. - * - * If mode is VIRTCHNL_PHC_EXT_TS_FALLING_EDGE, the function shall timestamp - * the falling edge of the input when it transitions from high to low signal. - * - * If mode is VIRTCHNL_PHC_EXT_TS_BOTH_EDGES, the function shall timestamp - * both the rising and falling edge of the signal whenever it changes. - * - * The PF shall return an error if the requested mode cannot be implemented on - * the function. - */ -struct virtchnl_phc_ext_ts { - u8 mode; /* see virtchnl_phc_ext_ts_mode */ - u8 rsvd[63]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(VIRTCHNL_PIN_CFG_LEN, virtchnl_phc_ext_ts); - -/* virtchnl_phc_per_out_flags - * - * Flags defining periodic output functionality. - */ -enum virtchnl_phc_per_out_flags { - VIRTCHNL_PHC_PER_OUT_PHASE_START = BIT(0), -}; - -/** - * virtchnl_phc_per_out - * @start: absolute start time (if VIRTCHNL_PHC_PER_OUT_PHASE_START unset) - * @phase: phase offset to start (if VIRTCHNL_PHC_PER_OUT_PHASE_START set) - * @period: time to complete a full clock cycle (low - > high -> low) - * @on: length of time the signal should stay high - * @flags: flags defining the periodic output operation. - * rsvd: reserved for future extension - * - * Configuration for a periodic output signal. Used to define the signal that - * should be generated on a given function. - * - * The period field determines the full length of the clock cycle, including - * both duration hold high transition and duration to hold low transition in - * nanoseconds. - * - * The on field determines how long the signal should remain high. For - * a traditional square wave clock that is on for some duration and off for - * the same duration, use an on length of precisely half the period. The duty - * cycle of the clock is period/on. - * - * If VIRTCHNL_PHC_PER_OUT_PHASE_START is unset, then the request is to start - * a clock an absolute time. This means that the clock should start precisely - * at the specified time in the start field. If the start time is in the past, - * then the periodic output should start at the next valid multiple of the - * period plus the start time: - * - * new_start = (n * period) + start - * (choose n such that new start is in the future) - * - * Note that the PF should not reject a start time in the past because it is - * possible that such a start time was valid when the request was made, but - * became invalid due to delay in programming the pin. - * - * If VIRTCHNL_PHC_PER_OUT_PHASE_START is set, then the request is to start - * the next multiple of the period plus the phase offset. The phase must be - * less than the period. In this case, the clock should start as soon possible - * at the next available multiple of the period. To calculate a start time - * when programming this mode, use: - * - * start = (n * period) + phase - * (choose n such that start is in the future) - * - * A period of zero should be treated as a request to disable the clock - * output. - */ -struct virtchnl_phc_per_out { - union { - u64 start; - u64 phase; - }; - u64 period; - u64 on; - u32 flags; - u8 rsvd[36]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(VIRTCHNL_PIN_CFG_LEN, virtchnl_phc_per_out); - -/* virtchnl_phc_pin_cfg_flags - * - * Definition of bits in the flags field of the virtchnl_phc_pin_cfg - * structure. - */ -enum virtchnl_phc_pin_cfg_flags { - /* Valid for VIRTCHNL_OP_1588_PTP_SET_PIN_CFG. If set, indicates this - * is a request to verify if the function can be assigned to the - * provided pin. In this case, the ext_ts and per_out fields are - * ignored, and the PF response must be an error if the pin cannot be - * assigned to that function index. - */ - VIRTCHNL_PHC_PIN_CFG_VERIFY = BIT(0), -}; - -/** - * virtchnl_phc_set_pin - * @pin_index: The pin to get or set - * @func: the function type the pin is assigned to - * @func_index: the index of the function the pin is assigned to - * @ext_ts: external timestamp configuration - * @per_out: periodic output configuration - * @rsvd1: Reserved for future extension - * @rsvd2: Reserved for future extension - * - * Sent along with the VIRTCHNL_OP_1588_PTP_SET_PIN_CFG op. - * - * The VF issues a VIRTCHNL_OP_1588_PTP_SET_PIN_CFG to assign the pin to one - * of the functions. It must set the pin_index field, the func field, and - * the func_index field. The pin_index must be less than n_pins, and the - * func_index must be less than the n_ext_ts or n_per_out depending on which - * function type is selected. If func is for an external timestamp, the - * ext_ts field must be filled in with the desired configuration. Similarly, - * if the function is for a periodic output, the per_out field must be - * configured. - * - * If the VIRTCHNL_PHC_PIN_CFG_VERIFY bit of the flag field is set, this is - * a request only to verify the configuration, not to set it. In this case, - * the PF should simply report an error if the requested pin cannot be - * assigned to the requested function. This allows VF to determine whether or - * not a given function can be assigned to a specific pin. Other flag bits are - * currently reserved and must be verified as zero on both sides. They may be - * extended in the future. - */ -struct virtchnl_phc_set_pin { - u32 flags; /* see virtchnl_phc_pin_cfg_flags */ - u8 pin_index; - u8 func; /* see virtchnl_phc_pin_func */ - u8 func_index; - u8 rsvd1; - union { - struct virtchnl_phc_ext_ts ext_ts; - struct virtchnl_phc_per_out per_out; - }; - u8 rsvd2[8]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(80, virtchnl_phc_set_pin); - -/** - * virtchnl_phc_pin - * @pin_index: The pin to get or set - * @func: the function type the pin is assigned to - * @func_index: the index of the function the pin is assigned to - * @rsvd: Reserved for future extension - * @name: human readable pin name, supplied by PF on GET_PIN_CFGS - * - * Sent by the PF as part of the VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS response. - * - * The VF issues a VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS request to the PF in - * order to obtain the current pin configuration for all of the pins that were - * assigned to this VF. - * - * This structure details the pin configuration state, including a pin name - * and which function is assigned to the pin currently. - */ -struct virtchnl_phc_pin { - u8 pin_index; - u8 func; /* see virtchnl_phc_pin_func */ - u8 func_index; - u8 rsvd[5]; - char name[64]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_phc_pin); - -/** - * virtchnl_phc_pin_cfg - * @len: length of the variable pin config array - * @pins: variable length pin configuration array - * - * Variable structure sent by the PF in reply to - * VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS. The VF does not send this structure with - * its request of the operation. - * - * It is possible that the PF may need to send more pin configuration data - * than can be sent in one virtchnl message. To handle this, the PF should - * issue multiple VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS responses. Each response - * will indicate the number of pins it covers. The VF should be ready to wait - * for multiple responses until it has received a total length equal to the - * number of n_pins negotiated during extended PTP capabilities exchange. - */ -struct virtchnl_phc_get_pins { - u8 len; - u8 rsvd[7]; - struct virtchnl_phc_pin pins[1]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(80, virtchnl_phc_get_pins); - -/** - * virtchnl_phc_ext_stamp - * @tstamp: timestamp value - * @tstamp_rsvd: Reserved for future extension of the timestamp value. - * @tstamp_format: format of the timstamp - * @func_index: external timestamp function this timestamp is for - * @rsvd2: Reserved for future extension - * - * Sent along with the VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP from the PF when an - * external timestamp function is triggered. - * - * This will be sent only if one of the external timestamp functions is - * configured by the VF, and is only valid if VIRTCHNL_1588_PTP_CAP_PIN_CFG is - * negotiated with the PF. - * - * The timestamp format is defined by the tstamp_format field using the - * virtchnl_ptp_tstamp_format enumeration. The tstamp_rsvd field is - * exclusively reserved for possible future variants of the timestamp format, - * and its access will be controlled by the tstamp_format field. - */ -struct virtchnl_phc_ext_tstamp { - u64 tstamp; - u8 tstamp_rsvd[8]; - u8 tstamp_format; - u8 func_index; - u8 rsvd2[6]; -}; - -VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_phc_ext_tstamp); - -/* Since VF messages are limited by u16 size, precalculate the maximum possible - * values of nested elements in virtchnl structures that virtual channel can - * possibly handle in a single message. - */ -enum virtchnl_vector_limits { - VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX = - ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) / - sizeof(struct virtchnl_queue_pair_info), - - VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX = - ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) / - sizeof(struct virtchnl_vector_map), - - VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX = - ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) / - sizeof(struct virtchnl_ether_addr), - - VIRTCHNL_OP_ADD_DEL_VLAN_MAX = - ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) / - sizeof(u16), - - - VIRTCHNL_OP_ENABLE_CHANNELS_MAX = - ((u16)(~0) - sizeof(struct virtchnl_tc_info)) / - sizeof(struct virtchnl_channel_info), - - VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX = - ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) / - sizeof(struct virtchnl_queue_chunk), - - VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX = - ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) / - sizeof(struct virtchnl_queue_vector), - - VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX = - ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) / - sizeof(struct virtchnl_vlan_filter), -}; - -/** - * virtchnl_vc_validate_vf_msg - * @ver: Virtchnl version info - * @v_opcode: Opcode for the message - * @msg: pointer to the msg buffer - * @msglen: msg length - * - * validate msg format against struct for each opcode - */ -static inline int -virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode, - u8 *msg, u16 msglen) -{ - bool err_msg_format = false; - u32 valid_len = 0; - - /* Validate message length. */ - switch (v_opcode) { - case VIRTCHNL_OP_VERSION: - valid_len = sizeof(struct virtchnl_version_info); - break; - case VIRTCHNL_OP_RESET_VF: - break; - case VIRTCHNL_OP_GET_VF_RESOURCES: - if (VF_IS_V11(ver)) - valid_len = sizeof(u32); - break; - case VIRTCHNL_OP_CONFIG_TX_QUEUE: - valid_len = sizeof(struct virtchnl_txq_info); - break; - case VIRTCHNL_OP_CONFIG_RX_QUEUE: - valid_len = sizeof(struct virtchnl_rxq_info); - break; - case VIRTCHNL_OP_CONFIG_VSI_QUEUES: - valid_len = sizeof(struct virtchnl_vsi_queue_config_info); - if (msglen >= valid_len) { - struct virtchnl_vsi_queue_config_info *vqc = - (struct virtchnl_vsi_queue_config_info *)msg; - - if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs > - VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) { - err_msg_format = true; - break; - } - - valid_len += (vqc->num_queue_pairs * - sizeof(struct - virtchnl_queue_pair_info)); - } - break; - case VIRTCHNL_OP_CONFIG_IRQ_MAP: - valid_len = sizeof(struct virtchnl_irq_map_info); - if (msglen >= valid_len) { - struct virtchnl_irq_map_info *vimi = - (struct virtchnl_irq_map_info *)msg; - - if (vimi->num_vectors == 0 || vimi->num_vectors > - VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) { - err_msg_format = true; - break; - } - - valid_len += (vimi->num_vectors * - sizeof(struct virtchnl_vector_map)); - } - break; - case VIRTCHNL_OP_ENABLE_QUEUES: - case VIRTCHNL_OP_DISABLE_QUEUES: - valid_len = sizeof(struct virtchnl_queue_select); - break; - case VIRTCHNL_OP_GET_MAX_RSS_QREGION: - break; - case VIRTCHNL_OP_ADD_ETH_ADDR: - case VIRTCHNL_OP_DEL_ETH_ADDR: - valid_len = sizeof(struct virtchnl_ether_addr_list); - if (msglen >= valid_len) { - struct virtchnl_ether_addr_list *veal = - (struct virtchnl_ether_addr_list *)msg; - - if (veal->num_elements == 0 || veal->num_elements > - VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) { - err_msg_format = true; - break; - } - - valid_len += veal->num_elements * - sizeof(struct virtchnl_ether_addr); - } - break; - case VIRTCHNL_OP_ADD_VLAN: - case VIRTCHNL_OP_DEL_VLAN: - valid_len = sizeof(struct virtchnl_vlan_filter_list); - if (msglen >= valid_len) { - struct virtchnl_vlan_filter_list *vfl = - (struct virtchnl_vlan_filter_list *)msg; - - if (vfl->num_elements == 0 || vfl->num_elements > - VIRTCHNL_OP_ADD_DEL_VLAN_MAX) { - err_msg_format = true; - break; - } - - valid_len += vfl->num_elements * sizeof(u16); - } - break; - case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: - valid_len = sizeof(struct virtchnl_promisc_info); - break; - case VIRTCHNL_OP_GET_STATS: - valid_len = sizeof(struct virtchnl_queue_select); - break; - case VIRTCHNL_OP_CONFIG_RSS_KEY: - valid_len = sizeof(struct virtchnl_rss_key); - if (msglen >= valid_len) { - struct virtchnl_rss_key *vrk = - (struct virtchnl_rss_key *)msg; - - if (vrk->key_len == 0) { - /* zero length is allowed as input */ - break; - } - - valid_len += vrk->key_len - 1; - } - break; - case VIRTCHNL_OP_CONFIG_RSS_LUT: - valid_len = sizeof(struct virtchnl_rss_lut); - if (msglen >= valid_len) { - struct virtchnl_rss_lut *vrl = - (struct virtchnl_rss_lut *)msg; - - if (vrl->lut_entries == 0) { - /* zero entries is allowed as input */ - break; - } - - valid_len += vrl->lut_entries - 1; - } - break; - case VIRTCHNL_OP_GET_RSS_HENA_CAPS: - break; - case VIRTCHNL_OP_SET_RSS_HENA: - valid_len = sizeof(struct virtchnl_rss_hena); - break; - case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: - case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: - break; - case VIRTCHNL_OP_REQUEST_QUEUES: - valid_len = sizeof(struct virtchnl_vf_res_request); - break; - case VIRTCHNL_OP_ENABLE_CHANNELS: - valid_len = sizeof(struct virtchnl_tc_info); - if (msglen >= valid_len) { - struct virtchnl_tc_info *vti = - (struct virtchnl_tc_info *)msg; - - if (vti->num_tc == 0 || vti->num_tc > - VIRTCHNL_OP_ENABLE_CHANNELS_MAX) { - err_msg_format = true; - break; - } - - valid_len += (vti->num_tc - 1) * - sizeof(struct virtchnl_channel_info); - } - break; - case VIRTCHNL_OP_DISABLE_CHANNELS: - break; - case VIRTCHNL_OP_ADD_CLOUD_FILTER: - case VIRTCHNL_OP_DEL_CLOUD_FILTER: - valid_len = sizeof(struct virtchnl_filter); - break; - case VIRTCHNL_OP_ADD_RSS_CFG: - case VIRTCHNL_OP_DEL_RSS_CFG: - valid_len = sizeof(struct virtchnl_rss_cfg); - break; - case VIRTCHNL_OP_ADD_FDIR_FILTER: - valid_len = sizeof(struct virtchnl_fdir_add); - break; - case VIRTCHNL_OP_DEL_FDIR_FILTER: - valid_len = sizeof(struct virtchnl_fdir_del); - break; - case VIRTCHNL_OP_GET_QOS_CAPS: - break; - case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP: - valid_len = sizeof(struct virtchnl_queue_tc_mapping); - if (msglen >= valid_len) { - struct virtchnl_queue_tc_mapping *q_tc = - (struct virtchnl_queue_tc_mapping *)msg; - if (q_tc->num_tc == 0) { - err_msg_format = true; - break; - } - valid_len += (q_tc->num_tc - 1) * - sizeof(q_tc->tc[0]); - } - break; - case VIRTCHNL_OP_CONFIG_QUEUE_BW: - valid_len = sizeof(struct virtchnl_queues_bw_cfg); - if (msglen >= valid_len) { - struct virtchnl_queues_bw_cfg *q_bw = - (struct virtchnl_queues_bw_cfg *)msg; - if (q_bw->num_queues == 0) { - err_msg_format = true; - break; - } - valid_len += (q_bw->num_queues - 1) * - sizeof(q_bw->cfg[0]); - } - break; - case VIRTCHNL_OP_CONFIG_QUANTA: - valid_len = sizeof(struct virtchnl_quanta_cfg); - if (msglen >= valid_len) { - struct virtchnl_quanta_cfg *q_quanta = - (struct virtchnl_quanta_cfg *)msg; - if (q_quanta->quanta_size == 0 || - q_quanta->queue_select.num_queues == 0) { - err_msg_format = true; - break; - } - } - break; - case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS: - break; - case VIRTCHNL_OP_ADD_VLAN_V2: - case VIRTCHNL_OP_DEL_VLAN_V2: - valid_len = sizeof(struct virtchnl_vlan_filter_list_v2); - if (msglen >= valid_len) { - struct virtchnl_vlan_filter_list_v2 *vfl = - (struct virtchnl_vlan_filter_list_v2 *)msg; - - if (vfl->num_elements == 0 || vfl->num_elements > - VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) { - err_msg_format = true; - break; - } - - valid_len += (vfl->num_elements - 1) * - sizeof(struct virtchnl_vlan_filter); - } - break; - case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2: - case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2: - case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2: - case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2: - case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2: - case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2: - valid_len = sizeof(struct virtchnl_vlan_setting); - break; - case VIRTCHNL_OP_1588_PTP_GET_CAPS: - valid_len = sizeof(struct virtchnl_ptp_caps); - break; - case VIRTCHNL_OP_1588_PTP_GET_TIME: - case VIRTCHNL_OP_1588_PTP_SET_TIME: - valid_len = sizeof(struct virtchnl_phc_time); - break; - case VIRTCHNL_OP_1588_PTP_ADJ_TIME: - valid_len = sizeof(struct virtchnl_phc_adj_time); - break; - case VIRTCHNL_OP_1588_PTP_ADJ_FREQ: - valid_len = sizeof(struct virtchnl_phc_adj_freq); - break; - case VIRTCHNL_OP_1588_PTP_TX_TIMESTAMP: - valid_len = sizeof(struct virtchnl_phc_tx_tstamp); - break; - case VIRTCHNL_OP_1588_PTP_SET_PIN_CFG: - valid_len = sizeof(struct virtchnl_phc_set_pin); - break; - case VIRTCHNL_OP_1588_PTP_GET_PIN_CFGS: - break; - case VIRTCHNL_OP_1588_PTP_EXT_TIMESTAMP: - valid_len = sizeof(struct virtchnl_phc_ext_tstamp); - break; - case VIRTCHNL_OP_ENABLE_QUEUES_V2: - case VIRTCHNL_OP_DISABLE_QUEUES_V2: - valid_len = sizeof(struct virtchnl_del_ena_dis_queues); - if (msglen >= valid_len) { - struct virtchnl_del_ena_dis_queues *qs = - (struct virtchnl_del_ena_dis_queues *)msg; - if (qs->chunks.num_chunks == 0 || - qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) { - err_msg_format = true; - break; - } - valid_len += (qs->chunks.num_chunks - 1) * - sizeof(struct virtchnl_queue_chunk); - } - break; - case VIRTCHNL_OP_MAP_QUEUE_VECTOR: - valid_len = sizeof(struct virtchnl_queue_vector_maps); - if (msglen >= valid_len) { - struct virtchnl_queue_vector_maps *v_qp = - (struct virtchnl_queue_vector_maps *)msg; - if (v_qp->num_qv_maps == 0 || - v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) { - err_msg_format = true; - break; - } - valid_len += (v_qp->num_qv_maps - 1) * - sizeof(struct virtchnl_queue_vector); - } - break; - /* These are always errors coming from the VF. */ - case VIRTCHNL_OP_EVENT: - case VIRTCHNL_OP_UNKNOWN: - default: - return VIRTCHNL_STATUS_ERR_PARAM; - } - /* few more checks */ - if (err_msg_format || valid_len != msglen) - return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH; - - return 0; -} -#endif /* _VIRTCHNL_H_ */ diff --git a/dpdk/drivers/common/idpf/base/virtchnl_inline_ipsec.h b/dpdk/drivers/common/idpf/base/virtchnl_inline_ipsec.h deleted file mode 100644 index e19043ac4..000000000 --- a/dpdk/drivers/common/idpf/base/virtchnl_inline_ipsec.h +++ /dev/null @@ -1,567 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2001-2022 Intel Corporation - */ - -#ifndef _VIRTCHNL_INLINE_IPSEC_H_ -#define _VIRTCHNL_INLINE_IPSEC_H_ - -#define VIRTCHNL_IPSEC_MAX_CRYPTO_CAP_NUM 3 -#define VIRTCHNL_IPSEC_MAX_ALGO_CAP_NUM 16 -#define VIRTCHNL_IPSEC_MAX_TX_DESC_NUM 128 -#define VIRTCHNL_IPSEC_MAX_CRYPTO_ITEM_NUMBER 2 -#define VIRTCHNL_IPSEC_MAX_KEY_LEN 128 -#define VIRTCHNL_IPSEC_MAX_SA_DESTROY_NUM 8 -#define VIRTCHNL_IPSEC_SA_DESTROY 0 -#define VIRTCHNL_IPSEC_BROADCAST_VFID 0xFFFFFFFF -#define VIRTCHNL_IPSEC_INVALID_REQ_ID 0xFFFF -#define VIRTCHNL_IPSEC_INVALID_SA_CFG_RESP 0xFFFFFFFF -#define VIRTCHNL_IPSEC_INVALID_SP_CFG_RESP 0xFFFFFFFF - -/* crypto type */ -#define VIRTCHNL_AUTH 1 -#define VIRTCHNL_CIPHER 2 -#define VIRTCHNL_AEAD 3 - -/* caps enabled */ -#define VIRTCHNL_IPSEC_ESN_ENA BIT(0) -#define VIRTCHNL_IPSEC_UDP_ENCAP_ENA BIT(1) -#define VIRTCHNL_IPSEC_SA_INDEX_SW_ENA BIT(2) -#define VIRTCHNL_IPSEC_AUDIT_ENA BIT(3) -#define VIRTCHNL_IPSEC_BYTE_LIMIT_ENA BIT(4) -#define VIRTCHNL_IPSEC_DROP_ON_AUTH_FAIL_ENA BIT(5) -#define VIRTCHNL_IPSEC_ARW_CHECK_ENA BIT(6) -#define VIRTCHNL_IPSEC_24BIT_SPI_ENA BIT(7) - -/* algorithm type */ -/* Hash Algorithm */ -#define VIRTCHNL_HASH_NO_ALG 0 /* NULL algorithm */ -#define VIRTCHNL_AES_CBC_MAC 1 /* AES-CBC-MAC algorithm */ -#define VIRTCHNL_AES_CMAC 2 /* AES CMAC algorithm */ -#define VIRTCHNL_AES_GMAC 3 /* AES GMAC algorithm */ -#define VIRTCHNL_AES_XCBC_MAC 4 /* AES XCBC algorithm */ -#define VIRTCHNL_MD5_HMAC 5 /* HMAC using MD5 algorithm */ -#define VIRTCHNL_SHA1_HMAC 6 /* HMAC using 128 bit SHA algorithm */ -#define VIRTCHNL_SHA224_HMAC 7 /* HMAC using 224 bit SHA algorithm */ -#define VIRTCHNL_SHA256_HMAC 8 /* HMAC using 256 bit SHA algorithm */ -#define VIRTCHNL_SHA384_HMAC 9 /* HMAC using 384 bit SHA algorithm */ -#define VIRTCHNL_SHA512_HMAC 10 /* HMAC using 512 bit SHA algorithm */ -#define VIRTCHNL_SHA3_224_HMAC 11 /* HMAC using 224 bit SHA3 algorithm */ -#define VIRTCHNL_SHA3_256_HMAC 12 /* HMAC using 256 bit SHA3 algorithm */ -#define VIRTCHNL_SHA3_384_HMAC 13 /* HMAC using 384 bit SHA3 algorithm */ -#define VIRTCHNL_SHA3_512_HMAC 14 /* HMAC using 512 bit SHA3 algorithm */ -/* Cipher Algorithm */ -#define VIRTCHNL_CIPHER_NO_ALG 15 /* NULL algorithm */ -#define VIRTCHNL_3DES_CBC 16 /* Triple DES algorithm in CBC mode */ -#define VIRTCHNL_AES_CBC 17 /* AES algorithm in CBC mode */ -#define VIRTCHNL_AES_CTR 18 /* AES algorithm in Counter mode */ -/* AEAD Algorithm */ -#define VIRTCHNL_AES_CCM 19 /* AES algorithm in CCM mode */ -#define VIRTCHNL_AES_GCM 20 /* AES algorithm in GCM mode */ -#define VIRTCHNL_CHACHA20_POLY1305 21 /* algorithm of ChaCha20-Poly1305 */ - -/* protocol type */ -#define VIRTCHNL_PROTO_ESP 1 -#define VIRTCHNL_PROTO_AH 2 -#define VIRTCHNL_PROTO_RSVD1 3 - -/* sa mode */ -#define VIRTCHNL_SA_MODE_TRANSPORT 1 -#define VIRTCHNL_SA_MODE_TUNNEL 2 -#define VIRTCHNL_SA_MODE_TRAN_TUN 3 -#define VIRTCHNL_SA_MODE_UNKNOWN 4 - -/* sa direction */ -#define VIRTCHNL_DIR_INGRESS 1 -#define VIRTCHNL_DIR_EGRESS 2 -#define VIRTCHNL_DIR_INGRESS_EGRESS 3 - -/* sa termination */ -#define VIRTCHNL_TERM_SOFTWARE 1 -#define VIRTCHNL_TERM_HARDWARE 2 - -/* sa ip type */ -#define VIRTCHNL_IPV4 1 -#define VIRTCHNL_IPV6 2 - -/* for virtchnl_ipsec_resp */ -enum inline_ipsec_resp { - INLINE_IPSEC_SUCCESS = 0, - INLINE_IPSEC_FAIL = -1, - INLINE_IPSEC_ERR_FIFO_FULL = -2, - INLINE_IPSEC_ERR_NOT_READY = -3, - INLINE_IPSEC_ERR_VF_DOWN = -4, - INLINE_IPSEC_ERR_INVALID_PARAMS = -5, - INLINE_IPSEC_ERR_NO_MEM = -6, -}; - -/* Detailed opcodes for DPDK and IPsec use */ -enum inline_ipsec_ops { - INLINE_IPSEC_OP_GET_CAP = 0, - INLINE_IPSEC_OP_GET_STATUS = 1, - INLINE_IPSEC_OP_SA_CREATE = 2, - INLINE_IPSEC_OP_SA_UPDATE = 3, - INLINE_IPSEC_OP_SA_DESTROY = 4, - INLINE_IPSEC_OP_SP_CREATE = 5, - INLINE_IPSEC_OP_SP_DESTROY = 6, - INLINE_IPSEC_OP_SA_READ = 7, - INLINE_IPSEC_OP_EVENT = 8, - INLINE_IPSEC_OP_RESP = 9, -}; - -#pragma pack(1) -/* Not all valid, if certain field is invalid, set 1 for all bits */ -struct virtchnl_algo_cap { - u32 algo_type; - - u16 block_size; - - u16 min_key_size; - u16 max_key_size; - u16 inc_key_size; - - u16 min_iv_size; - u16 max_iv_size; - u16 inc_iv_size; - - u16 min_digest_size; - u16 max_digest_size; - u16 inc_digest_size; - - u16 min_aad_size; - u16 max_aad_size; - u16 inc_aad_size; -}; -#pragma pack() - -/* vf record the capability of crypto from the virtchnl */ -struct virtchnl_sym_crypto_cap { - u8 crypto_type; - u8 algo_cap_num; - struct virtchnl_algo_cap algo_cap_list[VIRTCHNL_IPSEC_MAX_ALGO_CAP_NUM]; -}; - -/* VIRTCHNL_OP_GET_IPSEC_CAP - * VF pass virtchnl_ipsec_cap to PF - * and PF return capability of ipsec from virtchnl. - */ -#pragma pack(1) -struct virtchnl_ipsec_cap { - /* max number of SA per VF */ - u16 max_sa_num; - - /* IPsec SA Protocol - value ref VIRTCHNL_PROTO_XXX */ - u8 virtchnl_protocol_type; - - /* IPsec SA Mode - value ref VIRTCHNL_SA_MODE_XXX */ - u8 virtchnl_sa_mode; - - /* IPSec SA Direction - value ref VIRTCHNL_DIR_XXX */ - u8 virtchnl_direction; - - /* termination mode - value ref VIRTCHNL_TERM_XXX */ - u8 termination_mode; - - /* number of supported crypto capability */ - u8 crypto_cap_num; - - /* descriptor ID */ - u16 desc_id; - - /* capabilities enabled - value ref VIRTCHNL_IPSEC_XXX_ENA */ - u32 caps_enabled; - - /* crypto capabilities */ - struct virtchnl_sym_crypto_cap cap[VIRTCHNL_IPSEC_MAX_CRYPTO_CAP_NUM]; -}; - -/* configuration of crypto function */ -struct virtchnl_ipsec_crypto_cfg_item { - u8 crypto_type; - - u32 algo_type; - - /* Length of valid IV data. */ - u16 iv_len; - - /* Length of digest */ - u16 digest_len; - - /* SA salt */ - u32 salt; - - /* The length of the symmetric key */ - u16 key_len; - - /* key data buffer */ - u8 key_data[VIRTCHNL_IPSEC_MAX_KEY_LEN]; -}; -#pragma pack() - -struct virtchnl_ipsec_sym_crypto_cfg { - struct virtchnl_ipsec_crypto_cfg_item - items[VIRTCHNL_IPSEC_MAX_CRYPTO_ITEM_NUMBER]; -}; - -#pragma pack(1) -/* VIRTCHNL_OP_IPSEC_SA_CREATE - * VF send this SA configuration to PF using virtchnl; - * PF create SA as configuration and PF driver will return - * an unique index (sa_idx) for the created SA. - */ -struct virtchnl_ipsec_sa_cfg { - /* IPsec SA Protocol - AH/ESP */ - u8 virtchnl_protocol_type; - - /* termination mode - value ref VIRTCHNL_TERM_XXX */ - u8 virtchnl_termination; - - /* type of outer IP - IPv4/IPv6 */ - u8 virtchnl_ip_type; - - /* type of esn - !0:enable/0:disable */ - u8 esn_enabled; - - /* udp encap - !0:enable/0:disable */ - u8 udp_encap_enabled; - - /* IPSec SA Direction - value ref VIRTCHNL_DIR_XXX */ - u8 virtchnl_direction; - - /* reserved */ - u8 reserved1; - - /* SA security parameter index */ - u32 spi; - - /* outer src ip address */ - u8 src_addr[16]; - - /* outer dst ip address */ - u8 dst_addr[16]; - - /* SPD reference. Used to link an SA with its policy. - * PF drivers may ignore this field. - */ - u16 spd_ref; - - /* high 32 bits of esn */ - u32 esn_hi; - - /* low 32 bits of esn */ - u32 esn_low; - - /* When enabled, sa_index must be valid */ - u8 sa_index_en; - - /* SA index when sa_index_en is true */ - u32 sa_index; - - /* auditing mode - enable/disable */ - u8 audit_en; - - /* lifetime byte limit - enable/disable - * When enabled, byte_limit_hard and byte_limit_soft - * must be valid. - */ - u8 byte_limit_en; - - /* hard byte limit count */ - u64 byte_limit_hard; - - /* soft byte limit count */ - u64 byte_limit_soft; - - /* drop on authentication failure - enable/disable */ - u8 drop_on_auth_fail_en; - - /* anti-reply window check - enable/disable - * When enabled, arw_size must be valid. - */ - u8 arw_check_en; - - /* size of arw window, offset by 1. Setting to 0 - * represents ARW window size of 1. Setting to 127 - * represents ARW window size of 128 - */ - u8 arw_size; - - /* no ip offload mode - enable/disable - * When enabled, ip type and address must not be valid. - */ - u8 no_ip_offload_en; - - /* SA Domain. Used to logical separate an SADB into groups. - * PF drivers supporting a single group ignore this field. - */ - u16 sa_domain; - - /* crypto configuration */ - struct virtchnl_ipsec_sym_crypto_cfg crypto_cfg; -}; -#pragma pack() - -/* VIRTCHNL_OP_IPSEC_SA_UPDATE - * VF send configuration of index of SA to PF - * PF will update SA according to configuration - */ -struct virtchnl_ipsec_sa_update { - u32 sa_index; /* SA to update */ - u32 esn_hi; /* high 32 bits of esn */ - u32 esn_low; /* low 32 bits of esn */ -}; - -#pragma pack(1) -/* VIRTCHNL_OP_IPSEC_SA_DESTROY - * VF send configuration of index of SA to PF - * PF will destroy SA according to configuration - * flag bitmap indicate all SA or just selected SA will - * be destroyed - */ -struct virtchnl_ipsec_sa_destroy { - /* All zero bitmap indicates all SA will be destroyed. - * Non-zero bitmap indicates the selected SA in - * array sa_index will be destroyed. - */ - u8 flag; - - /* selected SA index */ - u32 sa_index[VIRTCHNL_IPSEC_MAX_SA_DESTROY_NUM]; -}; - -/* VIRTCHNL_OP_IPSEC_SA_READ - * VF send this SA configuration to PF using virtchnl; - * PF read SA and will return configuration for the created SA. - */ -struct virtchnl_ipsec_sa_read { - /* SA valid - invalid/valid */ - u8 valid; - - /* SA active - inactive/active */ - u8 active; - - /* SA SN rollover - not_rollover/rollover */ - u8 sn_rollover; - - /* IPsec SA Protocol - AH/ESP */ - u8 virtchnl_protocol_type; - - /* termination mode - value ref VIRTCHNL_TERM_XXX */ - u8 virtchnl_termination; - - /* auditing mode - enable/disable */ - u8 audit_en; - - /* lifetime byte limit - enable/disable - * When set to limit, byte_limit_hard and byte_limit_soft - * must be valid. - */ - u8 byte_limit_en; - - /* hard byte limit count */ - u64 byte_limit_hard; - - /* soft byte limit count */ - u64 byte_limit_soft; - - /* drop on authentication failure - enable/disable */ - u8 drop_on_auth_fail_en; - - /* anti-replay window check - enable/disable - * When set to check, arw_size, arw_top, and arw must be valid - */ - u8 arw_check_en; - - /* size of arw window, offset by 1. Setting to 0 - * represents ARW window size of 1. Setting to 127 - * represents ARW window size of 128 - */ - u8 arw_size; - - /* reserved */ - u8 reserved1; - - /* top of anti-replay-window */ - u64 arw_top; - - /* anti-replay-window */ - u8 arw[16]; - - /* packets processed */ - u64 packets_processed; - - /* bytes processed */ - u64 bytes_processed; - - /* packets dropped */ - u32 packets_dropped; - - /* authentication failures */ - u32 auth_fails; - - /* ARW check failures */ - u32 arw_fails; - - /* type of esn - enable/disable */ - u8 esn; - - /* IPSec SA Direction - value ref VIRTCHNL_DIR_XXX */ - u8 virtchnl_direction; - - /* SA security parameter index */ - u32 spi; - - /* SA salt */ - u32 salt; - - /* high 32 bits of esn */ - u32 esn_hi; - - /* low 32 bits of esn */ - u32 esn_low; - - /* SA Domain. Used to logical separate an SADB into groups. - * PF drivers supporting a single group ignore this field. - */ - u16 sa_domain; - - /* SPD reference. Used to link an SA with its policy. - * PF drivers may ignore this field. - */ - u16 spd_ref; - - /* crypto configuration. Salt and keys are set to 0 */ - struct virtchnl_ipsec_sym_crypto_cfg crypto_cfg; -}; -#pragma pack() - -/* Add allowlist entry in IES */ -struct virtchnl_ipsec_sp_cfg { - u32 spi; - u32 dip[4]; - - /* Drop frame if true or redirect to QAT if false. */ - u8 drop; - - /* Congestion domain. For future use. */ - u8 cgd; - - /* 0 for IPv4 table, 1 for IPv6 table. */ - u8 table_id; - - /* Set TC (congestion domain) if true. For future use. */ - u8 set_tc; - - /* 0 for NAT-T unsupported, 1 for NAT-T supported */ - u8 is_udp; - - /* reserved */ - u8 reserved; - - /* NAT-T UDP port number. Only valid in case NAT-T supported */ - u16 udp_port; -}; - -#pragma pack(1) -/* Delete allowlist entry in IES */ -struct virtchnl_ipsec_sp_destroy { - /* 0 for IPv4 table, 1 for IPv6 table. */ - u8 table_id; - u32 rule_id; -}; -#pragma pack() - -/* Response from IES to allowlist operations */ -struct virtchnl_ipsec_sp_cfg_resp { - u32 rule_id; -}; - -struct virtchnl_ipsec_sa_cfg_resp { - u32 sa_handle; -}; - -#define INLINE_IPSEC_EVENT_RESET 0x1 -#define INLINE_IPSEC_EVENT_CRYPTO_ON 0x2 -#define INLINE_IPSEC_EVENT_CRYPTO_OFF 0x4 - -struct virtchnl_ipsec_event { - u32 ipsec_event_data; -}; - -#define INLINE_IPSEC_STATUS_AVAILABLE 0x1 -#define INLINE_IPSEC_STATUS_UNAVAILABLE 0x2 - -struct virtchnl_ipsec_status { - u32 status; -}; - -struct virtchnl_ipsec_resp { - u32 resp; -}; - -/* Internal message descriptor for VF <-> IPsec communication */ -struct inline_ipsec_msg { - u16 ipsec_opcode; - u16 req_id; - - union { - /* IPsec request */ - struct virtchnl_ipsec_sa_cfg sa_cfg[0]; - struct virtchnl_ipsec_sp_cfg sp_cfg[0]; - struct virtchnl_ipsec_sa_update sa_update[0]; - struct virtchnl_ipsec_sa_destroy sa_destroy[0]; - struct virtchnl_ipsec_sp_destroy sp_destroy[0]; - - /* IPsec response */ - struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp[0]; - struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp[0]; - struct virtchnl_ipsec_cap ipsec_cap[0]; - struct virtchnl_ipsec_status ipsec_status[0]; - /* response to del_sa, del_sp, update_sa */ - struct virtchnl_ipsec_resp ipsec_resp[0]; - - /* IPsec event (no req_id is required) */ - struct virtchnl_ipsec_event event[0]; - - /* Reserved */ - struct virtchnl_ipsec_sa_read sa_read[0]; - } ipsec_data; -}; - -static inline u16 virtchnl_inline_ipsec_val_msg_len(u16 opcode) -{ - u16 valid_len = sizeof(struct inline_ipsec_msg); - - switch (opcode) { - case INLINE_IPSEC_OP_GET_CAP: - case INLINE_IPSEC_OP_GET_STATUS: - break; - case INLINE_IPSEC_OP_SA_CREATE: - valid_len += sizeof(struct virtchnl_ipsec_sa_cfg); - break; - case INLINE_IPSEC_OP_SP_CREATE: - valid_len += sizeof(struct virtchnl_ipsec_sp_cfg); - break; - case INLINE_IPSEC_OP_SA_UPDATE: - valid_len += sizeof(struct virtchnl_ipsec_sa_update); - break; - case INLINE_IPSEC_OP_SA_DESTROY: - valid_len += sizeof(struct virtchnl_ipsec_sa_destroy); - break; - case INLINE_IPSEC_OP_SP_DESTROY: - valid_len += sizeof(struct virtchnl_ipsec_sp_destroy); - break; - /* Only for msg length calculation of response to VF in case of - * inline ipsec failure. - */ - case INLINE_IPSEC_OP_RESP: - valid_len += sizeof(struct virtchnl_ipsec_resp); - break; - default: - valid_len = 0; - break; - } - - return valid_len; -} - -#endif /* _VIRTCHNL_INLINE_IPSEC_H_ */ diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca.c deleted file mode 100644 index 7b9cec09d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_burst.c deleted file mode 100644 index 55cb3a47e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg.c deleted file mode 100644 index 1d427ea19..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg_burst.c deleted file mode 100644 index a4ceb2cbc..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo.c deleted file mode 100644 index 3cd179933..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_burst.c deleted file mode 100644 index 6433093e5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg.c deleted file mode 100644 index 42fc7fd2f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg_burst.c deleted file mode 100644 index 94a5522e7..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_0_15_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca.c deleted file mode 100644 index d31cfdfd5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_burst.c deleted file mode 100644 index 333ef3f8a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg.c deleted file mode 100644 index f3a26618b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg_burst.c deleted file mode 100644 index f16fd0439..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo.c deleted file mode 100644 index eeac9e34a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_burst.c deleted file mode 100644 index 73fa82278..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg.c deleted file mode 100644 index a5746fa64..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg_burst.c deleted file mode 100644 index 032265533..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_112_127_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca.c deleted file mode 100644 index 93e33f5b5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_burst.c deleted file mode 100644 index b829aa0fc..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg.c deleted file mode 100644 index a7e96d41b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg_burst.c deleted file mode 100644 index ab9acd463..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo.c deleted file mode 100644 index 312fbc633..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_burst.c deleted file mode 100644 index 1f5b96cbb..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg.c deleted file mode 100644 index fb0b6cf69..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg_burst.c deleted file mode 100644 index 4d13be7a1..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_16_31_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca.c deleted file mode 100644 index 875e44279..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_burst.c deleted file mode 100644 index 9410e4864..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg.c deleted file mode 100644 index d45fe712b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg_burst.c deleted file mode 100644 index c0439536a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo.c deleted file mode 100644 index da010b002..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_burst.c deleted file mode 100644 index 5da95b21c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg.c deleted file mode 100644 index 65af91363..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg_burst.c deleted file mode 100644 index cff7e40fd..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_32_47_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca.c deleted file mode 100644 index e5783d18b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_burst.c deleted file mode 100644 index e4355853c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg.c deleted file mode 100644 index 269ead74c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg_burst.c deleted file mode 100644 index b64625425..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo.c deleted file mode 100644 index b7f8f6773..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_burst.c deleted file mode 100644 index 9a9cff9e1..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg.c deleted file mode 100644 index fffcad0c3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg_burst.c deleted file mode 100644 index 347dabd04..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_48_63_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca.c deleted file mode 100644 index b201b8a64..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_burst.c deleted file mode 100644 index b8e9bdbbd..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg.c deleted file mode 100644 index f3bccc222..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg_burst.c deleted file mode 100644 index 0057d6e89..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo.c deleted file mode 100644 index 216c54c51..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_burst.c deleted file mode 100644 index e17cf532a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg.c deleted file mode 100644 index d9186112c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg_burst.c deleted file mode 100644 index 4272ff2a5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_64_79_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca.c deleted file mode 100644 index 85253c20c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_burst.c deleted file mode 100644 index d624789f4..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg.c deleted file mode 100644 index b9cd213bf..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg_burst.c deleted file mode 100644 index ac152703a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo.c deleted file mode 100644 index 16b16e6a6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_burst.c deleted file mode 100644 index df284b78f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg.c deleted file mode 100644 index c890c504c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg_burst.c deleted file mode 100644 index 6af6918db..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_80_95_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca.c deleted file mode 100644 index 0e97b764d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_DEQ_CA(cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_burst.c deleted file mode 100644 index f23317bbd..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_burst_##name, \ - cn10k_sso_hws_deq_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg.c deleted file mode 100644 index be3178c5b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_DEQ_CA_SEG(cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg_burst.c deleted file mode 100644 index b0e2a106e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo.c deleted file mode 100644 index 60d0a5ac5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_DEQ_TMO_CA(cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_burst.c deleted file mode 100644 index 5f9479dd5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg.c deleted file mode 100644 index 769e78471..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg.c +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, \ - flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg_burst.c deleted file mode 100644 index 53ec7c0a4..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn10k/deq_96_111_ca_tmo_seg_burst.c +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn10k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_deq_tmo_ca_seg_##name, flags) \ - SSO_CMN_DEQ_BURST(cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name, \ - cn10k_sso_hws_reas_deq_tmo_ca_seg_##name, flags | NIX_RX_REAS_F) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca.c deleted file mode 100644 index ce4e57723..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_burst.c deleted file mode 100644 index 4f36ae2ee..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg.c deleted file mode 100644 index 0d64fa1f4..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg_burst.c deleted file mode 100644 index 23e21c29c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo.c deleted file mode 100644 index eba487394..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_burst.c deleted file mode 100644 index 1bd7ae530..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg.c deleted file mode 100644 index ff004823d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg_burst.c deleted file mode 100644 index e4905b36b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca.c deleted file mode 100644 index 2f74cc105..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_burst.c deleted file mode 100644 index dcf127de9..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg.c deleted file mode 100644 index b06a6bc6a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg_burst.c deleted file mode 100644 index 378a70bd9..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo.c deleted file mode 100644 index 8d734beee..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_burst.c deleted file mode 100644 index f6c02719d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg.c deleted file mode 100644 index ed89253c6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg_burst.c deleted file mode 100644 index af72ed944..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_0_15_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_0_15 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca.c deleted file mode 100644 index 3ef8f438e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_burst.c deleted file mode 100644 index 81d12dc55..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg.c deleted file mode 100644 index 7f5e9da9e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg_burst.c deleted file mode 100644 index a476064ae..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo.c deleted file mode 100644 index 14305ff0f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_burst.c deleted file mode 100644 index 8d5b19a9b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg.c deleted file mode 100644 index 35004a8ac..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg_burst.c deleted file mode 100644 index 29f1341a3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca.c deleted file mode 100644 index 333920acb..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_burst.c deleted file mode 100644 index 6ba41b810..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg.c deleted file mode 100644 index bd1643e8b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg_burst.c deleted file mode 100644 index ffc571942..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo.c deleted file mode 100644 index ec47a20be..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_burst.c deleted file mode 100644 index 58aa93f85..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg.c deleted file mode 100644 index 88e4b92b0..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg_burst.c deleted file mode 100644 index 737a24332..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_112_127_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_112_127 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca.c deleted file mode 100644 index b260fdadf..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_burst.c deleted file mode 100644 index ae2e48a27..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg.c deleted file mode 100644 index 2258d53a4..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg_burst.c deleted file mode 100644 index 206e03ce8..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo.c deleted file mode 100644 index 9c6b6dd2e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_burst.c deleted file mode 100644 index 8318627a3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg.c deleted file mode 100644 index b6d00400f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg_burst.c deleted file mode 100644 index a1cad96f7..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca.c deleted file mode 100644 index 42de2be88..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_burst.c deleted file mode 100644 index 8fb19a8d3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg.c deleted file mode 100644 index 6904d3c74..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg_burst.c deleted file mode 100644 index de0e91e8b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo.c deleted file mode 100644 index 8a0bf384f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_burst.c deleted file mode 100644 index ccf9a3f00..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg.c deleted file mode 100644 index af4f90098..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg_burst.c deleted file mode 100644 index 6dd99f72d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_16_31_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_16_31 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca.c deleted file mode 100644 index f2ef6cc6b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_burst.c deleted file mode 100644 index 313ecc739..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg.c deleted file mode 100644 index ae8cd5be6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg_burst.c deleted file mode 100644 index 40ecba623..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo.c deleted file mode 100644 index 10a2b6a75..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_burst.c deleted file mode 100644 index fbe3a7338..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg.c deleted file mode 100644 index 6366b5009..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg_burst.c deleted file mode 100644 index 5749a3c08..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca.c deleted file mode 100644 index 2ba290970..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_burst.c deleted file mode 100644 index b2f7d142b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg.c deleted file mode 100644 index abb7093e3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg_burst.c deleted file mode 100644 index 086398937..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo.c deleted file mode 100644 index 11e03c41c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_burst.c deleted file mode 100644 index 64daa1c5a..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg.c deleted file mode 100644 index 5ef0cbfc2..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg_burst.c deleted file mode 100644 index fc604c7e3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_32_47_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_32_47 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca.c deleted file mode 100644 index 0033b7ac8..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_burst.c deleted file mode 100644 index 939811ac8..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg.c deleted file mode 100644 index 16ddbbaa6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg_burst.c deleted file mode 100644 index 6c2aeddb0..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo.c deleted file mode 100644 index 66adc2a6c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_burst.c deleted file mode 100644 index 7337e071c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg.c deleted file mode 100644 index eaa7bdd39..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg_burst.c deleted file mode 100644 index 89b42c63b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca.c deleted file mode 100644 index e92ada449..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_burst.c deleted file mode 100644 index a72d7e7dc..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg.c deleted file mode 100644 index d299c4f2f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg_burst.c deleted file mode 100644 index decf0bfcc..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo.c deleted file mode 100644 index 218f72aee..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_burst.c deleted file mode 100644 index 8232bbdd1..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg.c deleted file mode 100644 index 4f03ca514..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg_burst.c deleted file mode 100644 index fdd8a0552..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_48_63_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_48_63 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca.c deleted file mode 100644 index ad76b572d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_burst.c deleted file mode 100644 index 7c98aeaff..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg.c deleted file mode 100644 index 28ce2dda6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg_burst.c deleted file mode 100644 index 183984ca8..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo.c deleted file mode 100644 index 1d89f9db5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_burst.c deleted file mode 100644 index f83435b81..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg.c deleted file mode 100644 index 7e721ba3d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg_burst.c deleted file mode 100644 index b767416d9..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca.c deleted file mode 100644 index 22d129431..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_burst.c deleted file mode 100644 index 4ef92f7d6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg.c deleted file mode 100644 index 6132f83d5..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg_burst.c deleted file mode 100644 index 2017f3fa8..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo.c deleted file mode 100644 index f72d6bcc9..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_burst.c deleted file mode 100644 index 6d646d8c4..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg.c deleted file mode 100644 index 310fd3c94..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg_burst.c deleted file mode 100644 index 9e7afaf2c..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_64_79_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_64_79 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca.c deleted file mode 100644 index 67c527b14..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_burst.c deleted file mode 100644 index 97d826458..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg.c deleted file mode 100644 index 38769c473..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg_burst.c deleted file mode 100644 index 77d857b3d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo.c deleted file mode 100644 index d48f314d3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_burst.c deleted file mode 100644 index 894546b0b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg.c deleted file mode 100644 index e704ee256..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg_burst.c deleted file mode 100644 index b1fac5c5f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca.c deleted file mode 100644 index 5c4548752..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_burst.c deleted file mode 100644 index 8c4e17f2e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg.c deleted file mode 100644 index b18af8f8b..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg_burst.c deleted file mode 100644 index ba58284bf..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo.c deleted file mode 100644 index 3f8fa2de0..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_burst.c deleted file mode 100644 index 03027f809..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg.c deleted file mode 100644 index 27bb4f00f..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg_burst.c deleted file mode 100644 index 8cb3a0750..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_80_95_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_80_95 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca.c deleted file mode 100644 index 8424824de..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA(cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_burst.c deleted file mode 100644 index 1cb92b3db..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_burst_##name, \ - cn9k_sso_hws_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg.c deleted file mode 100644 index ef3248cdf..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_CA_SEG(cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg_burst.c deleted file mode 100644 index 1faf9ead3..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo.c deleted file mode 100644 index 5df139ecc..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DEQ_TMO_CA(cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_burst.c deleted file mode 100644 index 1ce5f30c1..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg.c deleted file mode 100644 index def241f0d..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DEQ_TMO_CA_SEG(cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg_burst.c deleted file mode 100644 index 10f2821f6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca.c deleted file mode 100644 index d1b4378ad..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) SSO_DUAL_DEQ_CA(cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_burst.c deleted file mode 100644 index c3060bdf6..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg.c deleted file mode 100644 index 2d6e44c3e..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_CA_SEG(cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg_burst.c deleted file mode 100644 index 57923eb61..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo.c deleted file mode 100644 index a448618ad..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA(cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_burst.c deleted file mode 100644 index b6d197376..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg.c deleted file mode 100644 index b0b78b1be..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg.c +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_DUAL_DEQ_TMO_CA_SEG(cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg_burst.c b/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg_burst.c deleted file mode 100644 index 1e95e2755..000000000 --- a/dpdk/drivers/event/cnxk/deq/cn9k/deq_96_111_dual_ca_tmo_seg_burst.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2022 Marvell. - */ - -#include "cn9k_worker.h" -#include "cnxk_eventdev.h" -#include "cnxk_worker.h" - -#define R(name, flags) \ - SSO_CMN_DEQ_BURST(cn9k_sso_hws_dual_deq_tmo_ca_seg_burst_##name, \ - cn9k_sso_hws_dual_deq_tmo_ca_seg_##name, flags) - -NIX_RX_FASTPATH_MODES_96_111 -#undef R diff --git a/dpdk/drivers/net/ark/ark_rqp.c b/dpdk/drivers/net/ark/ark_rqp.c deleted file mode 100644 index efb9730fe..000000000 --- a/dpdk/drivers/net/ark/ark_rqp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2015-2018 Atomic Rules LLC - */ - -#include - -#include "ark_rqp.h" -#include "ark_logs.h" - -/* ************************************************************************* */ -void -ark_rqp_stats_reset(struct ark_rqpace_t *rqp) -{ - rqp->stats_clear = 1; - /* POR 992 */ - /* rqp->cpld_max = 992; */ - /* POR 64 */ - /* rqp->cplh_max = 64; */ -} - -/* ************************************************************************* */ -void -ark_rqp_dump(struct ark_rqpace_t *rqp) -{ - if (rqp->err_count_other || rqp->cmpl_errors) - ARK_PMD_LOG(ERR, - "RQP Errors noted: ctrl: %d cplh_hmax %d cpld_max %d" - ARK_SU32 - ARK_SU32 - ARK_SU32 "\n", - rqp->ctrl, rqp->cplh_max, rqp->cpld_max, - "Error Count", rqp->err_cnt, - "Error General", rqp->err_count_other, - "Cmpl Errors", rqp->cmpl_errors); - - ARK_PMD_LOG(INFO, "RQP Dump: ctrl: %d cplh_hmax %d cpld_max %d" - ARK_SU32 - ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 - ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 - ARK_SU32 ARK_SU32 ARK_SU32 - ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 "\n", - rqp->ctrl, rqp->cplh_max, rqp->cpld_max, - "Error Count", rqp->err_cnt, - "Error General", rqp->err_count_other, - "stall_pS", rqp->stall_ps, - "stall_pS Min", rqp->stall_ps_min, - "stall_pS Max", rqp->stall_ps_max, - "req_pS", rqp->req_ps, - "req_pS Min", rqp->req_ps_min, - "req_pS Max", rqp->req_ps_max, - "req_dWPS", rqp->req_dw_ps, - "req_dWPS Min", rqp->req_dw_ps_min, - "req_dWPS Max", rqp->req_dw_ps_max, - "cpl_pS", rqp->cpl_ps, - "cpl_pS Min", rqp->cpl_ps_min, - "cpl_pS Max", rqp->cpl_ps_max, - "cpl_dWPS", rqp->cpl_dw_ps, - "cpl_dWPS Min", rqp->cpl_dw_ps_min, - "cpl_dWPS Max", rqp->cpl_dw_ps_max, - "cplh pending", rqp->cplh_pending, - "cpld pending", rqp->cpld_pending, - "cplh pending max", rqp->cplh_pending_max, - "cpld pending max", rqp->cpld_pending_max); -} - -int -ark_rqp_lasped(struct ark_rqpace_t *rqp) -{ - return rqp->lasped; -} diff --git a/dpdk/drivers/net/ark/ark_rqp.h b/dpdk/drivers/net/ark/ark_rqp.h deleted file mode 100644 index d09f242e1..000000000 --- a/dpdk/drivers/net/ark/ark_rqp.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2015-2018 Atomic Rules LLC - */ - -#ifndef _ARK_RQP_H_ -#define _ARK_RQP_H_ - -#include - -#include - -/* The RQP or ReQuest Pacer is an internal Arkville hardware module - * which limits the PCIE data flow to insure correct operation for the - * particular hardware PCIE endpoint. - * This module is *not* intended for end-user manipulation, hence - * there is minimal documentation. - */ - -/* - * RQ Pacing core hardware structure - * This is an overlay structures to a memory mapped FPGA device. These - * structs will never be instantiated in ram memory - */ -struct ark_rqpace_t { - volatile uint32_t ctrl; - volatile uint32_t stats_clear; - volatile uint32_t cplh_max; - volatile uint32_t cpld_max; - volatile uint32_t err_cnt; - volatile uint32_t stall_ps; - volatile uint32_t stall_ps_min; - volatile uint32_t stall_ps_max; - volatile uint32_t req_ps; - volatile uint32_t req_ps_min; - volatile uint32_t req_ps_max; - volatile uint32_t req_dw_ps; - volatile uint32_t req_dw_ps_min; - volatile uint32_t req_dw_ps_max; - volatile uint32_t cpl_ps; - volatile uint32_t cpl_ps_min; - volatile uint32_t cpl_ps_max; - volatile uint32_t cpl_dw_ps; - volatile uint32_t cpl_dw_ps_min; - volatile uint32_t cpl_dw_ps_max; - volatile uint32_t cplh_pending; - volatile uint32_t cpld_pending; - volatile uint32_t cplh_pending_max; - volatile uint32_t cpld_pending_max; - volatile uint32_t err_count_other; - char eval[4]; - volatile int32_t lasped; - volatile uint32_t cmpl_errors; -}; - -void ark_rqp_dump(struct ark_rqpace_t *rqp); -void ark_rqp_stats_reset(struct ark_rqpace_t *rqp); -int ark_rqp_lasped(struct ark_rqpace_t *rqp); -#endif diff --git a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.c b/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.c deleted file mode 100644 index dc9606712..000000000 --- a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.c +++ /dev/null @@ -1,190 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. - */ - -#include - -#include "tf_shadow_identifier.h" -#include "tf_common.h" -#include "tf_util.h" -#include "tfp.h" - -/** - * Shadow identifier DB element - */ -struct tf_shadow_ident_element { - /** - * Identifier - */ - uint32_t *id; - - /** - * Reference count, array of number of identifier type entries - */ - uint32_t *ref_count; -}; - -/** - * Shadow identifier DB definition - */ -struct tf_shadow_ident_db { - /** - * Number of elements in the DB - */ - uint16_t num_entries; - - /** - * The DB consists of an array of elements - */ - struct tf_shadow_ident_element *db; -}; - -int -tf_shadow_ident_create_db(struct tf_shadow_ident_create_db_parms *parms) -{ - int rc; - int i; - struct tfp_calloc_parms cparms; - struct tf_shadow_ident_db *shadow_db; - struct tf_shadow_ident_element *db; - - TF_CHECK_PARMS1(parms); - - /* Build the shadow DB per the request */ - cparms.nitems = 1; - cparms.size = sizeof(struct tf_shadow_ident_db); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - return rc; - shadow_db = (void *)cparms.mem_va; - - /* Build the DB within shadow DB */ - cparms.nitems = parms->num_elements; - cparms.size = sizeof(struct tf_shadow_ident_element); - rc = tfp_calloc(&cparms); - if (rc) - return rc; - shadow_db->db = (struct tf_shadow_ident_element *)cparms.mem_va; - shadow_db->num_entries = parms->num_elements; - - db = shadow_db->db; - for (i = 0; i < parms->num_elements; i++) { - /* If the element didn't request an allocation no need - * to create a pool nor verify if we got a reservation. - */ - if (parms->cfg->alloc_cnt[i] == 0) - continue; - - /* Create array */ - cparms.nitems = parms->cfg->alloc_cnt[i]; - cparms.size = sizeof(uint32_t); - rc = tfp_calloc(&cparms); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Array alloc failed, type:%d\n", - tf_dir_2_str(parms->dir), - i); - goto fail; - } - db[i].ref_count = (uint32_t *)cparms.mem_va; - } - - *parms->tf_shadow_ident_db = (void *)shadow_db; - - return 0; -fail: - tfp_free((void *)db->ref_count); - tfp_free((void *)db); - tfp_free((void *)shadow_db); - parms->tf_shadow_ident_db = NULL; - - return -EINVAL; -} - -int -tf_shadow_ident_free_db(struct tf_shadow_ident_free_db_parms *parms) -{ - int i; - struct tf_shadow_ident_db *shadow_db; - - TF_CHECK_PARMS1(parms); - - shadow_db = (struct tf_shadow_ident_db *)parms->tf_shadow_ident_db; - for (i = 0; i < shadow_db->num_entries; i++) - tfp_free((void *)shadow_db->db[i].ref_count); - - tfp_free((void *)shadow_db->db); - tfp_free((void *)parms->tf_shadow_ident_db); - - return 0; -} - -int -tf_shadow_ident_search(struct tf_shadow_ident_search_parms *parms) -{ - struct tf_shadow_ident_db *shadow_db; - uint32_t ref_cnt = 0; - - TF_CHECK_PARMS1(parms); - - shadow_db = (struct tf_shadow_ident_db *)parms->tf_shadow_ident_db; - ref_cnt = shadow_db->db[parms->type].ref_count[parms->search_id]; - if (ref_cnt > 0) { - *parms->hit = 1; - *parms->ref_cnt = ++ref_cnt; - shadow_db->db[parms->type].ref_count[parms->search_id] = - ref_cnt; - } else { - *parms->hit = 0; - *parms->ref_cnt = 0; - } - - - return 0; -} - -#define ID_REF_CNT_MAX 0xffffffff -int -tf_shadow_ident_insert(struct tf_shadow_ident_insert_parms *parms) -{ - struct tf_shadow_ident_db *shadow_db; - - TF_CHECK_PARMS1(parms); - - shadow_db = (struct tf_shadow_ident_db *)parms->tf_shadow_ident_db; - - /* In case of overflow, ref count keeps the max value */ - if (shadow_db->db[parms->type].ref_count[parms->id] < ID_REF_CNT_MAX) - shadow_db->db[parms->type].ref_count[parms->id]++; - else - TFP_DRV_LOG(ERR, - "Identifier %d in type %d reaches the max ref_cnt\n", - parms->type, - parms->id); - - parms->ref_cnt = shadow_db->db[parms->type].ref_count[parms->id]; - - return 0; -} - -int -tf_shadow_ident_remove(struct tf_shadow_ident_remove_parms *parms) -{ - struct tf_shadow_ident_db *shadow_db; - uint32_t ref_cnt = 0; - - TF_CHECK_PARMS1(parms); - - shadow_db = (struct tf_shadow_ident_db *)parms->tf_shadow_ident_db; - ref_cnt = shadow_db->db[parms->type].ref_count[parms->id]; - if (ref_cnt > 0) - shadow_db->db[parms->type].ref_count[parms->id]--; - else - return -EINVAL; - - *parms->ref_cnt = shadow_db->db[parms->type].ref_count[parms->id]; - - return 0; -} diff --git a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.h b/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.h deleted file mode 100644 index ff41eaad9..000000000 --- a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_identifier.h +++ /dev/null @@ -1,229 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. - */ - -#ifndef _TF_SHADOW_IDENTIFIER_H_ -#define _TF_SHADOW_IDENTIFIER_H_ - -#include "tf_core.h" - -struct tf; - -/** - * The Shadow Identifier module provides shadow DB handling for identifier based - * TF types. A shadow DB provides the capability that allows for reuse - * of TF resources. - * - * A Shadow identifier DB is intended to be used by the Identifier Type module - * only. - */ - -/** - * Shadow DB configuration information for a single identifier type. - * - * It is used in an array of identifier types. The array must be ordered - * by the TF type is represents. - */ -struct tf_shadow_ident_cfg_parms { - /** - * TF Identifier type - */ - enum tf_identifier_type type; - - /** - * Number of entries the Shadow DB needs to hold - */ - int num_entries; - - /** - * Resource allocation count array. This array content - * originates from the tf_session_resources that is passed in - * on session open. - * Array size is num_elements. - */ - uint16_t *alloc_cnt; -}; - -/** - * Shadow identifier DB creation parameters - */ -struct tf_shadow_ident_create_db_parms { - /** - * [in] Receive or transmit direction. - */ - enum tf_dir dir; - /** - * [in] Configuration information for the shadow db - */ - struct tf_shadow_ident_cfg_parms *cfg; - /** - * [in] Number of elements in the parms structure - */ - uint16_t num_elements; - /** - * [out] Shadow identifier DB handle - */ - void **tf_shadow_ident_db; -}; - -/** - * Shadow identifier DB free parameters - */ -struct tf_shadow_ident_free_db_parms { - /** - * Shadow identifier DB handle - */ - void *tf_shadow_ident_db; -}; - -/** - * Shadow identifier search parameters - */ -struct tf_shadow_ident_search_parms { - /** - * [in] Shadow identifier DB handle - */ - void *tf_shadow_ident_db; - /** - * [in] Identifier type - */ - enum tf_identifier_type type; - /** - * [in] id to search - */ - uint16_t search_id; - /** - * [out] Index of the found element returned if hit - */ - bool *hit; - /** - * [out] Reference count incremented if hit - */ - uint32_t *ref_cnt; -}; - -/** - * Shadow identifier insert parameters - */ -struct tf_shadow_ident_insert_parms { - /** - * [in] Shadow identifier DB handle - */ - void *tf_shadow_ident_db; - /** - * [in] Tbl type - */ - enum tf_identifier_type type; - /** - * [in] Entry to update - */ - uint16_t id; - /** - * [out] Reference count after insert - */ - uint32_t ref_cnt; -}; - -/** - * Shadow identifier remove parameters - */ -struct tf_shadow_ident_remove_parms { - /** - * [in] Shadow identifier DB handle - */ - void *tf_shadow_ident_db; - /** - * [in] Tbl type - */ - enum tf_identifier_type type; - /** - * [in] Entry to update - */ - uint16_t id; - /** - * [out] Reference count after removal - */ - uint32_t *ref_cnt; -}; - -/** - * @page shadow_ident Shadow identifier DB - * - * @ref tf_shadow_ident_create_db - * - * @ref tf_shadow_ident_free_db - * - * @reg tf_shadow_ident_search - * - * @reg tf_shadow_ident_insert - * - * @reg tf_shadow_ident_remove - */ - -/** - * Creates and fills a Shadow identifier DB. The DB is indexed per the - * parms structure. - * - * [in] parms - * Pointer to create db parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_shadow_ident_create_db(struct tf_shadow_ident_create_db_parms *parms); - -/** - * Closes the Shadow identifier DB and frees all allocated - * resources per the associated database. - * - * [in] parms - * Pointer to the free DB parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_shadow_ident_free_db(struct tf_shadow_ident_free_db_parms *parms); - -/** - * Search Shadow identifier db for matching result - * - * [in] parms - * Pointer to the search parameters - * - * Returns - * - (0) if successful, element was found. - * - (-EINVAL) on failure. - */ -int tf_shadow_ident_search(struct tf_shadow_ident_search_parms *parms); - -/** - * Inserts an element into the Shadow identifier DB. Ref_count after insert - * will be incremented. - * - * [in] parms - * Pointer to insert parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_shadow_ident_insert(struct tf_shadow_ident_insert_parms *parms); - -/** - * Removes an element from the Shadow identifier DB. Will fail if the - * elements ref_count is 0. Ref_count after removal will be - * decremented. - * - * [in] parms - * Pointer to remove parameter - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_shadow_ident_remove(struct tf_shadow_ident_remove_parms *parms); - -#endif /* _TF_SHADOW_IDENTIFIER_H_ */ diff --git a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.c b/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.c deleted file mode 100644 index 5fcd1f910..000000000 --- a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.c +++ /dev/null @@ -1,837 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. - */ - -#include "tf_common.h" -#include "tf_util.h" -#include "tfp.h" -#include "tf_tcam.h" -#include "tf_shadow_tcam.h" -#include "tf_hash.h" - -/** - * The implementation includes 3 tables per tcam table type. - * - hash table - * - sized so that a minimum of 4 slots per shadow entry are available to - * minimize the likelihood of collisions. - * - shadow key table - * - sized to the number of entries requested and is directly indexed - * - the index is zero based and is the tcam index - the base address - * - the key and mask are stored in the key table. - * - The stored key is the AND of the key/mask in order to eliminate the need - * to compare both the key and mask. - * - shadow result table - * - the result table is stored separately since it only needs to be accessed - * when the key matches. - * - the result has a back pointer to the hash table via the hb handle. The - * hb handle is a 32 bit representation of the hash with a valid bit, bucket - * element index, and the hash index. It is necessary to store the hb handle - * with the result since subsequent removes only provide the tcam index. - * - * - Max entries is limited in the current implementation since bit 15 is the - * valid bit in the hash table. - * - A 16bit hash is calculated and masked based on the number of entries - * - 64b wide bucket is used and broken into 4x16bit elements. - * This decision is based on quicker bucket scanning to determine if any - * elements are in use. - * - bit 15 of each bucket element is the valid, this is done to prevent having - * to read the larger key/result data for determining VALID. It also aids - * in the more efficient scanning of the bucket for slot usage. - */ - -/* - * The maximum number of shadow entries supported. The value also doubles as - * the maximum number of hash buckets. There are only 15 bits of data per - * bucket to point to the shadow tables. - */ -#define TF_SHADOW_TCAM_ENTRIES_MAX (1 << 15) - -/* The number of elements(BE) per hash bucket (HB) */ -#define TF_SHADOW_TCAM_HB_NUM_ELEM (4) -#define TF_SHADOW_TCAM_BE_VALID (1 << 15) -#define TF_SHADOW_TCAM_BE_IS_VALID(be) (((be) & TF_SHADOW_TCAM_BE_VALID) != 0) - -/** - * The hash bucket handle is 32b - * - bit 31, the Valid bit - * - bit 29-30, the element - * - bits 0-15, the hash idx (is masked based on the allocated size) - */ -#define TF_SHADOW_TCAM_HB_HANDLE_IS_VALID(hndl) (((hndl) & (1 << 31)) != 0) -#define TF_SHADOW_TCAM_HB_HANDLE_CREATE(idx, be) ((1 << 31) | \ - ((be) << 29) | (idx)) - -#define TF_SHADOW_TCAM_HB_HANDLE_BE_GET(hdl) (((hdl) >> 29) & \ - (TF_SHADOW_TCAM_HB_NUM_ELEM - 1)) - -#define TF_SHADOW_TCAM_HB_HANDLE_HASH_GET(ctxt, hdl)((hdl) & \ - (ctxt)->hash_ctxt.hid_mask) - -/** - * The idx provided by the caller is within a region, so currently the base is - * either added or subtracted from the idx to ensure it can be used as a - * compressed index - */ - -/* Convert the tcam index to a shadow index */ -#define TF_SHADOW_TCAM_IDX_TO_SHIDX(ctxt, idx) ((idx) - \ - (ctxt)->shadow_ctxt.base_addr) - -/* Convert the shadow index to a tcam index */ -#define TF_SHADOW_TCAM_SHIDX_TO_IDX(ctxt, idx) ((idx) + \ - (ctxt)->shadow_ctxt.base_addr) - -/* Simple helper masks for clearing en element from the bucket */ -#define TF_SHADOW_TCAM_BE0_MASK_CLEAR(hb) ((hb) & 0xffffffffffff0000ull) -#define TF_SHADOW_TCAM_BE1_MASK_CLEAR(hb) ((hb) & 0xffffffff0000ffffull) -#define TF_SHADOW_TCAM_BE2_MASK_CLEAR(hb) ((hb) & 0xffff0000ffffffffull) -#define TF_SHADOW_TCAM_BE3_MASK_CLEAR(hb) ((hb) & 0x0000ffffffffffffull) - -/** - * This should be coming from external, but for now it is assumed that no key - * is greater than 1K bits and no result is bigger than 128 bits. This makes - * allocation of the hash table easier without having to allocate on the fly. - */ -#define TF_SHADOW_TCAM_MAX_KEY_SZ 128 -#define TF_SHADOW_TCAM_MAX_RESULT_SZ 16 - -/* - * Local only defines for the internal data. - */ - -/** - * tf_shadow_tcam_shadow_key_entry is the key/mask entry of the key table. - * The key stored in the table is the masked version of the key. This is done - * to eliminate the need of comparing both the key and mask. - */ -struct tf_shadow_tcam_shadow_key_entry { - uint8_t key[TF_SHADOW_TCAM_MAX_KEY_SZ]; - uint8_t mask[TF_SHADOW_TCAM_MAX_KEY_SZ]; -}; - -/** - * tf_shadow_tcam_shadow_result_entry is the result table entry. - * The result table writes are broken into two phases: - * - The search phase, which stores the hb_handle and key size and - * - The set phase, which writes the result, refcnt, and result size - */ -struct tf_shadow_tcam_shadow_result_entry { - uint8_t result[TF_SHADOW_TCAM_MAX_RESULT_SZ]; - uint16_t result_size; - uint16_t key_size; - uint32_t refcnt; - uint32_t hb_handle; -}; - -/** - * tf_shadow_tcam_shadow_ctxt holds all information for accessing the key and - * result tables. - */ -struct tf_shadow_tcam_shadow_ctxt { - struct tf_shadow_tcam_shadow_key_entry *sh_key_tbl; - struct tf_shadow_tcam_shadow_result_entry *sh_res_tbl; - uint32_t base_addr; - uint16_t num_entries; - uint16_t alloc_idx; -}; - -/** - * tf_shadow_tcam_hash_ctxt holds all information related to accessing the hash - * table. - */ -struct tf_shadow_tcam_hash_ctxt { - uint64_t *hashtbl; - uint16_t hid_mask; - uint16_t hash_entries; -}; - -/** - * tf_shadow_tcam_ctxt holds the hash and shadow tables for the current shadow - * tcam db. This structure is per tcam table type as each tcam table has it's - * own shadow and hash table. - */ -struct tf_shadow_tcam_ctxt { - struct tf_shadow_tcam_shadow_ctxt shadow_ctxt; - struct tf_shadow_tcam_hash_ctxt hash_ctxt; -}; - -/** - * tf_shadow_tcam_db is the allocated db structure returned as an opaque - * void * pointer to the caller during create db. It holds the pointers for - * each tcam associated with the db. - */ -struct tf_shadow_tcam_db { - /* Each context holds the shadow and hash table information */ - struct tf_shadow_tcam_ctxt *ctxt[TF_TCAM_TBL_TYPE_MAX]; -}; - -/** - * Returns the number of entries in the contexts shadow table. - */ -static inline uint16_t -tf_shadow_tcam_sh_num_entries_get(struct tf_shadow_tcam_ctxt *ctxt) -{ - return ctxt->shadow_ctxt.num_entries; -} - -/** - * Compare the give key with the key in the shadow table. - * - * Returns 0 if the keys match - */ -static int -tf_shadow_tcam_key_cmp(struct tf_shadow_tcam_ctxt *ctxt, - uint8_t *key, - uint8_t *mask, - uint16_t sh_idx, - uint16_t size) -{ - if (size != ctxt->shadow_ctxt.sh_res_tbl[sh_idx].key_size || - sh_idx >= tf_shadow_tcam_sh_num_entries_get(ctxt) || !key || !mask) - return -1; - - return memcmp(key, ctxt->shadow_ctxt.sh_key_tbl[sh_idx].key, size); -} - -/** - * Copies the shadow result to the result. - * - * Returns 0 on failure - */ -static void * -tf_shadow_tcam_res_cpy(struct tf_shadow_tcam_ctxt *ctxt, - uint8_t *result, - uint16_t sh_idx, - uint16_t size) -{ - if (sh_idx >= tf_shadow_tcam_sh_num_entries_get(ctxt) || !result) - return 0; - - if (ctxt->shadow_ctxt.sh_res_tbl[sh_idx].result_size != size) - return 0; - - return memcpy(result, - ctxt->shadow_ctxt.sh_res_tbl[sh_idx].result, - size); -} - -/** - * Using a software based CRC function for now, but will look into using hw - * assisted in the future. - */ -static uint32_t -tf_shadow_tcam_crc32_calc(uint8_t *key, uint32_t len) -{ - return tf_hash_calc_crc32(key, len); -} - -/** - * Free the memory associated with the context. - */ -static void -tf_shadow_tcam_ctxt_delete(struct tf_shadow_tcam_ctxt *ctxt) -{ - if (!ctxt) - return; - - tfp_free(ctxt->hash_ctxt.hashtbl); - tfp_free(ctxt->shadow_ctxt.sh_key_tbl); - tfp_free(ctxt->shadow_ctxt.sh_res_tbl); -} - -/** - * The TF Shadow TCAM context is per TCAM and holds all information relating to - * managing the shadow and search capability. This routine allocated data that - * needs to be deallocated by the tf_shadow_tcam_ctxt_delete prior when deleting - * the shadow db. - */ -static int -tf_shadow_tcam_ctxt_create(struct tf_shadow_tcam_ctxt *ctxt, - uint16_t num_entries, - uint16_t base_addr) -{ - struct tfp_calloc_parms cparms; - uint16_t hash_size = 1; - uint16_t hash_mask; - int rc; - - /* Hash table is a power of two that holds the number of entries */ - if (num_entries > TF_SHADOW_TCAM_ENTRIES_MAX) { - TFP_DRV_LOG(ERR, "Too many entries for shadow %d > %d\n", - num_entries, - TF_SHADOW_TCAM_ENTRIES_MAX); - return -ENOMEM; - } - - while (hash_size < num_entries) - hash_size = hash_size << 1; - - hash_mask = hash_size - 1; - - /* Allocate the hash table */ - cparms.nitems = hash_size; - cparms.size = sizeof(uint64_t); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - goto error; - ctxt->hash_ctxt.hashtbl = cparms.mem_va; - ctxt->hash_ctxt.hid_mask = hash_mask; - ctxt->hash_ctxt.hash_entries = hash_size; - - /* allocate the shadow tables */ - /* allocate the shadow key table */ - cparms.nitems = num_entries; - cparms.size = sizeof(struct tf_shadow_tcam_shadow_key_entry); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - goto error; - ctxt->shadow_ctxt.sh_key_tbl = cparms.mem_va; - - /* allocate the shadow result table */ - cparms.nitems = num_entries; - cparms.size = sizeof(struct tf_shadow_tcam_shadow_result_entry); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - goto error; - ctxt->shadow_ctxt.sh_res_tbl = cparms.mem_va; - - ctxt->shadow_ctxt.num_entries = num_entries; - ctxt->shadow_ctxt.base_addr = base_addr; - - return 0; -error: - tf_shadow_tcam_ctxt_delete(ctxt); - - return -ENOMEM; -} - -/** - * Get a shadow TCAM context given the db and the TCAM type - */ -static struct tf_shadow_tcam_ctxt * -tf_shadow_tcam_ctxt_get(struct tf_shadow_tcam_db *shadow_db, - enum tf_tcam_tbl_type type) -{ - if (type >= TF_TCAM_TBL_TYPE_MAX || - !shadow_db || - !shadow_db->ctxt[type]) - return NULL; - - return shadow_db->ctxt[type]; -} - -/** - * Sets the hash entry into the table given the TCAM context, hash bucket - * handle, and shadow index. - */ -static inline int -tf_shadow_tcam_set_hash_entry(struct tf_shadow_tcam_ctxt *ctxt, - uint32_t hb_handle, - uint16_t sh_idx) -{ - uint16_t hid = TF_SHADOW_TCAM_HB_HANDLE_HASH_GET(ctxt, hb_handle); - uint16_t be = TF_SHADOW_TCAM_HB_HANDLE_BE_GET(hb_handle); - uint64_t entry = sh_idx | TF_SHADOW_TCAM_BE_VALID; - - if (hid >= ctxt->hash_ctxt.hash_entries) - return -EINVAL; - - ctxt->hash_ctxt.hashtbl[hid] |= entry << (be * 16); - return 0; -} - -/** - * Clears the hash entry given the TCAM context and hash bucket handle. - */ -static inline void -tf_shadow_tcam_clear_hash_entry(struct tf_shadow_tcam_ctxt *ctxt, - uint32_t hb_handle) -{ - uint16_t hid, be; - uint64_t *bucket; - - if (!TF_SHADOW_TCAM_HB_HANDLE_IS_VALID(hb_handle)) - return; - - hid = TF_SHADOW_TCAM_HB_HANDLE_HASH_GET(ctxt, hb_handle); - be = TF_SHADOW_TCAM_HB_HANDLE_BE_GET(hb_handle); - bucket = &ctxt->hash_ctxt.hashtbl[hid]; - - switch (be) { - case 0: - *bucket = TF_SHADOW_TCAM_BE0_MASK_CLEAR(*bucket); - break; - case 1: - *bucket = TF_SHADOW_TCAM_BE1_MASK_CLEAR(*bucket); - break; - case 2: - *bucket = TF_SHADOW_TCAM_BE2_MASK_CLEAR(*bucket); - break; - case 3: - *bucket = TF_SHADOW_TCAM_BE2_MASK_CLEAR(*bucket); - break; - default: - /* - * Since the BE_GET masks non-inclusive bits, this will not - * happen. - */ - break; - } -} - -/** - * Clears the shadow key and result entries given the TCAM context and - * shadow index. - */ -static void -tf_shadow_tcam_clear_sh_entry(struct tf_shadow_tcam_ctxt *ctxt, - uint16_t sh_idx) -{ - struct tf_shadow_tcam_shadow_key_entry *sk_entry; - struct tf_shadow_tcam_shadow_result_entry *sr_entry; - - if (sh_idx >= tf_shadow_tcam_sh_num_entries_get(ctxt)) - return; - - sk_entry = &ctxt->shadow_ctxt.sh_key_tbl[sh_idx]; - sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[sh_idx]; - - /* - * memset key/result to zero for now, possibly leave the data alone - * in the future and rely on the valid bit in the hash table. - */ - memset(sk_entry, 0, sizeof(struct tf_shadow_tcam_shadow_key_entry)); - memset(sr_entry, 0, sizeof(struct tf_shadow_tcam_shadow_result_entry)); -} - -/** - * Binds the allocated tcam index with the hash and shadow tables. - * The entry will be incomplete until the set has happened with the result - * data. - */ -int -tf_shadow_tcam_bind_index(struct tf_shadow_tcam_bind_index_parms *parms) -{ - int rc; - int i; - uint16_t idx, klen; - struct tf_shadow_tcam_ctxt *ctxt; - struct tf_shadow_tcam_db *shadow_db; - struct tf_shadow_tcam_shadow_key_entry *sk_entry; - struct tf_shadow_tcam_shadow_result_entry *sr_entry; - uint8_t tkey[TF_SHADOW_TCAM_MAX_KEY_SZ]; - - if (!parms || !TF_SHADOW_TCAM_HB_HANDLE_IS_VALID(parms->hb_handle) || - !parms->key || !parms->mask) { - TFP_DRV_LOG(ERR, "Invalid parms\n"); - return -EINVAL; - } - - shadow_db = (struct tf_shadow_tcam_db *)parms->shadow_db; - ctxt = tf_shadow_tcam_ctxt_get(shadow_db, parms->type); - if (!ctxt) { - TFP_DRV_LOG(DEBUG, "%s no ctxt for table\n", - tf_tcam_tbl_2_str(parms->type)); - return -EINVAL; - } - - memset(tkey, 0, sizeof(tkey)); - idx = TF_SHADOW_TCAM_IDX_TO_SHIDX(ctxt, parms->idx); - klen = parms->key_size; - if (idx >= tf_shadow_tcam_sh_num_entries_get(ctxt) || - klen > TF_SHADOW_TCAM_MAX_KEY_SZ) { - TFP_DRV_LOG(ERR, "%s:%s Invalid len (%d) > %d || oob idx %d\n", - tf_dir_2_str(parms->dir), - tf_tcam_tbl_2_str(parms->type), - klen, - TF_SHADOW_TCAM_MAX_KEY_SZ, idx); - - return -EINVAL; - } - - rc = tf_shadow_tcam_set_hash_entry(ctxt, parms->hb_handle, idx); - if (rc) - return -EINVAL; - - sk_entry = &ctxt->shadow_ctxt.sh_key_tbl[idx]; - sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx]; - - /* - * Write the masked key to the table for more efficient comparisons - * later. - */ - for (i = 0; i < klen; i++) - tkey[i] = parms->key[i] & parms->mask[i]; - - memcpy(sk_entry->key, tkey, klen); - memcpy(sk_entry->mask, parms->mask, klen); - - /* Write the result table */ - sr_entry->key_size = parms->key_size; - sr_entry->hb_handle = parms->hb_handle; - sr_entry->refcnt = 1; - - return 0; -} - -/** - * Deletes hash/shadow information if no more references. - * - * Returns 0 - The caller should delete the tcam entry in hardware. - * Returns non-zero - The number of references to the entry - */ -int -tf_shadow_tcam_remove(struct tf_shadow_tcam_remove_parms *parms) -{ - uint16_t idx; - uint32_t hb_handle; - struct tf_shadow_tcam_ctxt *ctxt; - struct tf_shadow_tcam_db *shadow_db; - struct tf_tcam_free_parms *fparms; - struct tf_shadow_tcam_shadow_result_entry *sr_entry; - - if (!parms || !parms->fparms) { - TFP_DRV_LOG(ERR, "Invalid parms\n"); - return -EINVAL; - } - - fparms = parms->fparms; - - /* - * Initialize the reference count to zero. It will only be changed if - * non-zero. - */ - fparms->ref_cnt = 0; - - shadow_db = (struct tf_shadow_tcam_db *)parms->shadow_db; - ctxt = tf_shadow_tcam_ctxt_get(shadow_db, fparms->type); - if (!ctxt) { - TFP_DRV_LOG(DEBUG, "%s no ctxt for table\n", - tf_tcam_tbl_2_str(fparms->type)); - return 0; - } - - idx = TF_SHADOW_TCAM_IDX_TO_SHIDX(ctxt, fparms->idx); - if (idx >= tf_shadow_tcam_sh_num_entries_get(ctxt)) { - TFP_DRV_LOG(DEBUG, "%s %d >= %d\n", - tf_tcam_tbl_2_str(fparms->type), - fparms->idx, - tf_shadow_tcam_sh_num_entries_get(ctxt)); - return 0; - } - - sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx]; - if (sr_entry->refcnt <= 1) { - hb_handle = sr_entry->hb_handle; - tf_shadow_tcam_clear_hash_entry(ctxt, hb_handle); - tf_shadow_tcam_clear_sh_entry(ctxt, idx); - } else { - sr_entry->refcnt--; - fparms->ref_cnt = sr_entry->refcnt; - } - - return 0; -} - -int -tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms) -{ - uint16_t len; - uint8_t rcopy; - uint64_t bucket; - uint32_t i, hid32; - struct tf_shadow_tcam_ctxt *ctxt; - struct tf_shadow_tcam_db *shadow_db; - uint16_t hid16, hb_idx, hid_mask, shtbl_idx, shtbl_key, be_valid; - struct tf_tcam_alloc_search_parms *sparms; - uint8_t tkey[TF_SHADOW_TCAM_MAX_KEY_SZ]; - uint32_t be_avail = TF_SHADOW_TCAM_HB_NUM_ELEM; - - if (!parms || !parms->sparms) { - TFP_DRV_LOG(ERR, "tcam search with invalid parms\n"); - return -EINVAL; - } - - memset(tkey, 0, sizeof(tkey)); - sparms = parms->sparms; - - /* Initialize return values to invalid */ - sparms->hit = 0; - sparms->search_status = REJECT; - parms->hb_handle = 0; - sparms->ref_cnt = 0; - /* see if caller wanted the result */ - rcopy = sparms->result && sparms->result_size; - - shadow_db = (struct tf_shadow_tcam_db *)parms->shadow_db; - ctxt = tf_shadow_tcam_ctxt_get(shadow_db, sparms->type); - if (!ctxt) { - TFP_DRV_LOG(ERR, "%s Unable to get tcam mgr context\n", - tf_tcam_tbl_2_str(sparms->type)); - return -EINVAL; - } - - hid_mask = ctxt->hash_ctxt.hid_mask; - - len = sparms->key_size; - - if (len > TF_SHADOW_TCAM_MAX_KEY_SZ || - !sparms->key || !sparms->mask || !len) { - TFP_DRV_LOG(ERR, "%s:%s Invalid parms %d : %p : %p\n", - tf_dir_2_str(sparms->dir), - tf_tcam_tbl_2_str(sparms->type), - len, - sparms->key, - sparms->mask); - return -EINVAL; - } - - /* Combine the key and mask */ - for (i = 0; i < len; i++) - tkey[i] = sparms->key[i] & sparms->mask[i]; - - /* - * Calculate the crc32 - * Fold it to create a 16b value - * Reduce it to fit the table - */ - hid32 = tf_shadow_tcam_crc32_calc(tkey, len); - hid16 = (uint16_t)(((hid32 >> 16) & 0xffff) ^ (hid32 & 0xffff)); - hb_idx = hid16 & hid_mask; - - bucket = ctxt->hash_ctxt.hashtbl[hb_idx]; - - if (!bucket) { - /* empty bucket means a miss and available entry */ - sparms->search_status = MISS; - parms->hb_handle = TF_SHADOW_TCAM_HB_HANDLE_CREATE(hb_idx, 0); - sparms->idx = 0; - return 0; - } - - /* Set the avail to max so we can detect when there is an avail entry */ - be_avail = TF_SHADOW_TCAM_HB_NUM_ELEM; - for (i = 0; i < TF_SHADOW_TCAM_HB_NUM_ELEM; i++) { - shtbl_idx = (uint16_t)((bucket >> (i * 16)) & 0xffff); - be_valid = TF_SHADOW_TCAM_BE_IS_VALID(shtbl_idx); - if (!be_valid) { - /* The element is avail, keep going */ - be_avail = i; - continue; - } - /* There is a valid entry, compare it */ - shtbl_key = shtbl_idx & ~TF_SHADOW_TCAM_BE_VALID; - if (!tf_shadow_tcam_key_cmp(ctxt, - sparms->key, - sparms->mask, - shtbl_key, - sparms->key_size)) { - /* - * It matches, increment the ref count if the caller - * requested allocation and return the info - */ - if (sparms->alloc) - ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt++; - - sparms->hit = 1; - sparms->search_status = HIT; - parms->hb_handle = - TF_SHADOW_TCAM_HB_HANDLE_CREATE(hb_idx, i); - sparms->idx = TF_SHADOW_TCAM_SHIDX_TO_IDX(ctxt, - shtbl_key); - sparms->ref_cnt = - ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt; - - /* copy the result, if caller wanted it. */ - if (rcopy && - !tf_shadow_tcam_res_cpy(ctxt, - sparms->result, - shtbl_key, - sparms->result_size)) { - /* - * Should never get here, possible memory - * corruption or something unexpected. - */ - TFP_DRV_LOG(ERR, "Error copying result\n"); - return -EINVAL; - } - - return 0; - } - } - - /* No hits, return avail entry if exists */ - if (be_avail < TF_SHADOW_TCAM_HB_NUM_ELEM) { - parms->hb_handle = - TF_SHADOW_TCAM_HB_HANDLE_CREATE(hb_idx, be_avail); - sparms->search_status = MISS; - sparms->hit = 0; - sparms->idx = 0; - } else { - sparms->search_status = REJECT; - } - - return 0; -} - -int -tf_shadow_tcam_insert(struct tf_shadow_tcam_insert_parms *parms) -{ - uint16_t idx; - struct tf_shadow_tcam_ctxt *ctxt; - struct tf_tcam_set_parms *sparms; - struct tf_shadow_tcam_db *shadow_db; - struct tf_shadow_tcam_shadow_result_entry *sr_entry; - - if (!parms || !parms->sparms) { - TFP_DRV_LOG(ERR, "Null parms\n"); - return -EINVAL; - } - - sparms = parms->sparms; - if (!sparms->result || !sparms->result_size) { - TFP_DRV_LOG(ERR, "%s:%s No result to set.\n", - tf_dir_2_str(sparms->dir), - tf_tcam_tbl_2_str(sparms->type)); - return -EINVAL; - } - - shadow_db = (struct tf_shadow_tcam_db *)parms->shadow_db; - ctxt = tf_shadow_tcam_ctxt_get(shadow_db, sparms->type); - if (!ctxt) { - /* We aren't tracking this table, so return success */ - TFP_DRV_LOG(DEBUG, "%s Unable to get tcam mgr context\n", - tf_tcam_tbl_2_str(sparms->type)); - return 0; - } - - idx = TF_SHADOW_TCAM_IDX_TO_SHIDX(ctxt, sparms->idx); - if (idx >= tf_shadow_tcam_sh_num_entries_get(ctxt)) { - TFP_DRV_LOG(ERR, "%s:%s Invalid idx(0x%x)\n", - tf_dir_2_str(sparms->dir), - tf_tcam_tbl_2_str(sparms->type), - sparms->idx); - return -EINVAL; - } - - /* Write the result table, the key/hash has been written already */ - sr_entry = &ctxt->shadow_ctxt.sh_res_tbl[idx]; - - /* - * If the handle is not valid, the bind was never called. We aren't - * tracking this entry. - */ - if (!TF_SHADOW_TCAM_HB_HANDLE_IS_VALID(sr_entry->hb_handle)) - return 0; - - if (sparms->result_size > TF_SHADOW_TCAM_MAX_RESULT_SZ) { - TFP_DRV_LOG(ERR, "%s:%s Result length %d > %d\n", - tf_dir_2_str(sparms->dir), - tf_tcam_tbl_2_str(sparms->type), - sparms->result_size, - TF_SHADOW_TCAM_MAX_RESULT_SZ); - return -EINVAL; - } - - memcpy(sr_entry->result, sparms->result, sparms->result_size); - sr_entry->result_size = sparms->result_size; - - return 0; -} - -int -tf_shadow_tcam_free_db(struct tf_shadow_tcam_free_db_parms *parms) -{ - struct tf_shadow_tcam_db *shadow_db; - int i; - - TF_CHECK_PARMS1(parms); - - shadow_db = (struct tf_shadow_tcam_db *)parms->shadow_db; - if (!shadow_db) { - TFP_DRV_LOG(DEBUG, "Shadow db is NULL cannot be freed\n"); - return -EINVAL; - } - - for (i = 0; i < TF_TCAM_TBL_TYPE_MAX; i++) { - if (shadow_db->ctxt[i]) { - tf_shadow_tcam_ctxt_delete(shadow_db->ctxt[i]); - tfp_free(shadow_db->ctxt[i]); - } - } - - tfp_free(shadow_db); - - return 0; -} - -/** - * Allocate the TCAM resources for search and allocate - * - */ -int tf_shadow_tcam_create_db(struct tf_shadow_tcam_create_db_parms *parms) -{ - int rc; - int i; - uint16_t base; - struct tfp_calloc_parms cparms; - struct tf_shadow_tcam_db *shadow_db = NULL; - - TF_CHECK_PARMS1(parms); - - /* Build the shadow DB per the request */ - cparms.nitems = 1; - cparms.size = sizeof(struct tf_shadow_tcam_db); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - return rc; - shadow_db = (void *)cparms.mem_va; - - for (i = 0; i < TF_TCAM_TBL_TYPE_MAX; i++) { - /* If the element didn't request an allocation no need - * to create a pool nor verify if we got a reservation. - */ - if (!parms->cfg->alloc_cnt[i]) { - shadow_db->ctxt[i] = NULL; - continue; - } - - cparms.nitems = 1; - cparms.size = sizeof(struct tf_shadow_tcam_ctxt); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) - goto error; - - shadow_db->ctxt[i] = cparms.mem_va; - base = parms->cfg->base_addr[i]; - rc = tf_shadow_tcam_ctxt_create(shadow_db->ctxt[i], - parms->cfg->alloc_cnt[i], - base); - if (rc) - goto error; - } - - *parms->shadow_db = (void *)shadow_db; - - TFP_DRV_LOG(INFO, - "TF SHADOW TCAM - initialized\n"); - - return 0; -error: - for (i = 0; i < TF_TCAM_TBL_TYPE_MAX; i++) { - if (shadow_db->ctxt[i]) { - tf_shadow_tcam_ctxt_delete(shadow_db->ctxt[i]); - tfp_free(shadow_db->ctxt[i]); - } - } - - tfp_free(shadow_db); - - return -ENOMEM; -} diff --git a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.h b/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.h deleted file mode 100644 index d6506b219..000000000 --- a/dpdk/drivers/net/bnxt/tf_core/tf_shadow_tcam.h +++ /dev/null @@ -1,195 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2021 Broadcom - * All rights reserved. - */ - -#ifndef _TF_SHADOW_TCAM_H_ -#define _TF_SHADOW_TCAM_H_ - -#include "tf_core.h" - -/** - * Shadow DB configuration information - * - * The shadow configuration is for all tcam table types for a direction - */ -struct tf_shadow_tcam_cfg_parms { - /** - * [in] The number of elements in the alloc_cnt and base_addr - * For now, it should always be equal to TF_TCAM_TBL_TYPE_MAX - */ - int num_entries; - /** - * [in] Resource allocation count array - * This array content originates from the tf_session_resources - * that is passed in on session open - * Array size is TF_TCAM_TBL_TYPE_MAX - */ - uint16_t *alloc_cnt; - /** - * [in] The base index for each tcam table - */ - uint16_t base_addr[TF_TCAM_TBL_TYPE_MAX]; -}; - -/** - * Shadow TCAM DB creation parameters. The shadow db for this direction - * is returned - */ -struct tf_shadow_tcam_create_db_parms { - /** - * [in] Receive or transmit direction - */ - enum tf_dir dir; - /** - * [in] Configuration information for the shadow db - */ - struct tf_shadow_tcam_cfg_parms *cfg; - /** - * [out] Shadow tcam DB handle - */ - void **shadow_db; -}; - -/** - * Create the shadow db for a single direction - * - * The returned shadow db must be free using the free db API when no longer - * needed - */ -int -tf_shadow_tcam_create_db(struct tf_shadow_tcam_create_db_parms *parms); - -/** - * Shadow TCAM free parameters - */ -struct tf_shadow_tcam_free_db_parms { - /** - * [in] Shadow tcam DB handle - */ - void *shadow_db; -}; - -/** - * Free all resources associated with the shadow db - */ -int -tf_shadow_tcam_free_db(struct tf_shadow_tcam_free_db_parms *parms); - -/** - * Shadow TCAM bind index parameters - */ -struct tf_shadow_tcam_bind_index_parms { - /** - * [in] Shadow tcam DB handle - */ - void *shadow_db; - /** - * [in] receive or transmit direction - */ - enum tf_dir dir; - /** - * [in] TCAM table type - */ - enum tf_tcam_tbl_type type; - /** - * [in] index of the entry to program - */ - uint16_t idx; - /** - * [in] struct containing key - */ - uint8_t *key; - /** - * [in] struct containing mask fields - */ - uint8_t *mask; - /** - * [in] key size in bits (if search) - */ - uint16_t key_size; - /** - * [in] The hash bucket handled returned from the search - */ - uint32_t hb_handle; -}; - -/** - * Binds the allocated tcam index with the hash and shadow tables - */ -int -tf_shadow_tcam_bind_index(struct tf_shadow_tcam_bind_index_parms *parms); - -/** - * Shadow TCAM insert parameters - */ -struct tf_shadow_tcam_insert_parms { - /** - * [in] Shadow tcam DB handle - */ - void *shadow_db; - /** - * [in] The set parms from tf core - */ - struct tf_tcam_set_parms *sparms; -}; - -/** - * Set the entry into the tcam manager hash and shadow tables - * - * The search must have been used prior to setting the entry so that the - * hash has been calculated and duplicate entries will not be added - */ -int -tf_shadow_tcam_insert(struct tf_shadow_tcam_insert_parms *parms); - -/** - * Shadow TCAM remove parameters - */ -struct tf_shadow_tcam_remove_parms { - /** - * [in] Shadow tcam DB handle - */ - void *shadow_db; - /** - * [in,out] The set parms from tf core - */ - struct tf_tcam_free_parms *fparms; -}; - -/** - * Remove the entry from the tcam hash and shadow tables - * - * The search must have been used prior to setting the entry so that the - * hash has been calculated and duplicate entries will not be added - */ -int -tf_shadow_tcam_remove(struct tf_shadow_tcam_remove_parms *parms); - -/** - * Shadow TCAM search parameters - */ -struct tf_shadow_tcam_search_parms { - /** - * [in] Shadow tcam DB handle - */ - void *shadow_db; - /** - * [in,out] The search parameters from tf core - */ - struct tf_tcam_alloc_search_parms *sparms; - /** - * [out] The hash handle to use for the set - */ - uint32_t hb_handle; -}; - -/** - * Search for an entry in the tcam hash/shadow tables - * - * If there is a miss, but there is room for insertion, the hb_handle returned - * is used for insertion during the bind index API - */ -int -tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms); -#endif diff --git a/dpdk/drivers/net/idpf/idpf_rxtx_vec_avx512.c b/dpdk/drivers/net/idpf/idpf_rxtx_vec_avx512.c deleted file mode 100644 index f31582f5f..000000000 --- a/dpdk/drivers/net/idpf/idpf_rxtx_vec_avx512.c +++ /dev/null @@ -1,861 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#include "idpf_rxtx_vec_common.h" - -#include - -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -#define IDPF_DESCS_PER_LOOP_AVX 8 -#define PKTLEN_SHIFT 10 - -static __rte_always_inline void -idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) -{ - struct rte_mbuf **rxp = &rxq->sw_ring[rxq->rxrearm_start]; - volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring; - uint16_t rx_id; - int i; - - rxdp += rxq->rxrearm_start; - - /* Pull 'n' more MBUFs into the software ring */ - if (rte_mempool_get_bulk(rxq->mp, - (void *)rxp, - IDPF_RXQ_REARM_THRESH) < 0) { - if (rxq->rxrearm_nb + IDPF_RXQ_REARM_THRESH >= - rxq->nb_rx_desc) { - __m128i dma_addr0; - - dma_addr0 = _mm_setzero_si128(); - for (i = 0; i < IDPF_VPMD_DESCS_PER_LOOP; i++) { - rxp[i] = &rxq->fake_mbuf; - _mm_store_si128((__m128i *)&rxdp[i].read, - dma_addr0); - } - } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += - IDPF_RXQ_REARM_THRESH; - return; - } - struct rte_mbuf *mb0, *mb1, *mb2, *mb3; - struct rte_mbuf *mb4, *mb5, *mb6, *mb7; - __m512i dma_addr0_3, dma_addr4_7; - __m512i hdr_room = _mm512_set1_epi64(RTE_PKTMBUF_HEADROOM); - /* Initialize the mbufs in vector, process 8 mbufs in one loop */ - for (i = 0; i < IDPF_RXQ_REARM_THRESH; - i += 8, rxp += 8, rxdp += 8) { - __m128i vaddr0, vaddr1, vaddr2, vaddr3; - __m128i vaddr4, vaddr5, vaddr6, vaddr7; - __m256i vaddr0_1, vaddr2_3; - __m256i vaddr4_5, vaddr6_7; - __m512i vaddr0_3, vaddr4_7; - - mb0 = rxp[0]; - mb1 = rxp[1]; - mb2 = rxp[2]; - mb3 = rxp[3]; - mb4 = rxp[4]; - mb5 = rxp[5]; - mb6 = rxp[6]; - mb7 = rxp[7]; - - /* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */ - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_iova) != - offsetof(struct rte_mbuf, buf_addr) + 8); - vaddr0 = _mm_loadu_si128((__m128i *)&mb0->buf_addr); - vaddr1 = _mm_loadu_si128((__m128i *)&mb1->buf_addr); - vaddr2 = _mm_loadu_si128((__m128i *)&mb2->buf_addr); - vaddr3 = _mm_loadu_si128((__m128i *)&mb3->buf_addr); - vaddr4 = _mm_loadu_si128((__m128i *)&mb4->buf_addr); - vaddr5 = _mm_loadu_si128((__m128i *)&mb5->buf_addr); - vaddr6 = _mm_loadu_si128((__m128i *)&mb6->buf_addr); - vaddr7 = _mm_loadu_si128((__m128i *)&mb7->buf_addr); - - /** - * merge 0 & 1, by casting 0 to 256-bit and inserting 1 - * into the high lanes. Similarly for 2 & 3, and so on. - */ - vaddr0_1 = - _mm256_inserti128_si256(_mm256_castsi128_si256(vaddr0), - vaddr1, 1); - vaddr2_3 = - _mm256_inserti128_si256(_mm256_castsi128_si256(vaddr2), - vaddr3, 1); - vaddr4_5 = - _mm256_inserti128_si256(_mm256_castsi128_si256(vaddr4), - vaddr5, 1); - vaddr6_7 = - _mm256_inserti128_si256(_mm256_castsi128_si256(vaddr6), - vaddr7, 1); - vaddr0_3 = - _mm512_inserti64x4(_mm512_castsi256_si512(vaddr0_1), - vaddr2_3, 1); - vaddr4_7 = - _mm512_inserti64x4(_mm512_castsi256_si512(vaddr4_5), - vaddr6_7, 1); - - /* convert pa to dma_addr hdr/data */ - dma_addr0_3 = _mm512_unpackhi_epi64(vaddr0_3, vaddr0_3); - dma_addr4_7 = _mm512_unpackhi_epi64(vaddr4_7, vaddr4_7); - - /* add headroom to pa values */ - dma_addr0_3 = _mm512_add_epi64(dma_addr0_3, hdr_room); - dma_addr4_7 = _mm512_add_epi64(dma_addr4_7, hdr_room); - - /* flush desc with pa dma_addr */ - _mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); - } - - rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH; - if (rxq->rxrearm_start >= rxq->nb_rx_desc) - rxq->rxrearm_start = 0; - - rxq->rxrearm_nb -= IDPF_RXQ_REARM_THRESH; - - rx_id = (uint16_t)((rxq->rxrearm_start == 0) ? - (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1)); - - /* Update the tail pointer on the NIC */ - IDPF_PCI_REG_WRITE(rxq->qrx_tail, rx_id); -} - -static __rte_always_inline void -idpf_singleq_rearm(struct idpf_rx_queue *rxq) -{ - int i; - uint16_t rx_id; - volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring; - struct rte_mempool_cache *cache = - rte_mempool_default_cache(rxq->mp, rte_lcore_id()); - struct rte_mbuf **rxp = &rxq->sw_ring[rxq->rxrearm_start]; - - rxdp += rxq->rxrearm_start; - - if (unlikely(cache == NULL)) - return idpf_singleq_rearm_common(rxq); - - /* We need to pull 'n' more MBUFs into the software ring from mempool - * We inline the mempool function here, so we can vectorize the copy - * from the cache into the shadow ring. - */ - - /* Can this be satisfied from the cache? */ - if (cache->len < IDPF_RXQ_REARM_THRESH) { - /* No. Backfill the cache first, and then fill from it */ - uint32_t req = IDPF_RXQ_REARM_THRESH + (cache->size - - cache->len); - - /* How many do we require i.e. number to fill the cache + the request */ - int ret = rte_mempool_ops_dequeue_bulk - (rxq->mp, &cache->objs[cache->len], req); - if (ret == 0) { - cache->len += req; - } else { - if (rxq->rxrearm_nb + IDPF_RXQ_REARM_THRESH >= - rxq->nb_rx_desc) { - __m128i dma_addr0; - - dma_addr0 = _mm_setzero_si128(); - for (i = 0; i < IDPF_VPMD_DESCS_PER_LOOP; i++) { - rxp[i] = &rxq->fake_mbuf; - _mm_storeu_si128((__m128i *)&rxdp[i].read, - dma_addr0); - } - } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += - IDPF_RXQ_REARM_THRESH; - return; - } - } - - const __m512i iova_offsets = _mm512_set1_epi64(offsetof - (struct rte_mbuf, buf_iova)); - const __m512i headroom = _mm512_set1_epi64(RTE_PKTMBUF_HEADROOM); - - /* to shuffle the addresses to correct slots. Values 4-7 will contain - * zeros, so use 7 for a zero-value. - */ - const __m512i permute_idx = _mm512_set_epi64(7, 7, 3, 1, 7, 7, 2, 0); - - /* Initialize the mbufs in vector, process 8 mbufs in one loop, taking - * from mempool cache and populating both shadow and HW rings - */ - for (i = 0; i < IDPF_RXQ_REARM_THRESH / IDPF_DESCS_PER_LOOP_AVX; i++) { - const __m512i mbuf_ptrs = _mm512_loadu_si512 - (&cache->objs[cache->len - IDPF_DESCS_PER_LOOP_AVX]); - _mm512_storeu_si512(rxp, mbuf_ptrs); - - const __m512i iova_base_addrs = _mm512_i64gather_epi64 - (_mm512_add_epi64(mbuf_ptrs, iova_offsets), - 0, /* base */ - 1 /* scale */); - const __m512i iova_addrs = _mm512_add_epi64(iova_base_addrs, - headroom); - const __m512i iovas0 = _mm512_castsi256_si512 - (_mm512_extracti64x4_epi64(iova_addrs, 0)); - const __m512i iovas1 = _mm512_castsi256_si512 - (_mm512_extracti64x4_epi64(iova_addrs, 1)); - - /* permute leaves desc 2-3 addresses in header address slots 0-1 - * but these are ignored by driver since header split not - * enabled. Similarly for desc 6 & 7. - */ - const __m512i desc0_1 = _mm512_permutexvar_epi64 - (permute_idx, - iovas0); - const __m512i desc2_3 = _mm512_bsrli_epi128(desc0_1, 8); - - const __m512i desc4_5 = _mm512_permutexvar_epi64 - (permute_idx, - iovas1); - const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8); - - _mm512_storeu_si512((void *)rxdp, desc0_1); - _mm512_storeu_si512((void *)(rxdp + 2), desc2_3); - _mm512_storeu_si512((void *)(rxdp + 4), desc4_5); - _mm512_storeu_si512((void *)(rxdp + 6), desc6_7); - - rxp += IDPF_DESCS_PER_LOOP_AVX; - rxdp += IDPF_DESCS_PER_LOOP_AVX; - cache->len -= IDPF_DESCS_PER_LOOP_AVX; - } - - rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH; - if (rxq->rxrearm_start >= rxq->nb_rx_desc) - rxq->rxrearm_start = 0; - - rxq->rxrearm_nb -= IDPF_RXQ_REARM_THRESH; - - rx_id = (uint16_t)((rxq->rxrearm_start == 0) ? - (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1)); - - /* Update the tail pointer on the NIC */ - IDPF_PCI_REG_WRITE(rxq->qrx_tail, rx_id); -} - -#define IDPF_RX_LEN_MASK 0x80808080 -static __rte_always_inline uint16_t -_idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq, - struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) -{ - const uint32_t *type_table = rxq->adapter->ptype_tbl; - - const __m256i mbuf_init = _mm256_set_epi64x(0, 0, 0, - rxq->mbuf_initializer); - struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail]; - volatile union virtchnl2_rx_desc *rxdp = rxq->rx_ring; - - rxdp += rxq->rx_tail; - - rte_prefetch0(rxdp); - - /* nb_pkts has to be floor-aligned to IDPF_DESCS_PER_LOOP_AVX */ - nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, IDPF_DESCS_PER_LOOP_AVX); - - /* See if we need to rearm the RX queue - gives the prefetch a bit - * of time to act - */ - if (rxq->rxrearm_nb > IDPF_RXQ_REARM_THRESH) - idpf_singleq_rearm(rxq); - - /* Before we start moving massive data around, check to see if - * there is actually a packet available - */ - if ((rxdp->flex_nic_wb.status_error0 & - rte_cpu_to_le_32(1 << VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S)) == 0) - return 0; - - /* 8 packets DD mask, LSB in each 32-bit value */ - const __m256i dd_check = _mm256_set1_epi32(1); - - /* mask to shuffle from desc. to mbuf (4 descriptors)*/ - const __m512i shuf_msk = - _mm512_set_epi32 - (/* 1st descriptor */ - 0xFFFFFFFF, /* rss set as unknown */ - 0xFFFF0504, /* vlan_macip set as unknown */ - /* octet 15~14, 16 bits data_len */ - 0xFFFF0504, /* skip high 16 bits pkt_len, zero out */ - /* octet 15~14, low 16 bits pkt_len */ - 0xFFFFFFFF, /* pkt_type set as unknown */ - /* 2nd descriptor */ - 0xFFFFFFFF, /* rss set as unknown */ - 0xFFFF0504, /* vlan_macip set as unknown */ - /* octet 15~14, 16 bits data_len */ - 0xFFFF0504, /* skip high 16 bits pkt_len, zero out */ - /* octet 15~14, low 16 bits pkt_len */ - 0xFFFFFFFF, /* pkt_type set as unknown */ - /* 3rd descriptor */ - 0xFFFFFFFF, /* rss set as unknown */ - 0xFFFF0504, /* vlan_macip set as unknown */ - /* octet 15~14, 16 bits data_len */ - 0xFFFF0504, /* skip high 16 bits pkt_len, zero out */ - /* octet 15~14, low 16 bits pkt_len */ - 0xFFFFFFFF, /* pkt_type set as unknown */ - /* 4th descriptor */ - 0xFFFFFFFF, /* rss set as unknown */ - 0xFFFF0504, /* vlan_macip set as unknown */ - /* octet 15~14, 16 bits data_len */ - 0xFFFF0504, /* skip high 16 bits pkt_len, zero out */ - /* octet 15~14, low 16 bits pkt_len */ - 0xFFFFFFFF /* pkt_type set as unknown */ - ); - /** - * compile-time check the shuffle layout is correct. - * NOTE: the first field (lowest address) is given last in set_epi - * calls above. - */ - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) != - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) != - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) != - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) != - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12); - - uint16_t i, received; - - for (i = 0, received = 0; i < nb_pkts; - i += IDPF_DESCS_PER_LOOP_AVX, - rxdp += IDPF_DESCS_PER_LOOP_AVX) { - /* step 1, copy over 8 mbuf pointers to rx_pkts array */ - _mm256_storeu_si256((void *)&rx_pkts[i], - _mm256_loadu_si256((void *)&sw_ring[i])); -#ifdef RTE_ARCH_X86_64 - _mm256_storeu_si256 - ((void *)&rx_pkts[i + 4], - _mm256_loadu_si256((void *)&sw_ring[i + 4])); -#endif - - __m512i raw_desc0_3, raw_desc4_7; - const __m128i raw_desc7 = - _mm_load_si128((void *)(rxdp + 7)); - rte_compiler_barrier(); - const __m128i raw_desc6 = - _mm_load_si128((void *)(rxdp + 6)); - rte_compiler_barrier(); - const __m128i raw_desc5 = - _mm_load_si128((void *)(rxdp + 5)); - rte_compiler_barrier(); - const __m128i raw_desc4 = - _mm_load_si128((void *)(rxdp + 4)); - rte_compiler_barrier(); - const __m128i raw_desc3 = - _mm_load_si128((void *)(rxdp + 3)); - rte_compiler_barrier(); - const __m128i raw_desc2 = - _mm_load_si128((void *)(rxdp + 2)); - rte_compiler_barrier(); - const __m128i raw_desc1 = - _mm_load_si128((void *)(rxdp + 1)); - rte_compiler_barrier(); - const __m128i raw_desc0 = - _mm_load_si128((void *)(rxdp + 0)); - - raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4); - raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1); - raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc6, 2); - raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc7, 3); - raw_desc0_3 = _mm512_broadcast_i32x4(raw_desc0); - raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3, raw_desc1, 1); - raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3, raw_desc2, 2); - raw_desc0_3 = _mm512_inserti32x4(raw_desc0_3, raw_desc3, 3); - - /** - * convert descriptors 4-7 into mbufs, adjusting length and - * re-arranging fields. Then write into the mbuf - */ - const __m512i len4_7 = _mm512_slli_epi32(raw_desc4_7, - PKTLEN_SHIFT); - const __m512i desc4_7 = _mm512_mask_blend_epi16(IDPF_RX_LEN_MASK, - raw_desc4_7, - len4_7); - __m512i mb4_7 = _mm512_shuffle_epi8(desc4_7, shuf_msk); - - /** - * to get packet types, shift 64-bit values down 30 bits - * and so ptype is in lower 8-bits in each - */ - const __m512i ptypes4_7 = _mm512_srli_epi64(desc4_7, 16); - const __m256i ptypes6_7 = _mm512_extracti64x4_epi64(ptypes4_7, 1); - const __m256i ptypes4_5 = _mm512_extracti64x4_epi64(ptypes4_7, 0); - const uint8_t ptype7 = _mm256_extract_epi8(ptypes6_7, 16); - const uint8_t ptype6 = _mm256_extract_epi8(ptypes6_7, 0); - const uint8_t ptype5 = _mm256_extract_epi8(ptypes4_5, 16); - const uint8_t ptype4 = _mm256_extract_epi8(ptypes4_5, 0); - - const __m512i ptype4_7 = _mm512_set_epi32 - (0, 0, 0, type_table[ptype7], - 0, 0, 0, type_table[ptype6], - 0, 0, 0, type_table[ptype5], - 0, 0, 0, type_table[ptype4]); - mb4_7 = _mm512_mask_blend_epi32(0x1111, mb4_7, ptype4_7); - - /** - * convert descriptors 0-3 into mbufs, adjusting length and - * re-arranging fields. Then write into the mbuf - */ - const __m512i len0_3 = _mm512_slli_epi32(raw_desc0_3, - PKTLEN_SHIFT); - const __m512i desc0_3 = _mm512_mask_blend_epi16(IDPF_RX_LEN_MASK, - raw_desc0_3, - len0_3); - __m512i mb0_3 = _mm512_shuffle_epi8(desc0_3, shuf_msk); - - /* get the packet types */ - const __m512i ptypes0_3 = _mm512_srli_epi64(desc0_3, 16); - const __m256i ptypes2_3 = _mm512_extracti64x4_epi64(ptypes0_3, 1); - const __m256i ptypes0_1 = _mm512_extracti64x4_epi64(ptypes0_3, 0); - const uint8_t ptype3 = _mm256_extract_epi8(ptypes2_3, 16); - const uint8_t ptype2 = _mm256_extract_epi8(ptypes2_3, 0); - const uint8_t ptype1 = _mm256_extract_epi8(ptypes0_1, 16); - const uint8_t ptype0 = _mm256_extract_epi8(ptypes0_1, 0); - - const __m512i ptype0_3 = _mm512_set_epi32 - (0, 0, 0, type_table[ptype3], - 0, 0, 0, type_table[ptype2], - 0, 0, 0, type_table[ptype1], - 0, 0, 0, type_table[ptype0]); - mb0_3 = _mm512_mask_blend_epi32(0x1111, mb0_3, ptype0_3); - - /** - * use permute/extract to get status content - * After the operations, the packets status flags are in the - * order (hi->lo): [1, 3, 5, 7, 0, 2, 4, 6] - */ - /* merge the status bits into one register */ - const __m512i status_permute_msk = _mm512_set_epi32 - (0, 0, 0, 0, - 0, 0, 0, 0, - 22, 30, 6, 14, - 18, 26, 2, 10); - const __m512i raw_status0_7 = _mm512_permutex2var_epi32 - (raw_desc4_7, status_permute_msk, raw_desc0_3); - __m256i status0_7 = _mm512_extracti64x4_epi64 - (raw_status0_7, 0); - - /* now do flag manipulation */ - - /** - * At this point, we have the 8 sets of flags in the low 16-bits - * of each 32-bit value. - * We want to extract these, and merge them with the mbuf init - * data so we can do a single write to the mbuf to set the flags - * and all the other initialization fields. Extracting the - * appropriate flags means that we have to do a shift and blend - * for each mbuf before we do the write. However, we can also - * add in the previously computed rx_descriptor fields to - * make a single 256-bit write per mbuf - */ - /* check the structure matches expectations */ - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) != - offsetof(struct rte_mbuf, rearm_data) + 8); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) != - RTE_ALIGN(offsetof(struct rte_mbuf, - rearm_data), - 16)); - /* build up data and do writes */ - __m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5, - rearm6, rearm7; - const __m256i mb4_5 = _mm512_extracti64x4_epi64(mb4_7, 0); - const __m256i mb6_7 = _mm512_extracti64x4_epi64(mb4_7, 1); - const __m256i mb0_1 = _mm512_extracti64x4_epi64(mb0_3, 0); - const __m256i mb2_3 = _mm512_extracti64x4_epi64(mb0_3, 1); - - rearm6 = _mm256_permute2f128_si256(mbuf_init, mb6_7, 0x20); - rearm4 = _mm256_permute2f128_si256(mbuf_init, mb4_5, 0x20); - rearm2 = _mm256_permute2f128_si256(mbuf_init, mb2_3, 0x20); - rearm0 = _mm256_permute2f128_si256(mbuf_init, mb0_1, 0x20); - - /* write to mbuf */ - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data, - rearm6); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data, - rearm4); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data, - rearm2); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data, - rearm0); - - rearm7 = _mm256_blend_epi32(mbuf_init, mb6_7, 0xF0); - rearm5 = _mm256_blend_epi32(mbuf_init, mb4_5, 0xF0); - rearm3 = _mm256_blend_epi32(mbuf_init, mb2_3, 0xF0); - rearm1 = _mm256_blend_epi32(mbuf_init, mb0_1, 0xF0); - - /* again write to mbufs */ - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data, - rearm7); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data, - rearm5); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data, - rearm3); - _mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data, - rearm1); - - /* perform dd_check */ - status0_7 = _mm256_and_si256(status0_7, dd_check); - status0_7 = _mm256_packs_epi32(status0_7, - _mm256_setzero_si256()); - - uint64_t burst = __builtin_popcountll - (_mm_cvtsi128_si64 - (_mm256_extracti128_si256 - (status0_7, 1))); - burst += __builtin_popcountll - (_mm_cvtsi128_si64 - (_mm256_castsi256_si128(status0_7))); - received += burst; - if (burst != IDPF_DESCS_PER_LOOP_AVX) - break; - } - - /* update tail pointers */ - rxq->rx_tail += received; - rxq->rx_tail &= (rxq->nb_rx_desc - 1); - if ((rxq->rx_tail & 1) == 1 && received > 1) { /* keep aligned */ - rxq->rx_tail--; - received--; - } - rxq->rxrearm_nb += received; - return received; -} - -/** - * Notice: - * - nb_pkts < IDPF_DESCS_PER_LOOP, just return no packet - */ -uint16_t -idpf_singleq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts) -{ - return _idpf_singleq_recv_raw_pkts_avx512(rx_queue, rx_pkts, nb_pkts); -} - -static __rte_always_inline int -idpf_tx_free_bufs_avx512(struct idpf_tx_queue *txq) -{ - struct idpf_tx_vec_entry *txep; - uint32_t n; - uint32_t i; - int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; - - /* check DD bits on threshold descriptor */ - if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype & - rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) != - rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) - return 0; - - n = txq->rs_thresh; - - /* first buffer to free from S/W ring is at index - * tx_next_dd - (tx_rs_thresh-1) - */ - txep = (void *)txq->sw_ring; - txep += txq->next_dd - (n - 1); - - if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0) { - struct rte_mempool *mp = txep[0].mbuf->pool; - struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, - rte_lcore_id()); - void **cache_objs; - - if (cache == NULL || cache->len == 0) - goto normal; - - cache_objs = &cache->objs[cache->len]; - - if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) { - rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n); - goto done; - } - - /* The cache follows the following algorithm - * 1. Add the objects to the cache - * 2. Anything greater than the cache min value (if it crosses the - * cache flush threshold) is flushed to the ring. - */ - /* Add elements back into the cache */ - uint32_t copied = 0; - /* n is multiple of 32 */ - while (copied < n) { - const __m512i a = _mm512_loadu_si512(&txep[copied]); - const __m512i b = _mm512_loadu_si512(&txep[copied + 8]); - const __m512i c = _mm512_loadu_si512(&txep[copied + 16]); - const __m512i d = _mm512_loadu_si512(&txep[copied + 24]); - - _mm512_storeu_si512(&cache_objs[copied], a); - _mm512_storeu_si512(&cache_objs[copied + 8], b); - _mm512_storeu_si512(&cache_objs[copied + 16], c); - _mm512_storeu_si512(&cache_objs[copied + 24], d); - copied += 32; - } - cache->len += n; - - if (cache->len >= cache->flushthresh) { - rte_mempool_ops_enqueue_bulk(mp, - &cache->objs[cache->size], - cache->len - cache->size); - cache->len = cache->size; - } - goto done; - } - -normal: - m = rte_pktmbuf_prefree_seg(txep[0].mbuf); - if (likely(m != NULL)) { - free[0] = m; - nb_free = 1; - for (i = 1; i < n; i++) { - m = rte_pktmbuf_prefree_seg(txep[i].mbuf); - if (likely(m != NULL)) { - if (likely(m->pool == free[0]->pool)) { - free[nb_free++] = m; - } else { - rte_mempool_put_bulk(free[0]->pool, - (void *)free, - nb_free); - free[0] = m; - nb_free = 1; - } - } - } - rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free); - } else { - for (i = 1; i < n; i++) { - m = rte_pktmbuf_prefree_seg(txep[i].mbuf); - if (m != NULL) - rte_mempool_put(m->pool, m); - } - } - -done: - /* buffers were freed, update counters */ - txq->nb_free = (uint16_t)(txq->nb_free + txq->rs_thresh); - txq->next_dd = (uint16_t)(txq->next_dd + txq->rs_thresh); - if (txq->next_dd >= txq->nb_tx_desc) - txq->next_dd = (uint16_t)(txq->rs_thresh - 1); - - return txq->rs_thresh; -} - -static __rte_always_inline void -tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep, - struct rte_mbuf **tx_pkts, uint16_t nb_pkts) -{ - int i; - - for (i = 0; i < (int)nb_pkts; ++i) - txep[i].mbuf = tx_pkts[i]; -} - -#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48 -static __rte_always_inline void -idpf_vtx1(volatile struct idpf_flex_tx_desc *txdp, - struct rte_mbuf *pkt, uint64_t flags) -{ - uint64_t high_qw = - (IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S | - ((uint64_t)flags << IDPF_FLEX_TXD_QW1_CMD_S) | - ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S)); - - __m128i descriptor = _mm_set_epi64x(high_qw, - pkt->buf_iova + pkt->data_off); - _mm_storeu_si128((__m128i *)txdp, descriptor); -} - -#define IDPF_TX_LEN_MASK 0xAA -#define IDPF_TX_OFF_MASK 0x55 -static __rte_always_inline void -idpf_vtx(volatile struct idpf_flex_tx_desc *txdp, - struct rte_mbuf **pkt, uint16_t nb_pkts, uint64_t flags) -{ - const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA | - ((uint64_t)flags << IDPF_FLEX_TXD_QW1_CMD_S)); - - /* if unaligned on 32-bit boundary, do one to align */ - if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { - idpf_vtx1(txdp, *pkt, flags); - nb_pkts--, txdp++, pkt++; - } - - /* do 4 at a time while possible, in bursts */ - for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) { - uint64_t hi_qw3 = - hi_qw_tmpl | - ((uint64_t)pkt[3]->data_len << - IDPF_FLEX_TXD_QW1_BUF_SZ_S); - uint64_t hi_qw2 = - hi_qw_tmpl | - ((uint64_t)pkt[2]->data_len << - IDPF_FLEX_TXD_QW1_BUF_SZ_S); - uint64_t hi_qw1 = - hi_qw_tmpl | - ((uint64_t)pkt[1]->data_len << - IDPF_FLEX_TXD_QW1_BUF_SZ_S); - uint64_t hi_qw0 = - hi_qw_tmpl | - ((uint64_t)pkt[0]->data_len << - IDPF_FLEX_TXD_QW1_BUF_SZ_S); - - __m512i desc0_3 = - _mm512_set_epi64 - (hi_qw3, - pkt[3]->buf_iova + pkt[3]->data_off, - hi_qw2, - pkt[2]->buf_iova + pkt[2]->data_off, - hi_qw1, - pkt[1]->buf_iova + pkt[1]->data_off, - hi_qw0, - pkt[0]->buf_iova + pkt[0]->data_off); - _mm512_storeu_si512((void *)txdp, desc0_3); - } - - /* do any last ones */ - while (nb_pkts) { - idpf_vtx1(txdp, *pkt, flags); - txdp++, pkt++, nb_pkts--; - } -} - -static __rte_always_inline uint16_t -idpf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) -{ - struct idpf_tx_queue *txq = tx_queue; - volatile struct idpf_flex_tx_desc *txdp; - struct idpf_tx_vec_entry *txep; - uint16_t n, nb_commit, tx_id; - uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP; - uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags; - - /* cross rx_thresh boundary is not allowed */ - nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh); - - if (txq->nb_free < txq->free_thresh) - idpf_tx_free_bufs_avx512(txq); - - nb_pkts = (uint16_t)RTE_MIN(txq->nb_free, nb_pkts); - nb_commit = nb_pkts; - if (unlikely(nb_pkts == 0)) - return 0; - - tx_id = txq->tx_tail; - txdp = &txq->tx_ring[tx_id]; - txep = (void *)txq->sw_ring; - txep += tx_id; - - txq->nb_free = (uint16_t)(txq->nb_free - nb_pkts); - - n = (uint16_t)(txq->nb_tx_desc - tx_id); - if (nb_commit >= n) { - tx_backlog_entry_avx512(txep, tx_pkts, n); - - idpf_vtx(txdp, tx_pkts, n - 1, flags); - tx_pkts += (n - 1); - txdp += (n - 1); - - idpf_vtx1(txdp, *tx_pkts++, rs); - - nb_commit = (uint16_t)(nb_commit - n); - - tx_id = 0; - txq->next_rs = (uint16_t)(txq->rs_thresh - 1); - - /* avoid reach the end of ring */ - txdp = &txq->tx_ring[tx_id]; - txep = (void *)txq->sw_ring; - txep += tx_id; - } - - tx_backlog_entry_avx512(txep, tx_pkts, nb_commit); - - idpf_vtx(txdp, tx_pkts, nb_commit, flags); - - tx_id = (uint16_t)(tx_id + nb_commit); - if (tx_id > txq->next_rs) { - txq->tx_ring[txq->next_rs].qw1.cmd_dtype |= - rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) << - IDPF_FLEX_TXD_QW1_CMD_S); - txq->next_rs = - (uint16_t)(txq->next_rs + txq->rs_thresh); - } - - txq->tx_tail = tx_id; - - IDPF_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail); - - return nb_pkts; -} - -static __rte_always_inline uint16_t -idpf_xmit_pkts_vec_avx512_cmn(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) -{ - uint16_t nb_tx = 0; - struct idpf_tx_queue *txq = tx_queue; - - while (nb_pkts) { - uint16_t ret, num; - - num = (uint16_t)RTE_MIN(nb_pkts, txq->rs_thresh); - ret = idpf_xmit_fixed_burst_vec_avx512(tx_queue, &tx_pkts[nb_tx], - num); - nb_tx += ret; - nb_pkts -= ret; - if (ret < num) - break; - } - - return nb_tx; -} - -uint16_t -idpf_singleq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts) -{ - return idpf_xmit_pkts_vec_avx512_cmn(tx_queue, tx_pkts, nb_pkts); -} - -static inline void -idpf_singleq_tx_release_mbufs_avx512(struct idpf_tx_queue *txq) -{ - unsigned int i; - const uint16_t max_desc = (uint16_t)(txq->nb_tx_desc - 1); - struct idpf_tx_vec_entry *swr = (void *)txq->sw_ring; - - if (txq->sw_ring == NULL || txq->nb_free == max_desc) - return; - - i = txq->next_dd - txq->rs_thresh + 1; - if (txq->tx_tail < i) { - for (; i < txq->nb_tx_desc; i++) { - rte_pktmbuf_free_seg(swr[i].mbuf); - swr[i].mbuf = NULL; - } - i = 0; - } - for (; i < txq->tx_tail; i++) { - rte_pktmbuf_free_seg(swr[i].mbuf); - swr[i].mbuf = NULL; - } -} - -static const struct idpf_txq_ops avx512_singleq_tx_vec_ops = { - .release_mbufs = idpf_singleq_tx_release_mbufs_avx512, -}; - -int __rte_cold -idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq) -{ - txq->ops = &avx512_singleq_tx_vec_ops; - return 0; -} diff --git a/dpdk/drivers/net/idpf/idpf_vchnl.c b/dpdk/drivers/net/idpf/idpf_vchnl.c deleted file mode 100644 index ac6486d4e..000000000 --- a/dpdk/drivers/net/idpf/idpf_vchnl.c +++ /dev/null @@ -1,1416 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "idpf_ethdev.h" -#include "idpf_rxtx.h" - -static int -idpf_vc_clean(struct idpf_adapter *adapter) -{ - struct idpf_ctlq_msg *q_msg[IDPF_CTLQ_LEN]; - uint16_t num_q_msg = IDPF_CTLQ_LEN; - struct idpf_dma_mem *dma_mem; - int err; - uint32_t i; - - for (i = 0; i < 10; i++) { - err = idpf_ctlq_clean_sq(adapter->hw.asq, &num_q_msg, q_msg); - msleep(20); - if (num_q_msg > 0) - break; - } - if (err != 0) - return err; - - /* Empty queue is not an error */ - for (i = 0; i < num_q_msg; i++) { - dma_mem = q_msg[i]->ctx.indirect.payload; - if (dma_mem != NULL) { - idpf_free_dma_mem(&adapter->hw, dma_mem); - rte_free(dma_mem); - } - rte_free(q_msg[i]); - } - - return 0; -} - -static int -idpf_send_vc_msg(struct idpf_adapter *adapter, uint32_t op, - uint16_t msg_size, uint8_t *msg) -{ - struct idpf_ctlq_msg *ctlq_msg; - struct idpf_dma_mem *dma_mem; - int err; - - err = idpf_vc_clean(adapter); - if (err != 0) - goto err; - - ctlq_msg = rte_zmalloc(NULL, sizeof(struct idpf_ctlq_msg), 0); - if (ctlq_msg == NULL) { - err = -ENOMEM; - goto err; - } - - dma_mem = rte_zmalloc(NULL, sizeof(struct idpf_dma_mem), 0); - if (dma_mem == NULL) { - err = -ENOMEM; - goto dma_mem_error; - } - - dma_mem->size = IDPF_DFLT_MBX_BUF_SIZE; - idpf_alloc_dma_mem(&adapter->hw, dma_mem, dma_mem->size); - if (dma_mem->va == NULL) { - err = -ENOMEM; - goto dma_alloc_error; - } - - memcpy(dma_mem->va, msg, msg_size); - - ctlq_msg->opcode = idpf_mbq_opc_send_msg_to_pf; - ctlq_msg->func_id = 0; - ctlq_msg->data_len = msg_size; - ctlq_msg->cookie.mbx.chnl_opcode = op; - ctlq_msg->cookie.mbx.chnl_retval = VIRTCHNL_STATUS_SUCCESS; - ctlq_msg->ctx.indirect.payload = dma_mem; - - err = idpf_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg); - if (err != 0) - goto send_error; - - return 0; - -send_error: - idpf_free_dma_mem(&adapter->hw, dma_mem); -dma_alloc_error: - rte_free(dma_mem); -dma_mem_error: - rte_free(ctlq_msg); -err: - return err; -} - -static enum idpf_vc_result -idpf_read_msg_from_cp(struct idpf_adapter *adapter, uint16_t buf_len, - uint8_t *buf) -{ - struct idpf_hw *hw = &adapter->hw; - struct idpf_ctlq_msg ctlq_msg; - struct idpf_dma_mem *dma_mem = NULL; - enum idpf_vc_result result = IDPF_MSG_NON; - uint32_t opcode; - uint16_t pending = 1; - int ret; - - ret = idpf_ctlq_recv(hw->arq, &pending, &ctlq_msg); - if (ret != 0) { - PMD_DRV_LOG(DEBUG, "Can't read msg from AQ"); - if (ret != -ENOMSG) - result = IDPF_MSG_ERR; - return result; - } - - rte_memcpy(buf, ctlq_msg.ctx.indirect.payload->va, buf_len); - - opcode = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode); - adapter->cmd_retval = - (enum virtchnl_status_code)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval); - - PMD_DRV_LOG(DEBUG, "CQ from CP carries opcode %u, retval %d", - opcode, adapter->cmd_retval); - - if (opcode == VIRTCHNL2_OP_EVENT) { - struct virtchnl2_event *ve = - (struct virtchnl2_event *)ctlq_msg.ctx.indirect.payload->va; - - result = IDPF_MSG_SYS; - switch (ve->event) { - case VIRTCHNL2_EVENT_LINK_CHANGE: - /* TBD */ - break; - default: - PMD_DRV_LOG(ERR, "%s: Unknown event %d from CP", - __func__, ve->event); - break; - } - } else { - /* async reply msg on command issued by pf previously */ - result = IDPF_MSG_CMD; - if (opcode != adapter->pend_cmd) { - PMD_DRV_LOG(WARNING, "command mismatch, expect %u, get %u", - adapter->pend_cmd, opcode); - result = IDPF_MSG_ERR; - } - } - - if (ctlq_msg.data_len != 0) - dma_mem = ctlq_msg.ctx.indirect.payload; - else - pending = 0; - - ret = idpf_ctlq_post_rx_buffs(hw, hw->arq, &pending, &dma_mem); - if (ret != 0 && dma_mem != NULL) - idpf_free_dma_mem(hw, dma_mem); - - return result; -} - -#define MAX_TRY_TIMES 200 -#define ASQ_DELAY_MS 10 - -int -idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, uint16_t buf_len, - uint8_t *buf) -{ - int err = 0; - int i = 0; - int ret; - - do { - ret = idpf_read_msg_from_cp(adapter, buf_len, buf); - if (ret == IDPF_MSG_CMD) - break; - rte_delay_ms(ASQ_DELAY_MS); - } while (i++ < MAX_TRY_TIMES); - if (i >= MAX_TRY_TIMES || - adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) { - err = -EBUSY; - PMD_DRV_LOG(ERR, "No response or return failure (%d) for cmd %d", - adapter->cmd_retval, ops); - } - - return err; -} - -static int -idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args) -{ - int err = 0; - int i = 0; - int ret; - - if (atomic_set_cmd(adapter, args->ops)) - return -EINVAL; - - ret = idpf_send_vc_msg(adapter, args->ops, args->in_args_size, args->in_args); - if (ret != 0) { - PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops); - clear_cmd(adapter); - return ret; - } - - switch (args->ops) { - case VIRTCHNL_OP_VERSION: - case VIRTCHNL2_OP_GET_CAPS: - case VIRTCHNL2_OP_CREATE_VPORT: - case VIRTCHNL2_OP_DESTROY_VPORT: - case VIRTCHNL2_OP_SET_RSS_KEY: - case VIRTCHNL2_OP_SET_RSS_LUT: - case VIRTCHNL2_OP_SET_RSS_HASH: - case VIRTCHNL2_OP_CONFIG_RX_QUEUES: - case VIRTCHNL2_OP_CONFIG_TX_QUEUES: - case VIRTCHNL2_OP_ENABLE_QUEUES: - case VIRTCHNL2_OP_DISABLE_QUEUES: - case VIRTCHNL2_OP_ENABLE_VPORT: - case VIRTCHNL2_OP_DISABLE_VPORT: - case VIRTCHNL2_OP_MAP_QUEUE_VECTOR: - case VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR: - case VIRTCHNL2_OP_ALLOC_VECTORS: - case VIRTCHNL2_OP_DEALLOC_VECTORS: - /* for init virtchnl ops, need to poll the response */ - err = idpf_read_one_msg(adapter, args->ops, args->out_size, args->out_buffer); - clear_cmd(adapter); - break; - case VIRTCHNL2_OP_GET_PTYPE_INFO: - /* for multuple response message, - * do not handle the response here. - */ - break; - default: - /* For other virtchnl ops in running time, - * wait for the cmd done flag. - */ - do { - if (adapter->pend_cmd == VIRTCHNL_OP_UNKNOWN) - break; - rte_delay_ms(ASQ_DELAY_MS); - /* If don't read msg or read sys event, continue */ - } while (i++ < MAX_TRY_TIMES); - /* If there's no response is received, clear command */ - if (i >= MAX_TRY_TIMES || - adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) { - err = -EBUSY; - PMD_DRV_LOG(ERR, "No response or return failure (%d) for cmd %d", - adapter->cmd_retval, args->ops); - clear_cmd(adapter); - } - break; - } - - return err; -} - -int -idpf_vc_check_api_version(struct idpf_adapter *adapter) -{ - struct virtchnl2_version_info version, *pver; - struct idpf_cmd_info args; - int err; - - memset(&version, 0, sizeof(struct virtchnl_version_info)); - version.major = VIRTCHNL2_VERSION_MAJOR_2; - version.minor = VIRTCHNL2_VERSION_MINOR_0; - - args.ops = VIRTCHNL_OP_VERSION; - args.in_args = (uint8_t *)&version; - args.in_args_size = sizeof(version); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) { - PMD_DRV_LOG(ERR, - "Failed to execute command of VIRTCHNL_OP_VERSION"); - return err; - } - - pver = (struct virtchnl2_version_info *)args.out_buffer; - adapter->virtchnl_version = *pver; - - if (adapter->virtchnl_version.major != VIRTCHNL2_VERSION_MAJOR_2 || - adapter->virtchnl_version.minor != VIRTCHNL2_VERSION_MINOR_0) { - PMD_INIT_LOG(ERR, "VIRTCHNL API version mismatch:(%u.%u)-(%u.%u)", - adapter->virtchnl_version.major, - adapter->virtchnl_version.minor, - VIRTCHNL2_VERSION_MAJOR_2, - VIRTCHNL2_VERSION_MINOR_0); - return -EINVAL; - } - - return 0; -} - -int __rte_cold -idpf_get_pkt_type(struct idpf_adapter *adapter) -{ - struct virtchnl2_get_ptype_info *ptype_info; - uint16_t ptype_recvd = 0, ptype_offset, i, j; - int ret; - - ret = idpf_vc_query_ptype_info(adapter); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Fail to query packet type information"); - return ret; - } - - ptype_info = rte_zmalloc("ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 0); - if (ptype_info == NULL) - return -ENOMEM; - - while (ptype_recvd < IDPF_MAX_PKT_TYPE) { - ret = idpf_read_one_msg(adapter, VIRTCHNL2_OP_GET_PTYPE_INFO, - IDPF_DFLT_MBX_BUF_SIZE, (u8 *)ptype_info); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Fail to get packet type information"); - goto free_ptype_info; - } - - ptype_recvd += ptype_info->num_ptypes; - ptype_offset = sizeof(struct virtchnl2_get_ptype_info) - - sizeof(struct virtchnl2_ptype); - - for (i = 0; i < rte_cpu_to_le_16(ptype_info->num_ptypes); i++) { - bool is_inner = false, is_ip = false; - struct virtchnl2_ptype *ptype; - uint32_t proto_hdr = 0; - - ptype = (struct virtchnl2_ptype *) - ((u8 *)ptype_info + ptype_offset); - ptype_offset += IDPF_GET_PTYPE_SIZE(ptype); - if (ptype_offset > IDPF_DFLT_MBX_BUF_SIZE) { - ret = -EINVAL; - goto free_ptype_info; - } - - if (rte_cpu_to_le_16(ptype->ptype_id_10) == 0xFFFF) - goto free_ptype_info; - - for (j = 0; j < ptype->proto_id_count; j++) { - switch (rte_cpu_to_le_16(ptype->proto_id[j])) { - case VIRTCHNL2_PROTO_HDR_GRE: - case VIRTCHNL2_PROTO_HDR_VXLAN: - proto_hdr &= ~RTE_PTYPE_L4_MASK; - proto_hdr |= RTE_PTYPE_TUNNEL_GRENAT; - is_inner = true; - break; - case VIRTCHNL2_PROTO_HDR_MAC: - if (is_inner) { - proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK; - proto_hdr |= RTE_PTYPE_INNER_L2_ETHER; - } else { - proto_hdr &= ~RTE_PTYPE_L2_MASK; - proto_hdr |= RTE_PTYPE_L2_ETHER; - } - break; - case VIRTCHNL2_PROTO_HDR_VLAN: - if (is_inner) { - proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK; - proto_hdr |= RTE_PTYPE_INNER_L2_ETHER_VLAN; - } - break; - case VIRTCHNL2_PROTO_HDR_PTP: - proto_hdr &= ~RTE_PTYPE_L2_MASK; - proto_hdr |= RTE_PTYPE_L2_ETHER_TIMESYNC; - break; - case VIRTCHNL2_PROTO_HDR_LLDP: - proto_hdr &= ~RTE_PTYPE_L2_MASK; - proto_hdr |= RTE_PTYPE_L2_ETHER_LLDP; - break; - case VIRTCHNL2_PROTO_HDR_ARP: - proto_hdr &= ~RTE_PTYPE_L2_MASK; - proto_hdr |= RTE_PTYPE_L2_ETHER_ARP; - break; - case VIRTCHNL2_PROTO_HDR_PPPOE: - proto_hdr &= ~RTE_PTYPE_L2_MASK; - proto_hdr |= RTE_PTYPE_L2_ETHER_PPPOE; - break; - case VIRTCHNL2_PROTO_HDR_IPV4: - if (!is_ip) { - proto_hdr |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; - is_ip = true; - } else { - proto_hdr |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | - RTE_PTYPE_TUNNEL_IP; - is_inner = true; - } - break; - case VIRTCHNL2_PROTO_HDR_IPV6: - if (!is_ip) { - proto_hdr |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; - is_ip = true; - } else { - proto_hdr |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | - RTE_PTYPE_TUNNEL_IP; - is_inner = true; - } - break; - case VIRTCHNL2_PROTO_HDR_IPV4_FRAG: - case VIRTCHNL2_PROTO_HDR_IPV6_FRAG: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_FRAG; - else - proto_hdr |= RTE_PTYPE_L4_FRAG; - break; - case VIRTCHNL2_PROTO_HDR_UDP: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_UDP; - else - proto_hdr |= RTE_PTYPE_L4_UDP; - break; - case VIRTCHNL2_PROTO_HDR_TCP: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_TCP; - else - proto_hdr |= RTE_PTYPE_L4_TCP; - break; - case VIRTCHNL2_PROTO_HDR_SCTP: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_SCTP; - else - proto_hdr |= RTE_PTYPE_L4_SCTP; - break; - case VIRTCHNL2_PROTO_HDR_ICMP: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_ICMP; - else - proto_hdr |= RTE_PTYPE_L4_ICMP; - break; - case VIRTCHNL2_PROTO_HDR_ICMPV6: - if (is_inner) - proto_hdr |= RTE_PTYPE_INNER_L4_ICMP; - else - proto_hdr |= RTE_PTYPE_L4_ICMP; - break; - case VIRTCHNL2_PROTO_HDR_L2TPV2: - case VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL: - case VIRTCHNL2_PROTO_HDR_L2TPV3: - is_inner = true; - proto_hdr |= RTE_PTYPE_TUNNEL_L2TP; - break; - case VIRTCHNL2_PROTO_HDR_NVGRE: - is_inner = true; - proto_hdr |= RTE_PTYPE_TUNNEL_NVGRE; - break; - case VIRTCHNL2_PROTO_HDR_GTPC_TEID: - is_inner = true; - proto_hdr |= RTE_PTYPE_TUNNEL_GTPC; - break; - case VIRTCHNL2_PROTO_HDR_GTPU: - case VIRTCHNL2_PROTO_HDR_GTPU_UL: - case VIRTCHNL2_PROTO_HDR_GTPU_DL: - is_inner = true; - proto_hdr |= RTE_PTYPE_TUNNEL_GTPU; - break; - case VIRTCHNL2_PROTO_HDR_PAY: - case VIRTCHNL2_PROTO_HDR_IPV6_EH: - case VIRTCHNL2_PROTO_HDR_PRE_MAC: - case VIRTCHNL2_PROTO_HDR_POST_MAC: - case VIRTCHNL2_PROTO_HDR_ETHERTYPE: - case VIRTCHNL2_PROTO_HDR_SVLAN: - case VIRTCHNL2_PROTO_HDR_CVLAN: - case VIRTCHNL2_PROTO_HDR_MPLS: - case VIRTCHNL2_PROTO_HDR_MMPLS: - case VIRTCHNL2_PROTO_HDR_CTRL: - case VIRTCHNL2_PROTO_HDR_ECP: - case VIRTCHNL2_PROTO_HDR_EAPOL: - case VIRTCHNL2_PROTO_HDR_PPPOD: - case VIRTCHNL2_PROTO_HDR_IGMP: - case VIRTCHNL2_PROTO_HDR_AH: - case VIRTCHNL2_PROTO_HDR_ESP: - case VIRTCHNL2_PROTO_HDR_IKE: - case VIRTCHNL2_PROTO_HDR_NATT_KEEP: - case VIRTCHNL2_PROTO_HDR_GTP: - case VIRTCHNL2_PROTO_HDR_GTP_EH: - case VIRTCHNL2_PROTO_HDR_GTPCV2: - case VIRTCHNL2_PROTO_HDR_ECPRI: - case VIRTCHNL2_PROTO_HDR_VRRP: - case VIRTCHNL2_PROTO_HDR_OSPF: - case VIRTCHNL2_PROTO_HDR_TUN: - case VIRTCHNL2_PROTO_HDR_VXLAN_GPE: - case VIRTCHNL2_PROTO_HDR_GENEVE: - case VIRTCHNL2_PROTO_HDR_NSH: - case VIRTCHNL2_PROTO_HDR_QUIC: - case VIRTCHNL2_PROTO_HDR_PFCP: - case VIRTCHNL2_PROTO_HDR_PFCP_NODE: - case VIRTCHNL2_PROTO_HDR_PFCP_SESSION: - case VIRTCHNL2_PROTO_HDR_RTP: - case VIRTCHNL2_PROTO_HDR_NO_PROTO: - default: - continue; - } - adapter->ptype_tbl[ptype->ptype_id_10] = proto_hdr; - } - } - } - -free_ptype_info: - rte_free(ptype_info); - clear_cmd(adapter); - return ret; -} - -int -idpf_vc_get_caps(struct idpf_adapter *adapter) -{ - struct virtchnl2_get_capabilities caps_msg; - struct idpf_cmd_info args; - int err; - - memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities)); - - caps_msg.csum_caps = - VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP | - VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP | - VIRTCHNL2_CAP_TX_CSUM_GENERIC | - VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP | - VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP | - VIRTCHNL2_CAP_RX_CSUM_GENERIC; - - caps_msg.rss_caps = - VIRTCHNL2_CAP_RSS_IPV4_TCP | - VIRTCHNL2_CAP_RSS_IPV4_UDP | - VIRTCHNL2_CAP_RSS_IPV4_SCTP | - VIRTCHNL2_CAP_RSS_IPV4_OTHER | - VIRTCHNL2_CAP_RSS_IPV6_TCP | - VIRTCHNL2_CAP_RSS_IPV6_UDP | - VIRTCHNL2_CAP_RSS_IPV6_SCTP | - VIRTCHNL2_CAP_RSS_IPV6_OTHER | - VIRTCHNL2_CAP_RSS_IPV4_AH | - VIRTCHNL2_CAP_RSS_IPV4_ESP | - VIRTCHNL2_CAP_RSS_IPV4_AH_ESP | - VIRTCHNL2_CAP_RSS_IPV6_AH | - VIRTCHNL2_CAP_RSS_IPV6_ESP | - VIRTCHNL2_CAP_RSS_IPV6_AH_ESP; - - caps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR; - - args.ops = VIRTCHNL2_OP_GET_CAPS; - args.in_args = (uint8_t *)&caps_msg; - args.in_args_size = sizeof(caps_msg); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) { - PMD_DRV_LOG(ERR, - "Failed to execute command of VIRTCHNL2_OP_GET_CAPS"); - return err; - } - - rte_memcpy(adapter->caps, args.out_buffer, sizeof(caps_msg)); - - return 0; -} - -int -idpf_vc_create_vport(struct idpf_adapter *adapter) -{ - uint16_t idx = adapter->cur_vport_idx; - struct virtchnl2_create_vport *vport_req_info = - (struct virtchnl2_create_vport *)adapter->vport_req_info[idx]; - struct virtchnl2_create_vport vport_msg; - struct idpf_cmd_info args; - int err = -1; - - memset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport)); - vport_msg.vport_type = vport_req_info->vport_type; - vport_msg.txq_model = vport_req_info->txq_model; - vport_msg.rxq_model = vport_req_info->rxq_model; - vport_msg.num_tx_q = vport_req_info->num_tx_q; - vport_msg.num_tx_complq = vport_req_info->num_tx_complq; - vport_msg.num_rx_q = vport_req_info->num_rx_q; - vport_msg.num_rx_bufq = vport_req_info->num_rx_bufq; - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_CREATE_VPORT; - args.in_args = (uint8_t *)&vport_msg; - args.in_args_size = sizeof(vport_msg); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) { - PMD_DRV_LOG(ERR, - "Failed to execute command of VIRTCHNL2_OP_CREATE_VPORT"); - return err; - } - - if (adapter->vport_recv_info[idx] == NULL) { - adapter->vport_recv_info[idx] = rte_zmalloc(NULL, - IDPF_DFLT_MBX_BUF_SIZE, 0); - if (adapter->vport_recv_info[idx] == NULL) { - PMD_INIT_LOG(ERR, "Failed to alloc vport_recv_info."); - return -ENOMEM; - } - } - rte_memcpy(adapter->vport_recv_info[idx], args.out_buffer, - IDPF_DFLT_MBX_BUF_SIZE); - return 0; -} - -int -idpf_vc_destroy_vport(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_vport vc_vport; - struct idpf_cmd_info args; - int err; - - vc_vport.vport_id = vport->vport_id; - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_DESTROY_VPORT; - args.in_args = (uint8_t *)&vc_vport; - args.in_args_size = sizeof(vc_vport); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_DESTROY_VPORT"); - - return err; -} - -int -idpf_vc_set_rss_key(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_rss_key *rss_key; - struct idpf_cmd_info args; - int len, err; - - len = sizeof(*rss_key) + sizeof(rss_key->key[0]) * - (vport->rss_key_size - 1); - rss_key = rte_zmalloc("rss_key", len, 0); - if (rss_key == NULL) - return -ENOMEM; - - rss_key->vport_id = vport->vport_id; - rss_key->key_len = vport->rss_key_size; - rte_memcpy(rss_key->key, vport->rss_key, - sizeof(rss_key->key[0]) * vport->rss_key_size); - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_SET_RSS_KEY; - args.in_args = (uint8_t *)rss_key; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_SET_RSS_KEY"); - - rte_free(rss_key); - return err; -} - -int -idpf_vc_set_rss_lut(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_rss_lut *rss_lut; - struct idpf_cmd_info args; - int len, err; - - len = sizeof(*rss_lut) + sizeof(rss_lut->lut[0]) * - (vport->rss_lut_size - 1); - rss_lut = rte_zmalloc("rss_lut", len, 0); - if (rss_lut == NULL) - return -ENOMEM; - - rss_lut->vport_id = vport->vport_id; - rss_lut->lut_entries = vport->rss_lut_size; - rte_memcpy(rss_lut->lut, vport->rss_lut, - sizeof(rss_lut->lut[0]) * vport->rss_lut_size); - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_SET_RSS_LUT; - args.in_args = (uint8_t *)rss_lut; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_SET_RSS_LUT"); - - rte_free(rss_lut); - return err; -} - -int -idpf_vc_set_rss_hash(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_rss_hash rss_hash; - struct idpf_cmd_info args; - int err; - - memset(&rss_hash, 0, sizeof(rss_hash)); - rss_hash.ptype_groups = vport->rss_hf; - rss_hash.vport_id = vport->vport_id; - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_SET_RSS_HASH; - args.in_args = (uint8_t *)&rss_hash; - args.in_args_size = sizeof(rss_hash); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of OP_SET_RSS_HASH"); - - return err; -} - -#define IDPF_RX_BUF_STRIDE 64 -int -idpf_vc_config_rxqs(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct idpf_rx_queue **rxq = - (struct idpf_rx_queue **)vport->dev_data->rx_queues; - struct virtchnl2_config_rx_queues *vc_rxqs = NULL; - struct virtchnl2_rxq_info *rxq_info; - struct idpf_cmd_info args; - uint16_t total_qs, num_qs; - int size, i, j; - int err = 0; - int k = 0; - - total_qs = vport->num_rx_q + vport->num_rx_bufq; - while (total_qs) { - if (total_qs > adapter->max_rxq_per_msg) { - num_qs = adapter->max_rxq_per_msg; - total_qs -= adapter->max_rxq_per_msg; - } else { - num_qs = total_qs; - total_qs = 0; - } - - size = sizeof(*vc_rxqs) + (num_qs - 1) * - sizeof(struct virtchnl2_rxq_info); - vc_rxqs = rte_zmalloc("cfg_rxqs", size, 0); - if (vc_rxqs == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_rx_queues"); - err = -ENOMEM; - break; - } - vc_rxqs->vport_id = vport->vport_id; - vc_rxqs->num_qinfo = num_qs; - if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) { - for (i = 0; i < num_qs; i++, k++) { - rxq_info = &vc_rxqs->qinfo[i]; - rxq_info->dma_ring_addr = rxq[k]->rx_ring_phys_addr; - rxq_info->type = VIRTCHNL2_QUEUE_TYPE_RX; - rxq_info->queue_id = rxq[k]->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE; - rxq_info->data_buffer_size = rxq[k]->rx_buf_len; - rxq_info->max_pkt_size = vport->max_pkt_len; - - rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SQ_NIC_M; - rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE; - - rxq_info->ring_len = rxq[k]->nb_rx_desc; - } - } else { - for (i = 0; i < num_qs / 3; i++, k++) { - /* Rx queue */ - rxq_info = &vc_rxqs->qinfo[i * 3]; - rxq_info->dma_ring_addr = - rxq[k]->rx_ring_phys_addr; - rxq_info->type = VIRTCHNL2_QUEUE_TYPE_RX; - rxq_info->queue_id = rxq[k]->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - rxq_info->data_buffer_size = rxq[k]->rx_buf_len; - rxq_info->max_pkt_size = vport->max_pkt_len; - - rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M; - rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE; - - rxq_info->ring_len = rxq[k]->nb_rx_desc; - rxq_info->rx_bufq1_id = rxq[k]->bufq1->queue_id; - rxq_info->rx_bufq2_id = rxq[k]->bufq2->queue_id; - rxq_info->rx_buffer_low_watermark = 64; - - /* Buffer queue */ - for (j = 1; j <= IDPF_RX_BUFQ_PER_GRP; j++) { - struct idpf_rx_queue *bufq = j == 1 ? - rxq[k]->bufq1 : rxq[k]->bufq2; - rxq_info = &vc_rxqs->qinfo[i * 3 + j]; - rxq_info->dma_ring_addr = - bufq->rx_ring_phys_addr; - rxq_info->type = - VIRTCHNL2_QUEUE_TYPE_RX_BUFFER; - rxq_info->queue_id = bufq->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - rxq_info->data_buffer_size = bufq->rx_buf_len; - rxq_info->desc_ids = - VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M; - rxq_info->ring_len = bufq->nb_rx_desc; - - rxq_info->buffer_notif_stride = - IDPF_RX_BUF_STRIDE; - rxq_info->rx_buffer_low_watermark = 64; - } - } - } - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_CONFIG_RX_QUEUES; - args.in_args = (uint8_t *)vc_rxqs; - args.in_args_size = size; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - rte_free(vc_rxqs); - if (err != 0) { - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES"); - break; - } - } - - return err; -} - -int -idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id) -{ - struct idpf_adapter *adapter = vport->adapter; - struct idpf_rx_queue **rxq = - (struct idpf_rx_queue **)vport->dev_data->rx_queues; - struct virtchnl2_config_rx_queues *vc_rxqs = NULL; - struct virtchnl2_rxq_info *rxq_info; - struct idpf_cmd_info args; - uint16_t num_qs; - int size, err, i; - - if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) - num_qs = IDPF_RXQ_PER_GRP; - else - num_qs = IDPF_RXQ_PER_GRP + IDPF_RX_BUFQ_PER_GRP; - - size = sizeof(*vc_rxqs) + (num_qs - 1) * - sizeof(struct virtchnl2_rxq_info); - vc_rxqs = rte_zmalloc("cfg_rxqs", size, 0); - if (vc_rxqs == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_rx_queues"); - err = -ENOMEM; - return err; - } - vc_rxqs->vport_id = vport->vport_id; - vc_rxqs->num_qinfo = num_qs; - if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) { - rxq_info = &vc_rxqs->qinfo[0]; - rxq_info->dma_ring_addr = rxq[rxq_id]->rx_ring_phys_addr; - rxq_info->type = VIRTCHNL2_QUEUE_TYPE_RX; - rxq_info->queue_id = rxq[rxq_id]->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE; - rxq_info->data_buffer_size = rxq[rxq_id]->rx_buf_len; - rxq_info->max_pkt_size = vport->max_pkt_len; - - rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SQ_NIC_M; - rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE; - - rxq_info->ring_len = rxq[rxq_id]->nb_rx_desc; - } else { - /* Rx queue */ - rxq_info = &vc_rxqs->qinfo[0]; - rxq_info->dma_ring_addr = rxq[rxq_id]->rx_ring_phys_addr; - rxq_info->type = VIRTCHNL2_QUEUE_TYPE_RX; - rxq_info->queue_id = rxq[rxq_id]->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - rxq_info->data_buffer_size = rxq[rxq_id]->rx_buf_len; - rxq_info->max_pkt_size = vport->max_pkt_len; - - rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M; - rxq_info->qflags |= VIRTCHNL2_RX_DESC_SIZE_32BYTE; - - rxq_info->ring_len = rxq[rxq_id]->nb_rx_desc; - rxq_info->rx_bufq1_id = rxq[rxq_id]->bufq1->queue_id; - rxq_info->rx_bufq2_id = rxq[rxq_id]->bufq2->queue_id; - rxq_info->rx_buffer_low_watermark = 64; - - /* Buffer queue */ - for (i = 1; i <= IDPF_RX_BUFQ_PER_GRP; i++) { - struct idpf_rx_queue *bufq = - i == 1 ? rxq[rxq_id]->bufq1 : rxq[rxq_id]->bufq2; - rxq_info = &vc_rxqs->qinfo[i]; - rxq_info->dma_ring_addr = bufq->rx_ring_phys_addr; - rxq_info->type = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER; - rxq_info->queue_id = bufq->queue_id; - rxq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - rxq_info->data_buffer_size = bufq->rx_buf_len; - rxq_info->desc_ids = VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M; - rxq_info->ring_len = bufq->nb_rx_desc; - - rxq_info->buffer_notif_stride = IDPF_RX_BUF_STRIDE; - rxq_info->rx_buffer_low_watermark = 64; - } - } - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_CONFIG_RX_QUEUES; - args.in_args = (uint8_t *)vc_rxqs; - args.in_args_size = size; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - rte_free(vc_rxqs); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES"); - - return err; -} - -int -idpf_vc_config_txqs(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct idpf_tx_queue **txq = - (struct idpf_tx_queue **)vport->dev_data->tx_queues; - struct virtchnl2_config_tx_queues *vc_txqs = NULL; - struct virtchnl2_txq_info *txq_info; - struct idpf_cmd_info args; - uint16_t total_qs, num_qs; - int size, i; - int err = 0; - int k = 0; - - total_qs = vport->num_tx_q + vport->num_tx_complq; - while (total_qs) { - if (total_qs > adapter->max_txq_per_msg) { - num_qs = adapter->max_txq_per_msg; - total_qs -= adapter->max_txq_per_msg; - } else { - num_qs = total_qs; - total_qs = 0; - } - size = sizeof(*vc_txqs) + (num_qs - 1) * - sizeof(struct virtchnl2_txq_info); - vc_txqs = rte_zmalloc("cfg_txqs", size, 0); - if (vc_txqs == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_tx_queues"); - err = -ENOMEM; - break; - } - vc_txqs->vport_id = vport->vport_id; - vc_txqs->num_qinfo = num_qs; - if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) { - for (i = 0; i < num_qs; i++, k++) { - txq_info = &vc_txqs->qinfo[i]; - txq_info->dma_ring_addr = txq[k]->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX; - txq_info->queue_id = txq[k]->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_QUEUE; - txq_info->ring_len = txq[k]->nb_tx_desc; - } - } else { - for (i = 0; i < num_qs / 2; i++, k++) { - /* txq info */ - txq_info = &vc_txqs->qinfo[2 * i]; - txq_info->dma_ring_addr = txq[k]->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX; - txq_info->queue_id = txq[k]->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_FLOW; - txq_info->ring_len = txq[k]->nb_tx_desc; - txq_info->tx_compl_queue_id = - txq[k]->complq->queue_id; - txq_info->relative_queue_id = txq_info->queue_id; - - /* tx completion queue info */ - txq_info = &vc_txqs->qinfo[2 * i + 1]; - txq_info->dma_ring_addr = - txq[k]->complq->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION; - txq_info->queue_id = txq[k]->complq->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_FLOW; - txq_info->ring_len = txq[k]->complq->nb_tx_desc; - } - } - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_CONFIG_TX_QUEUES; - args.in_args = (uint8_t *)vc_txqs; - args.in_args_size = size; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - rte_free(vc_txqs); - if (err != 0) { - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES"); - break; - } - } - - return err; -} - -int -idpf_vc_config_txq(struct idpf_vport *vport, uint16_t txq_id) -{ - struct idpf_adapter *adapter = vport->adapter; - struct idpf_tx_queue **txq = - (struct idpf_tx_queue **)vport->dev_data->tx_queues; - struct virtchnl2_config_tx_queues *vc_txqs = NULL; - struct virtchnl2_txq_info *txq_info; - struct idpf_cmd_info args; - uint16_t num_qs; - int size, err; - - if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) - num_qs = IDPF_TXQ_PER_GRP; - else - num_qs = IDPF_TXQ_PER_GRP + IDPF_TX_COMPLQ_PER_GRP; - - size = sizeof(*vc_txqs) + (num_qs - 1) * - sizeof(struct virtchnl2_txq_info); - vc_txqs = rte_zmalloc("cfg_txqs", size, 0); - if (vc_txqs == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate virtchnl2_config_tx_queues"); - err = -ENOMEM; - return err; - } - vc_txqs->vport_id = vport->vport_id; - vc_txqs->num_qinfo = num_qs; - - if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) { - txq_info = &vc_txqs->qinfo[0]; - txq_info->dma_ring_addr = txq[txq_id]->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX; - txq_info->queue_id = txq[txq_id]->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SINGLE; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_QUEUE; - txq_info->ring_len = txq[txq_id]->nb_tx_desc; - } else { - /* txq info */ - txq_info = &vc_txqs->qinfo[0]; - txq_info->dma_ring_addr = txq[txq_id]->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX; - txq_info->queue_id = txq[txq_id]->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_FLOW; - txq_info->ring_len = txq[txq_id]->nb_tx_desc; - txq_info->tx_compl_queue_id = txq[txq_id]->complq->queue_id; - txq_info->relative_queue_id = txq_info->queue_id; - - /* tx completion queue info */ - txq_info = &vc_txqs->qinfo[1]; - txq_info->dma_ring_addr = txq[txq_id]->complq->tx_ring_phys_addr; - txq_info->type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION; - txq_info->queue_id = txq[txq_id]->complq->queue_id; - txq_info->model = VIRTCHNL2_QUEUE_MODEL_SPLIT; - txq_info->sched_mode = VIRTCHNL2_TXQ_SCHED_MODE_FLOW; - txq_info->ring_len = txq[txq_id]->complq->nb_tx_desc; - } - - memset(&args, 0, sizeof(args)); - args.ops = VIRTCHNL2_OP_CONFIG_TX_QUEUES; - args.in_args = (uint8_t *)vc_txqs; - args.in_args_size = size; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - rte_free(vc_txqs); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES"); - - return err; -} - -int -idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, bool map) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_queue_vector_maps *map_info; - struct virtchnl2_queue_vector *vecmap; - uint16_t nb_rxq = vport->dev_data->nb_rx_queues; - struct idpf_cmd_info args; - int len, i, err = 0; - - len = sizeof(struct virtchnl2_queue_vector_maps) + - (nb_rxq - 1) * sizeof(struct virtchnl2_queue_vector); - - map_info = rte_zmalloc("map_info", len, 0); - if (map_info == NULL) - return -ENOMEM; - - map_info->vport_id = vport->vport_id; - map_info->num_qv_maps = nb_rxq; - for (i = 0; i < nb_rxq; i++) { - vecmap = &map_info->qv_maps[i]; - vecmap->queue_id = vport->qv_map[i].queue_id; - vecmap->vector_id = vport->qv_map[i].vector_id; - vecmap->itr_idx = VIRTCHNL2_ITR_IDX_0; - vecmap->queue_type = VIRTCHNL2_QUEUE_TYPE_RX; - } - - args.ops = map ? VIRTCHNL2_OP_MAP_QUEUE_VECTOR : - VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR; - args.in_args = (u8 *)map_info; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_%s_QUEUE_VECTOR", - map ? "MAP" : "UNMAP"); - - rte_free(map_info); - return err; -} - -int -idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_alloc_vectors *alloc_vec; - struct idpf_cmd_info args; - int err, len; - - len = sizeof(struct virtchnl2_alloc_vectors) + - (num_vectors - 1) * sizeof(struct virtchnl2_vector_chunk); - alloc_vec = rte_zmalloc("alloc_vec", len, 0); - if (alloc_vec == NULL) - return -ENOMEM; - - alloc_vec->num_vectors = num_vectors; - - args.ops = VIRTCHNL2_OP_ALLOC_VECTORS; - args.in_args = (u8 *)alloc_vec; - args.in_args_size = sizeof(struct virtchnl2_alloc_vectors); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL2_OP_ALLOC_VECTORS"); - - if (vport->recv_vectors == NULL) { - vport->recv_vectors = rte_zmalloc("recv_vectors", len, 0); - if (vport->recv_vectors == NULL) { - rte_free(alloc_vec); - return -ENOMEM; - } - } - - rte_memcpy(vport->recv_vectors, args.out_buffer, len); - rte_free(alloc_vec); - return err; -} - -int -idpf_vc_dealloc_vectors(struct idpf_vport *vport) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_alloc_vectors *alloc_vec; - struct virtchnl2_vector_chunks *vcs; - struct idpf_cmd_info args; - int err, len; - - alloc_vec = vport->recv_vectors; - vcs = &alloc_vec->vchunks; - - len = sizeof(struct virtchnl2_vector_chunks) + - (vcs->num_vchunks - 1) * sizeof(struct virtchnl2_vector_chunk); - - args.ops = VIRTCHNL2_OP_DEALLOC_VECTORS; - args.in_args = (u8 *)vcs; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL2_OP_DEALLOC_VECTORS"); - - return err; -} - -static int -idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, - uint32_t type, bool on) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_del_ena_dis_queues *queue_select; - struct virtchnl2_queue_chunk *queue_chunk; - struct idpf_cmd_info args; - int err, len; - - len = sizeof(struct virtchnl2_del_ena_dis_queues); - queue_select = rte_zmalloc("queue_select", len, 0); - if (queue_select == NULL) - return -ENOMEM; - - queue_chunk = queue_select->chunks.chunks; - queue_select->chunks.num_chunks = 1; - queue_select->vport_id = vport->vport_id; - - queue_chunk->type = type; - queue_chunk->start_queue_id = qid; - queue_chunk->num_queues = 1; - - args.ops = on ? VIRTCHNL2_OP_ENABLE_QUEUES : - VIRTCHNL2_OP_DISABLE_QUEUES; - args.in_args = (u8 *)queue_select; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_%s_QUEUES", - on ? "ENABLE" : "DISABLE"); - - rte_free(queue_select); - return err; -} - -int -idpf_switch_queue(struct idpf_vport *vport, uint16_t qid, - bool rx, bool on) -{ - uint32_t type; - int err, queue_id; - - /* switch txq/rxq */ - type = rx ? VIRTCHNL2_QUEUE_TYPE_RX : VIRTCHNL2_QUEUE_TYPE_TX; - - if (type == VIRTCHNL2_QUEUE_TYPE_RX) - queue_id = vport->chunks_info.rx_start_qid + qid; - else - queue_id = vport->chunks_info.tx_start_qid + qid; - err = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on); - if (err != 0) - return err; - - /* switch tx completion queue */ - if (!rx && vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) { - type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION; - queue_id = vport->chunks_info.tx_compl_start_qid + qid; - err = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on); - if (err != 0) - return err; - } - - /* switch rx buffer queue */ - if (rx && vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) { - type = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER; - queue_id = vport->chunks_info.rx_buf_start_qid + 2 * qid; - err = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on); - if (err != 0) - return err; - queue_id++; - err = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on); - if (err != 0) - return err; - } - - return err; -} - -#define IDPF_RXTX_QUEUE_CHUNKS_NUM 2 -int -idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_del_ena_dis_queues *queue_select; - struct virtchnl2_queue_chunk *queue_chunk; - uint32_t type; - struct idpf_cmd_info args; - uint16_t num_chunks; - int err, len; - - num_chunks = IDPF_RXTX_QUEUE_CHUNKS_NUM; - if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) - num_chunks++; - if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) - num_chunks++; - - len = sizeof(struct virtchnl2_del_ena_dis_queues) + - sizeof(struct virtchnl2_queue_chunk) * (num_chunks - 1); - queue_select = rte_zmalloc("queue_select", len, 0); - if (queue_select == NULL) - return -ENOMEM; - - queue_chunk = queue_select->chunks.chunks; - queue_select->chunks.num_chunks = num_chunks; - queue_select->vport_id = vport->vport_id; - - type = VIRTCHNL_QUEUE_TYPE_RX; - queue_chunk[type].type = type; - queue_chunk[type].start_queue_id = vport->chunks_info.rx_start_qid; - queue_chunk[type].num_queues = vport->num_rx_q; - - type = VIRTCHNL2_QUEUE_TYPE_TX; - queue_chunk[type].type = type; - queue_chunk[type].start_queue_id = vport->chunks_info.tx_start_qid; - queue_chunk[type].num_queues = vport->num_tx_q; - - if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) { - type = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER; - queue_chunk[type].type = type; - queue_chunk[type].start_queue_id = - vport->chunks_info.rx_buf_start_qid; - queue_chunk[type].num_queues = vport->num_rx_bufq; - } - - if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) { - type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION; - queue_chunk[type].type = type; - queue_chunk[type].start_queue_id = - vport->chunks_info.tx_compl_start_qid; - queue_chunk[type].num_queues = vport->num_tx_complq; - } - - args.ops = enable ? VIRTCHNL2_OP_ENABLE_QUEUES : - VIRTCHNL2_OP_DISABLE_QUEUES; - args.in_args = (u8 *)queue_select; - args.in_args_size = len; - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_%s_QUEUES", - enable ? "ENABLE" : "DISABLE"); - - rte_free(queue_select); - return err; -} - -int -idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable) -{ - struct idpf_adapter *adapter = vport->adapter; - struct virtchnl2_vport vc_vport; - struct idpf_cmd_info args; - int err; - - vc_vport.vport_id = vport->vport_id; - args.ops = enable ? VIRTCHNL2_OP_ENABLE_VPORT : - VIRTCHNL2_OP_DISABLE_VPORT; - args.in_args = (uint8_t *)&vc_vport; - args.in_args_size = sizeof(vc_vport); - args.out_buffer = adapter->mbx_resp; - args.out_size = IDPF_DFLT_MBX_BUF_SIZE; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) { - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_%s_VPORT", - enable ? "ENABLE" : "DISABLE"); - } - - return err; -} - -int -idpf_vc_query_ptype_info(struct idpf_adapter *adapter) -{ - struct virtchnl2_get_ptype_info *ptype_info; - struct idpf_cmd_info args; - int len, err; - - len = sizeof(struct virtchnl2_get_ptype_info); - ptype_info = rte_zmalloc("ptype_info", len, 0); - if (ptype_info == NULL) - return -ENOMEM; - - ptype_info->start_ptype_id = 0; - ptype_info->num_ptypes = IDPF_MAX_PKT_TYPE; - args.ops = VIRTCHNL2_OP_GET_PTYPE_INFO; - args.in_args = (u8 *)ptype_info; - args.in_args_size = len; - - err = idpf_execute_vc_cmd(adapter, &args); - if (err != 0) - PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL2_OP_GET_PTYPE_INFO"); - - rte_free(ptype_info); - return err; -} diff --git a/dpdk/drivers/net/kni/meson.build b/dpdk/drivers/net/kni/meson.build deleted file mode 100644 index 2acc98969..000000000 --- a/dpdk/drivers/net/kni/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2018 Intel Corporation - -if is_windows - build = false - reason = 'not supported on Windows' - subdir_done() -endif - -deps += 'kni' -sources = files('rte_eth_kni.c') diff --git a/dpdk/drivers/net/kni/rte_eth_kni.c b/dpdk/drivers/net/kni/rte_eth_kni.c deleted file mode 100644 index c0e1f8db4..000000000 --- a/dpdk/drivers/net/kni/rte_eth_kni.c +++ /dev/null @@ -1,524 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/* Only single queue supported */ -#define KNI_MAX_QUEUE_PER_PORT 1 - -#define MAX_KNI_PORTS 8 - -#define KNI_ETHER_MTU(mbuf_size) \ - ((mbuf_size) - RTE_ETHER_HDR_LEN) /**< Ethernet MTU. */ - -#define ETH_KNI_NO_REQUEST_THREAD_ARG "no_request_thread" -static const char * const valid_arguments[] = { - ETH_KNI_NO_REQUEST_THREAD_ARG, - NULL -}; - -struct eth_kni_args { - int no_request_thread; -}; - -struct pmd_queue_stats { - uint64_t pkts; - uint64_t bytes; -}; - -struct pmd_queue { - struct pmd_internals *internals; - struct rte_mempool *mb_pool; - - struct pmd_queue_stats rx; - struct pmd_queue_stats tx; -}; - -struct pmd_internals { - struct rte_kni *kni; - uint16_t port_id; - int is_kni_started; - - pthread_t thread; - int stop_thread; - int no_request_thread; - - struct rte_ether_addr eth_addr; - - struct pmd_queue rx_queues[KNI_MAX_QUEUE_PER_PORT]; - struct pmd_queue tx_queues[KNI_MAX_QUEUE_PER_PORT]; -}; - -static const struct rte_eth_link pmd_link = { - .link_speed = RTE_ETH_SPEED_NUM_10G, - .link_duplex = RTE_ETH_LINK_FULL_DUPLEX, - .link_status = RTE_ETH_LINK_DOWN, - .link_autoneg = RTE_ETH_LINK_FIXED, -}; -static int is_kni_initialized; - -RTE_LOG_REGISTER_DEFAULT(eth_kni_logtype, NOTICE); - -#define PMD_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, eth_kni_logtype, \ - "%s(): " fmt "\n", __func__, ##args) -static uint16_t -eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) -{ - struct pmd_queue *kni_q = q; - struct rte_kni *kni = kni_q->internals->kni; - uint16_t nb_pkts; - int i; - - nb_pkts = rte_kni_rx_burst(kni, bufs, nb_bufs); - for (i = 0; i < nb_pkts; i++) - bufs[i]->port = kni_q->internals->port_id; - - kni_q->rx.pkts += nb_pkts; - - return nb_pkts; -} - -static uint16_t -eth_kni_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) -{ - struct pmd_queue *kni_q = q; - struct rte_kni *kni = kni_q->internals->kni; - uint16_t nb_pkts; - - nb_pkts = rte_kni_tx_burst(kni, bufs, nb_bufs); - - kni_q->tx.pkts += nb_pkts; - - return nb_pkts; -} - -static void * -kni_handle_request(void *param) -{ - struct pmd_internals *internals = param; -#define MS 1000 - - while (!internals->stop_thread) { - rte_kni_handle_request(internals->kni); - usleep(500 * MS); - } - - return param; -} - -static int -eth_kni_start(struct rte_eth_dev *dev) -{ - struct pmd_internals *internals = dev->data->dev_private; - uint16_t port_id = dev->data->port_id; - struct rte_mempool *mb_pool; - struct rte_kni_conf conf = {{0}}; - const char *name = dev->device->name + 4; /* remove net_ */ - - mb_pool = internals->rx_queues[0].mb_pool; - strlcpy(conf.name, name, RTE_KNI_NAMESIZE); - conf.force_bind = 0; - conf.group_id = port_id; - conf.mbuf_size = - rte_pktmbuf_data_room_size(mb_pool) - RTE_PKTMBUF_HEADROOM; - conf.mtu = KNI_ETHER_MTU(conf.mbuf_size); - - internals->kni = rte_kni_alloc(mb_pool, &conf, NULL); - if (internals->kni == NULL) { - PMD_LOG(ERR, - "Fail to create kni interface for port: %d", - port_id); - return -1; - } - - return 0; -} - -static int -eth_kni_dev_start(struct rte_eth_dev *dev) -{ - struct pmd_internals *internals = dev->data->dev_private; - int ret; - - if (internals->is_kni_started == 0) { - ret = eth_kni_start(dev); - if (ret) - return -1; - internals->is_kni_started = 1; - } - - if (internals->no_request_thread == 0) { - internals->stop_thread = 0; - - ret = rte_ctrl_thread_create(&internals->thread, - "kni_handle_req", NULL, - kni_handle_request, internals); - if (ret) { - PMD_LOG(ERR, - "Fail to create kni request thread"); - return -1; - } - } - - dev->data->dev_link.link_status = 1; - - return 0; -} - -static int -eth_kni_dev_stop(struct rte_eth_dev *dev) -{ - struct pmd_internals *internals = dev->data->dev_private; - int ret; - - if (internals->no_request_thread == 0 && internals->stop_thread == 0) { - internals->stop_thread = 1; - - ret = pthread_cancel(internals->thread); - if (ret) - PMD_LOG(ERR, "Can't cancel the thread"); - - ret = pthread_join(internals->thread, NULL); - if (ret) - PMD_LOG(ERR, "Can't join the thread"); - } - - dev->data->dev_link.link_status = 0; - dev->data->dev_started = 0; - - return 0; -} - -static int -eth_kni_close(struct rte_eth_dev *eth_dev) -{ - struct pmd_internals *internals; - int ret; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - ret = eth_kni_dev_stop(eth_dev); - if (ret) - PMD_LOG(WARNING, "Not able to stop kni for %s", - eth_dev->data->name); - - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; - - internals = eth_dev->data->dev_private; - ret = rte_kni_release(internals->kni); - if (ret) - PMD_LOG(WARNING, "Not able to release kni for %s", - eth_dev->data->name); - - return ret; -} - -static int -eth_kni_dev_configure(struct rte_eth_dev *dev __rte_unused) -{ - return 0; -} - -static int -eth_kni_dev_info(struct rte_eth_dev *dev __rte_unused, - struct rte_eth_dev_info *dev_info) -{ - dev_info->max_mac_addrs = 1; - dev_info->max_rx_pktlen = UINT32_MAX; - dev_info->max_rx_queues = KNI_MAX_QUEUE_PER_PORT; - dev_info->max_tx_queues = KNI_MAX_QUEUE_PER_PORT; - dev_info->min_rx_bufsize = 0; - - return 0; -} - -static int -eth_kni_rx_queue_setup(struct rte_eth_dev *dev, - uint16_t rx_queue_id, - uint16_t nb_rx_desc __rte_unused, - unsigned int socket_id __rte_unused, - const struct rte_eth_rxconf *rx_conf __rte_unused, - struct rte_mempool *mb_pool) -{ - struct pmd_internals *internals = dev->data->dev_private; - struct pmd_queue *q; - - q = &internals->rx_queues[rx_queue_id]; - q->internals = internals; - q->mb_pool = mb_pool; - - dev->data->rx_queues[rx_queue_id] = q; - - return 0; -} - -static int -eth_kni_tx_queue_setup(struct rte_eth_dev *dev, - uint16_t tx_queue_id, - uint16_t nb_tx_desc __rte_unused, - unsigned int socket_id __rte_unused, - const struct rte_eth_txconf *tx_conf __rte_unused) -{ - struct pmd_internals *internals = dev->data->dev_private; - struct pmd_queue *q; - - q = &internals->tx_queues[tx_queue_id]; - q->internals = internals; - - dev->data->tx_queues[tx_queue_id] = q; - - return 0; -} - -static int -eth_kni_link_update(struct rte_eth_dev *dev __rte_unused, - int wait_to_complete __rte_unused) -{ - return 0; -} - -static int -eth_kni_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) -{ - unsigned long rx_packets_total = 0, rx_bytes_total = 0; - unsigned long tx_packets_total = 0, tx_bytes_total = 0; - struct rte_eth_dev_data *data = dev->data; - unsigned int i, num_stats; - struct pmd_queue *q; - - num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS, - data->nb_rx_queues); - for (i = 0; i < num_stats; i++) { - q = data->rx_queues[i]; - stats->q_ipackets[i] = q->rx.pkts; - stats->q_ibytes[i] = q->rx.bytes; - rx_packets_total += stats->q_ipackets[i]; - rx_bytes_total += stats->q_ibytes[i]; - } - - num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS, - data->nb_tx_queues); - for (i = 0; i < num_stats; i++) { - q = data->tx_queues[i]; - stats->q_opackets[i] = q->tx.pkts; - stats->q_obytes[i] = q->tx.bytes; - tx_packets_total += stats->q_opackets[i]; - tx_bytes_total += stats->q_obytes[i]; - } - - stats->ipackets = rx_packets_total; - stats->ibytes = rx_bytes_total; - stats->opackets = tx_packets_total; - stats->obytes = tx_bytes_total; - - return 0; -} - -static int -eth_kni_stats_reset(struct rte_eth_dev *dev) -{ - struct rte_eth_dev_data *data = dev->data; - struct pmd_queue *q; - unsigned int i; - - for (i = 0; i < data->nb_rx_queues; i++) { - q = data->rx_queues[i]; - q->rx.pkts = 0; - q->rx.bytes = 0; - } - for (i = 0; i < data->nb_tx_queues; i++) { - q = data->tx_queues[i]; - q->tx.pkts = 0; - q->tx.bytes = 0; - } - - return 0; -} - -static const struct eth_dev_ops eth_kni_ops = { - .dev_start = eth_kni_dev_start, - .dev_stop = eth_kni_dev_stop, - .dev_close = eth_kni_close, - .dev_configure = eth_kni_dev_configure, - .dev_infos_get = eth_kni_dev_info, - .rx_queue_setup = eth_kni_rx_queue_setup, - .tx_queue_setup = eth_kni_tx_queue_setup, - .link_update = eth_kni_link_update, - .stats_get = eth_kni_stats_get, - .stats_reset = eth_kni_stats_reset, -}; - -static struct rte_eth_dev * -eth_kni_create(struct rte_vdev_device *vdev, - struct eth_kni_args *args, - unsigned int numa_node) -{ - struct pmd_internals *internals; - struct rte_eth_dev_data *data; - struct rte_eth_dev *eth_dev; - - PMD_LOG(INFO, "Creating kni ethdev on numa socket %u", - numa_node); - - /* reserve an ethdev entry */ - eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*internals)); - if (!eth_dev) - return NULL; - - internals = eth_dev->data->dev_private; - internals->port_id = eth_dev->data->port_id; - data = eth_dev->data; - data->nb_rx_queues = 1; - data->nb_tx_queues = 1; - data->dev_link = pmd_link; - data->mac_addrs = &internals->eth_addr; - data->promiscuous = 1; - data->all_multicast = 1; - data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - - rte_eth_random_addr(internals->eth_addr.addr_bytes); - - eth_dev->dev_ops = ð_kni_ops; - - internals->no_request_thread = args->no_request_thread; - - return eth_dev; -} - -static int -kni_init(void) -{ - int ret; - - if (is_kni_initialized == 0) { - ret = rte_kni_init(MAX_KNI_PORTS); - if (ret < 0) - return ret; - } - - is_kni_initialized++; - - return 0; -} - -static int -eth_kni_kvargs_process(struct eth_kni_args *args, const char *params) -{ - struct rte_kvargs *kvlist; - - kvlist = rte_kvargs_parse(params, valid_arguments); - if (kvlist == NULL) - return -1; - - memset(args, 0, sizeof(struct eth_kni_args)); - - if (rte_kvargs_count(kvlist, ETH_KNI_NO_REQUEST_THREAD_ARG) == 1) - args->no_request_thread = 1; - - rte_kvargs_free(kvlist); - - return 0; -} - -static int -eth_kni_probe(struct rte_vdev_device *vdev) -{ - struct rte_eth_dev *eth_dev; - struct eth_kni_args args; - const char *name; - const char *params; - int ret; - - name = rte_vdev_device_name(vdev); - params = rte_vdev_device_args(vdev); - PMD_LOG(INFO, "Initializing eth_kni for %s", name); - - if (rte_eal_process_type() == RTE_PROC_SECONDARY) { - eth_dev = rte_eth_dev_attach_secondary(name); - if (!eth_dev) { - PMD_LOG(ERR, "Failed to probe %s", name); - return -1; - } - /* TODO: request info from primary to set up Rx and Tx */ - eth_dev->dev_ops = ð_kni_ops; - eth_dev->device = &vdev->device; - rte_eth_dev_probing_finish(eth_dev); - return 0; - } - - ret = eth_kni_kvargs_process(&args, params); - if (ret < 0) - return ret; - - ret = kni_init(); - if (ret < 0) - return ret; - - eth_dev = eth_kni_create(vdev, &args, rte_socket_id()); - if (eth_dev == NULL) - goto kni_uninit; - - eth_dev->rx_pkt_burst = eth_kni_rx; - eth_dev->tx_pkt_burst = eth_kni_tx; - - rte_eth_dev_probing_finish(eth_dev); - return 0; - -kni_uninit: - is_kni_initialized--; - if (is_kni_initialized == 0) - rte_kni_close(); - return -1; -} - -static int -eth_kni_remove(struct rte_vdev_device *vdev) -{ - struct rte_eth_dev *eth_dev; - const char *name; - int ret; - - name = rte_vdev_device_name(vdev); - PMD_LOG(INFO, "Un-Initializing eth_kni for %s", name); - - /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); - if (eth_dev != NULL) { - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - ret = eth_kni_dev_stop(eth_dev); - if (ret != 0) - return ret; - return rte_eth_dev_release_port(eth_dev); - } - eth_kni_close(eth_dev); - rte_eth_dev_release_port(eth_dev); - } - - is_kni_initialized--; - if (is_kni_initialized == 0) - rte_kni_close(); - - return 0; -} - -static struct rte_vdev_driver eth_kni_drv = { - .probe = eth_kni_probe, - .remove = eth_kni_remove, -}; - -RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv); -RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "="); diff --git a/dpdk/drivers/net/liquidio/base/lio_23xx_reg.h b/dpdk/drivers/net/liquidio/base/lio_23xx_reg.h deleted file mode 100644 index 9f28504b5..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_23xx_reg.h +++ /dev/null @@ -1,165 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_23XX_REG_H_ -#define _LIO_23XX_REG_H_ - -/* ###################### REQUEST QUEUE ######################### */ - -/* 64 registers for Input Queues Start Addr - SLI_PKT(0..63)_INSTR_BADDR */ -#define CN23XX_SLI_PKT_INSTR_BADDR_START64 0x10010 - -/* 64 registers for Input Doorbell - SLI_PKT(0..63)_INSTR_BAOFF_DBELL */ -#define CN23XX_SLI_PKT_INSTR_BADDR_DBELL_START 0x10020 - -/* 64 registers for Input Queue size - SLI_PKT(0..63)_INSTR_FIFO_RSIZE */ -#define CN23XX_SLI_PKT_INSTR_FIFO_RSIZE_START 0x10030 - -/* 64 registers for Input Queue Instr Count - SLI_PKT_IN_DONE(0..63)_CNTS */ -#define CN23XX_SLI_PKT_IN_DONE_CNTS_START64 0x10040 - -/* 64 registers (64-bit) - ES, RO, NS, Arbitration for Input Queue Data & - * gather list fetches. SLI_PKT(0..63)_INPUT_CONTROL. - */ -#define CN23XX_SLI_PKT_INPUT_CONTROL_START64 0x10000 - -/* ------- Request Queue Macros --------- */ - -/* Each Input Queue register is at a 16-byte Offset in BAR0 */ -#define CN23XX_IQ_OFFSET 0x20000 - -#define CN23XX_SLI_IQ_PKT_CONTROL64(iq) \ - (CN23XX_SLI_PKT_INPUT_CONTROL_START64 + ((iq) * CN23XX_IQ_OFFSET)) - -#define CN23XX_SLI_IQ_BASE_ADDR64(iq) \ - (CN23XX_SLI_PKT_INSTR_BADDR_START64 + ((iq) * CN23XX_IQ_OFFSET)) - -#define CN23XX_SLI_IQ_SIZE(iq) \ - (CN23XX_SLI_PKT_INSTR_FIFO_RSIZE_START + ((iq) * CN23XX_IQ_OFFSET)) - -#define CN23XX_SLI_IQ_DOORBELL(iq) \ - (CN23XX_SLI_PKT_INSTR_BADDR_DBELL_START + ((iq) * CN23XX_IQ_OFFSET)) - -#define CN23XX_SLI_IQ_INSTR_COUNT64(iq) \ - (CN23XX_SLI_PKT_IN_DONE_CNTS_START64 + ((iq) * CN23XX_IQ_OFFSET)) - -/* Number of instructions to be read in one MAC read request. - * setting to Max value(4) - */ -#define CN23XX_PKT_INPUT_CTL_RDSIZE (3 << 25) -#define CN23XX_PKT_INPUT_CTL_IS_64B (1 << 24) -#define CN23XX_PKT_INPUT_CTL_RST (1 << 23) -#define CN23XX_PKT_INPUT_CTL_QUIET (1 << 28) -#define CN23XX_PKT_INPUT_CTL_RING_ENB (1 << 22) -#define CN23XX_PKT_INPUT_CTL_DATA_ES_64B_SWAP (1 << 6) -#define CN23XX_PKT_INPUT_CTL_USE_CSR (1 << 4) -#define CN23XX_PKT_INPUT_CTL_GATHER_ES_64B_SWAP (2) - -/* These bits[47:44] select the Physical function number within the MAC */ -#define CN23XX_PKT_INPUT_CTL_PF_NUM_POS 45 -/* These bits[43:32] select the function number within the PF */ -#define CN23XX_PKT_INPUT_CTL_VF_NUM_POS 32 - -#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN -#define CN23XX_PKT_INPUT_CTL_MASK \ - (CN23XX_PKT_INPUT_CTL_RDSIZE | \ - CN23XX_PKT_INPUT_CTL_DATA_ES_64B_SWAP | \ - CN23XX_PKT_INPUT_CTL_USE_CSR) -#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN -#define CN23XX_PKT_INPUT_CTL_MASK \ - (CN23XX_PKT_INPUT_CTL_RDSIZE | \ - CN23XX_PKT_INPUT_CTL_DATA_ES_64B_SWAP | \ - CN23XX_PKT_INPUT_CTL_USE_CSR | \ - CN23XX_PKT_INPUT_CTL_GATHER_ES_64B_SWAP) -#endif - -/* ############################ OUTPUT QUEUE ######################### */ - -/* 64 registers for Output queue control - SLI_PKT(0..63)_OUTPUT_CONTROL */ -#define CN23XX_SLI_PKT_OUTPUT_CONTROL_START 0x10050 - -/* 64 registers for Output queue buffer and info size - * SLI_PKT(0..63)_OUT_SIZE - */ -#define CN23XX_SLI_PKT_OUT_SIZE 0x10060 - -/* 64 registers for Output Queue Start Addr - SLI_PKT(0..63)_SLIST_BADDR */ -#define CN23XX_SLI_SLIST_BADDR_START64 0x10070 - -/* 64 registers for Output Queue Packet Credits - * SLI_PKT(0..63)_SLIST_BAOFF_DBELL - */ -#define CN23XX_SLI_PKT_SLIST_BAOFF_DBELL_START 0x10080 - -/* 64 registers for Output Queue size - SLI_PKT(0..63)_SLIST_FIFO_RSIZE */ -#define CN23XX_SLI_PKT_SLIST_FIFO_RSIZE_START 0x10090 - -/* 64 registers for Output Queue Packet Count - SLI_PKT(0..63)_CNTS */ -#define CN23XX_SLI_PKT_CNTS_START 0x100B0 - -/* Each Output Queue register is at a 16-byte Offset in BAR0 */ -#define CN23XX_OQ_OFFSET 0x20000 - -/* ------- Output Queue Macros --------- */ - -#define CN23XX_SLI_OQ_PKT_CONTROL(oq) \ - (CN23XX_SLI_PKT_OUTPUT_CONTROL_START + ((oq) * CN23XX_OQ_OFFSET)) - -#define CN23XX_SLI_OQ_BASE_ADDR64(oq) \ - (CN23XX_SLI_SLIST_BADDR_START64 + ((oq) * CN23XX_OQ_OFFSET)) - -#define CN23XX_SLI_OQ_SIZE(oq) \ - (CN23XX_SLI_PKT_SLIST_FIFO_RSIZE_START + ((oq) * CN23XX_OQ_OFFSET)) - -#define CN23XX_SLI_OQ_BUFF_INFO_SIZE(oq) \ - (CN23XX_SLI_PKT_OUT_SIZE + ((oq) * CN23XX_OQ_OFFSET)) - -#define CN23XX_SLI_OQ_PKTS_SENT(oq) \ - (CN23XX_SLI_PKT_CNTS_START + ((oq) * CN23XX_OQ_OFFSET)) - -#define CN23XX_SLI_OQ_PKTS_CREDIT(oq) \ - (CN23XX_SLI_PKT_SLIST_BAOFF_DBELL_START + ((oq) * CN23XX_OQ_OFFSET)) - -/* ------------------ Masks ---------------- */ -#define CN23XX_PKT_OUTPUT_CTL_IPTR (1 << 11) -#define CN23XX_PKT_OUTPUT_CTL_ES (1 << 9) -#define CN23XX_PKT_OUTPUT_CTL_NSR (1 << 8) -#define CN23XX_PKT_OUTPUT_CTL_ROR (1 << 7) -#define CN23XX_PKT_OUTPUT_CTL_DPTR (1 << 6) -#define CN23XX_PKT_OUTPUT_CTL_BMODE (1 << 5) -#define CN23XX_PKT_OUTPUT_CTL_ES_P (1 << 3) -#define CN23XX_PKT_OUTPUT_CTL_NSR_P (1 << 2) -#define CN23XX_PKT_OUTPUT_CTL_ROR_P (1 << 1) -#define CN23XX_PKT_OUTPUT_CTL_RING_ENB (1 << 0) - -/* Rings per Virtual Function [RO] */ -#define CN23XX_PKT_INPUT_CTL_RPVF_MASK 0x3F -#define CN23XX_PKT_INPUT_CTL_RPVF_POS 48 - -/* These bits[47:44][RO] give the Physical function - * number info within the MAC - */ -#define CN23XX_PKT_INPUT_CTL_PF_NUM_MASK 0x7 - -/* These bits[43:32][RO] give the virtual function - * number info within the PF - */ -#define CN23XX_PKT_INPUT_CTL_VF_NUM_MASK 0x1FFF - -/* ######################### Mailbox Reg Macros ######################## */ -#define CN23XX_SLI_PKT_PF_VF_MBOX_SIG_START 0x10200 -#define CN23XX_VF_SLI_PKT_MBOX_INT_START 0x10210 - -#define CN23XX_SLI_MBOX_OFFSET 0x20000 -#define CN23XX_SLI_MBOX_SIG_IDX_OFFSET 0x8 - -#define CN23XX_SLI_PKT_PF_VF_MBOX_SIG(q, idx) \ - (CN23XX_SLI_PKT_PF_VF_MBOX_SIG_START + \ - ((q) * CN23XX_SLI_MBOX_OFFSET + \ - (idx) * CN23XX_SLI_MBOX_SIG_IDX_OFFSET)) - -#define CN23XX_VF_SLI_PKT_MBOX_INT(q) \ - (CN23XX_VF_SLI_PKT_MBOX_INT_START + ((q) * CN23XX_SLI_MBOX_OFFSET)) - -#endif /* _LIO_23XX_REG_H_ */ diff --git a/dpdk/drivers/net/liquidio/base/lio_23xx_vf.c b/dpdk/drivers/net/liquidio/base/lio_23xx_vf.c deleted file mode 100644 index c6b8310b7..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_23xx_vf.c +++ /dev/null @@ -1,513 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#include - -#include -#include -#include - -#include "lio_logs.h" -#include "lio_23xx_vf.h" -#include "lio_23xx_reg.h" -#include "lio_mbox.h" - -static int -cn23xx_vf_reset_io_queues(struct lio_device *lio_dev, uint32_t num_queues) -{ - uint32_t loop = CN23XX_VF_BUSY_READING_REG_LOOP_COUNT; - uint64_t d64, q_no; - int ret_val = 0; - - PMD_INIT_FUNC_TRACE(); - - for (q_no = 0; q_no < num_queues; q_no++) { - /* set RST bit to 1. This bit applies to both IQ and OQ */ - d64 = lio_read_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - d64 = d64 | CN23XX_PKT_INPUT_CTL_RST; - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - d64); - } - - /* wait until the RST bit is clear or the RST and QUIET bits are set */ - for (q_no = 0; q_no < num_queues; q_no++) { - volatile uint64_t reg_val; - - reg_val = lio_read_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - while ((reg_val & CN23XX_PKT_INPUT_CTL_RST) && - !(reg_val & CN23XX_PKT_INPUT_CTL_QUIET) && - loop) { - reg_val = lio_read_csr64( - lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - loop = loop - 1; - } - - if (loop == 0) { - lio_dev_err(lio_dev, - "clearing the reset reg failed or setting the quiet reg failed for qno: %lu\n", - (unsigned long)q_no); - return -1; - } - - reg_val = reg_val & ~CN23XX_PKT_INPUT_CTL_RST; - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - reg_val); - - reg_val = lio_read_csr64( - lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - if (reg_val & CN23XX_PKT_INPUT_CTL_RST) { - lio_dev_err(lio_dev, - "clearing the reset failed for qno: %lu\n", - (unsigned long)q_no); - ret_val = -1; - } - } - - return ret_val; -} - -static int -cn23xx_vf_setup_global_input_regs(struct lio_device *lio_dev) -{ - uint64_t q_no; - uint64_t d64; - - PMD_INIT_FUNC_TRACE(); - - if (cn23xx_vf_reset_io_queues(lio_dev, - lio_dev->sriov_info.rings_per_vf)) - return -1; - - for (q_no = 0; q_no < (lio_dev->sriov_info.rings_per_vf); q_no++) { - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_DOORBELL(q_no), - 0xFFFFFFFF); - - d64 = lio_read_csr64(lio_dev, - CN23XX_SLI_IQ_INSTR_COUNT64(q_no)); - - d64 &= 0xEFFFFFFFFFFFFFFFL; - - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_INSTR_COUNT64(q_no), - d64); - - /* Select ES, RO, NS, RDSIZE,DPTR Fomat#0 for - * the Input Queues - */ - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - CN23XX_PKT_INPUT_CTL_MASK); - } - - return 0; -} - -static void -cn23xx_vf_setup_global_output_regs(struct lio_device *lio_dev) -{ - uint32_t reg_val; - uint32_t q_no; - - PMD_INIT_FUNC_TRACE(); - - for (q_no = 0; q_no < lio_dev->sriov_info.rings_per_vf; q_no++) { - lio_write_csr(lio_dev, CN23XX_SLI_OQ_PKTS_CREDIT(q_no), - 0xFFFFFFFF); - - reg_val = - lio_read_csr(lio_dev, CN23XX_SLI_OQ_PKTS_SENT(q_no)); - - reg_val &= 0xEFFFFFFFFFFFFFFFL; - - lio_write_csr(lio_dev, CN23XX_SLI_OQ_PKTS_SENT(q_no), reg_val); - - reg_val = - lio_read_csr(lio_dev, CN23XX_SLI_OQ_PKT_CONTROL(q_no)); - - /* set IPTR & DPTR */ - reg_val |= - (CN23XX_PKT_OUTPUT_CTL_IPTR | CN23XX_PKT_OUTPUT_CTL_DPTR); - - /* reset BMODE */ - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_BMODE); - - /* No Relaxed Ordering, No Snoop, 64-bit Byte swap - * for Output Queue Scatter List - * reset ROR_P, NSR_P - */ - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_ROR_P); - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_NSR_P); - -#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_ES_P); -#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN - reg_val |= (CN23XX_PKT_OUTPUT_CTL_ES_P); -#endif - /* No Relaxed Ordering, No Snoop, 64-bit Byte swap - * for Output Queue Data - * reset ROR, NSR - */ - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_ROR); - reg_val &= ~(CN23XX_PKT_OUTPUT_CTL_NSR); - /* set the ES bit */ - reg_val |= (CN23XX_PKT_OUTPUT_CTL_ES); - - /* write all the selected settings */ - lio_write_csr(lio_dev, CN23XX_SLI_OQ_PKT_CONTROL(q_no), - reg_val); - } -} - -static int -cn23xx_vf_setup_device_regs(struct lio_device *lio_dev) -{ - PMD_INIT_FUNC_TRACE(); - - if (cn23xx_vf_setup_global_input_regs(lio_dev)) - return -1; - - cn23xx_vf_setup_global_output_regs(lio_dev); - - return 0; -} - -static void -cn23xx_vf_setup_iq_regs(struct lio_device *lio_dev, uint32_t iq_no) -{ - struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; - uint64_t pkt_in_done = 0; - - PMD_INIT_FUNC_TRACE(); - - /* Write the start of the input queue's ring and its size */ - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_BASE_ADDR64(iq_no), - iq->base_addr_dma); - lio_write_csr(lio_dev, CN23XX_SLI_IQ_SIZE(iq_no), iq->nb_desc); - - /* Remember the doorbell & instruction count register addr - * for this queue - */ - iq->doorbell_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_IQ_DOORBELL(iq_no); - iq->inst_cnt_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_IQ_INSTR_COUNT64(iq_no); - lio_dev_dbg(lio_dev, "InstQ[%d]:dbell reg @ 0x%p instcnt_reg @ 0x%p\n", - iq_no, iq->doorbell_reg, iq->inst_cnt_reg); - - /* Store the current instruction counter (used in flush_iq - * calculation) - */ - pkt_in_done = rte_read64(iq->inst_cnt_reg); - - /* Clear the count by writing back what we read, but don't - * enable data traffic here - */ - rte_write64(pkt_in_done, iq->inst_cnt_reg); -} - -static void -cn23xx_vf_setup_oq_regs(struct lio_device *lio_dev, uint32_t oq_no) -{ - struct lio_droq *droq = lio_dev->droq[oq_no]; - - PMD_INIT_FUNC_TRACE(); - - lio_write_csr64(lio_dev, CN23XX_SLI_OQ_BASE_ADDR64(oq_no), - droq->desc_ring_dma); - lio_write_csr(lio_dev, CN23XX_SLI_OQ_SIZE(oq_no), droq->nb_desc); - - lio_write_csr(lio_dev, CN23XX_SLI_OQ_BUFF_INFO_SIZE(oq_no), - (droq->buffer_size | (OCTEON_RH_SIZE << 16))); - - /* Get the mapped address of the pkt_sent and pkts_credit regs */ - droq->pkts_sent_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_OQ_PKTS_SENT(oq_no); - droq->pkts_credit_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_OQ_PKTS_CREDIT(oq_no); -} - -static void -cn23xx_vf_free_mbox(struct lio_device *lio_dev) -{ - PMD_INIT_FUNC_TRACE(); - - rte_free(lio_dev->mbox[0]); - lio_dev->mbox[0] = NULL; - - rte_free(lio_dev->mbox); - lio_dev->mbox = NULL; -} - -static int -cn23xx_vf_setup_mbox(struct lio_device *lio_dev) -{ - struct lio_mbox *mbox; - - PMD_INIT_FUNC_TRACE(); - - if (lio_dev->mbox == NULL) { - lio_dev->mbox = rte_zmalloc(NULL, sizeof(void *), 0); - if (lio_dev->mbox == NULL) - return -ENOMEM; - } - - mbox = rte_zmalloc(NULL, sizeof(struct lio_mbox), 0); - if (mbox == NULL) { - rte_free(lio_dev->mbox); - lio_dev->mbox = NULL; - return -ENOMEM; - } - - rte_spinlock_init(&mbox->lock); - - mbox->lio_dev = lio_dev; - - mbox->q_no = 0; - - mbox->state = LIO_MBOX_STATE_IDLE; - - /* VF mbox interrupt reg */ - mbox->mbox_int_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_VF_SLI_PKT_MBOX_INT(0); - /* VF reads from SIG0 reg */ - mbox->mbox_read_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_PKT_PF_VF_MBOX_SIG(0, 0); - /* VF writes into SIG1 reg */ - mbox->mbox_write_reg = (uint8_t *)lio_dev->hw_addr + - CN23XX_SLI_PKT_PF_VF_MBOX_SIG(0, 1); - - lio_dev->mbox[0] = mbox; - - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - - return 0; -} - -static int -cn23xx_vf_enable_io_queues(struct lio_device *lio_dev) -{ - uint32_t q_no; - - PMD_INIT_FUNC_TRACE(); - - for (q_no = 0; q_no < lio_dev->num_iqs; q_no++) { - uint64_t reg_val; - - /* set the corresponding IQ IS_64B bit */ - if (lio_dev->io_qmask.iq64B & (1ULL << q_no)) { - reg_val = lio_read_csr64( - lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - reg_val = reg_val | CN23XX_PKT_INPUT_CTL_IS_64B; - lio_write_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - reg_val); - } - - /* set the corresponding IQ ENB bit */ - if (lio_dev->io_qmask.iq & (1ULL << q_no)) { - reg_val = lio_read_csr64( - lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - reg_val = reg_val | CN23XX_PKT_INPUT_CTL_RING_ENB; - lio_write_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - reg_val); - } - } - for (q_no = 0; q_no < lio_dev->num_oqs; q_no++) { - uint32_t reg_val; - - /* set the corresponding OQ ENB bit */ - if (lio_dev->io_qmask.oq & (1ULL << q_no)) { - reg_val = lio_read_csr( - lio_dev, - CN23XX_SLI_OQ_PKT_CONTROL(q_no)); - reg_val = reg_val | CN23XX_PKT_OUTPUT_CTL_RING_ENB; - lio_write_csr(lio_dev, - CN23XX_SLI_OQ_PKT_CONTROL(q_no), - reg_val); - } - } - - return 0; -} - -static void -cn23xx_vf_disable_io_queues(struct lio_device *lio_dev) -{ - uint32_t num_queues; - - PMD_INIT_FUNC_TRACE(); - - /* per HRM, rings can only be disabled via reset operation, - * NOT via SLI_PKT()_INPUT/OUTPUT_CONTROL[ENB] - */ - num_queues = lio_dev->num_iqs; - if (num_queues < lio_dev->num_oqs) - num_queues = lio_dev->num_oqs; - - cn23xx_vf_reset_io_queues(lio_dev, num_queues); -} - -void -cn23xx_vf_ask_pf_to_do_flr(struct lio_device *lio_dev) -{ - struct lio_mbox_cmd mbox_cmd; - - memset(&mbox_cmd, 0, sizeof(struct lio_mbox_cmd)); - mbox_cmd.msg.s.type = LIO_MBOX_REQUEST; - mbox_cmd.msg.s.resp_needed = 0; - mbox_cmd.msg.s.cmd = LIO_VF_FLR_REQUEST; - mbox_cmd.msg.s.len = 1; - mbox_cmd.q_no = 0; - mbox_cmd.recv_len = 0; - mbox_cmd.recv_status = 0; - mbox_cmd.fn = NULL; - mbox_cmd.fn_arg = 0; - - lio_mbox_write(lio_dev, &mbox_cmd); -} - -static void -cn23xx_pfvf_hs_callback(struct lio_device *lio_dev, - struct lio_mbox_cmd *cmd, void *arg) -{ - uint32_t major = 0; - - PMD_INIT_FUNC_TRACE(); - - rte_memcpy((uint8_t *)&lio_dev->pfvf_hsword, cmd->msg.s.params, 6); - if (cmd->recv_len > 1) { - struct lio_version *lio_ver = (struct lio_version *)cmd->data; - - major = lio_ver->major; - major = major << 16; - } - - rte_atomic64_set((rte_atomic64_t *)arg, major | 1); -} - -int -cn23xx_pfvf_handshake(struct lio_device *lio_dev) -{ - struct lio_mbox_cmd mbox_cmd; - struct lio_version *lio_ver = (struct lio_version *)&mbox_cmd.data[0]; - uint32_t q_no, count = 0; - rte_atomic64_t status; - uint32_t pfmajor; - uint32_t vfmajor; - uint32_t ret; - - PMD_INIT_FUNC_TRACE(); - - /* Sending VF_ACTIVE indication to the PF driver */ - lio_dev_dbg(lio_dev, "requesting info from PF\n"); - - mbox_cmd.msg.mbox_msg64 = 0; - mbox_cmd.msg.s.type = LIO_MBOX_REQUEST; - mbox_cmd.msg.s.resp_needed = 1; - mbox_cmd.msg.s.cmd = LIO_VF_ACTIVE; - mbox_cmd.msg.s.len = 2; - mbox_cmd.data[0] = 0; - lio_ver->major = LIO_BASE_MAJOR_VERSION; - lio_ver->minor = LIO_BASE_MINOR_VERSION; - lio_ver->micro = LIO_BASE_MICRO_VERSION; - mbox_cmd.q_no = 0; - mbox_cmd.recv_len = 0; - mbox_cmd.recv_status = 0; - mbox_cmd.fn = (lio_mbox_callback)cn23xx_pfvf_hs_callback; - mbox_cmd.fn_arg = (void *)&status; - - if (lio_mbox_write(lio_dev, &mbox_cmd)) { - lio_dev_err(lio_dev, "Write to mailbox failed\n"); - return -1; - } - - rte_atomic64_set(&status, 0); - - do { - rte_delay_ms(1); - } while ((rte_atomic64_read(&status) == 0) && (count++ < 10000)); - - ret = rte_atomic64_read(&status); - if (ret == 0) { - lio_dev_err(lio_dev, "cn23xx_pfvf_handshake timeout\n"); - return -1; - } - - for (q_no = 0; q_no < lio_dev->num_iqs; q_no++) - lio_dev->instr_queue[q_no]->txpciq.s.pkind = - lio_dev->pfvf_hsword.pkind; - - vfmajor = LIO_BASE_MAJOR_VERSION; - pfmajor = ret >> 16; - if (pfmajor != vfmajor) { - lio_dev_err(lio_dev, - "VF LiquidIO driver (major version %d) is not compatible with LiquidIO PF driver (major version %d)\n", - vfmajor, pfmajor); - ret = -EPERM; - } else { - lio_dev_dbg(lio_dev, - "VF LiquidIO driver (major version %d), LiquidIO PF driver (major version %d)\n", - vfmajor, pfmajor); - ret = 0; - } - - lio_dev_dbg(lio_dev, "got data from PF pkind is %d\n", - lio_dev->pfvf_hsword.pkind); - - return ret; -} - -void -cn23xx_vf_handle_mbox(struct lio_device *lio_dev) -{ - uint64_t mbox_int_val; - - /* read and clear by writing 1 */ - mbox_int_val = rte_read64(lio_dev->mbox[0]->mbox_int_reg); - rte_write64(mbox_int_val, lio_dev->mbox[0]->mbox_int_reg); - if (lio_mbox_read(lio_dev->mbox[0])) - lio_mbox_process_message(lio_dev->mbox[0]); -} - -int -cn23xx_vf_setup_device(struct lio_device *lio_dev) -{ - uint64_t reg_val; - - PMD_INIT_FUNC_TRACE(); - - /* INPUT_CONTROL[RPVF] gives the VF IOq count */ - reg_val = lio_read_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(0)); - - lio_dev->pf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_PF_NUM_POS) & - CN23XX_PKT_INPUT_CTL_PF_NUM_MASK; - lio_dev->vf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_VF_NUM_POS) & - CN23XX_PKT_INPUT_CTL_VF_NUM_MASK; - - reg_val = reg_val >> CN23XX_PKT_INPUT_CTL_RPVF_POS; - - lio_dev->sriov_info.rings_per_vf = - reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK; - - lio_dev->default_config = lio_get_conf(lio_dev); - if (lio_dev->default_config == NULL) - return -1; - - lio_dev->fn_list.setup_iq_regs = cn23xx_vf_setup_iq_regs; - lio_dev->fn_list.setup_oq_regs = cn23xx_vf_setup_oq_regs; - lio_dev->fn_list.setup_mbox = cn23xx_vf_setup_mbox; - lio_dev->fn_list.free_mbox = cn23xx_vf_free_mbox; - - lio_dev->fn_list.setup_device_regs = cn23xx_vf_setup_device_regs; - - lio_dev->fn_list.enable_io_queues = cn23xx_vf_enable_io_queues; - lio_dev->fn_list.disable_io_queues = cn23xx_vf_disable_io_queues; - - return 0; -} - diff --git a/dpdk/drivers/net/liquidio/base/lio_23xx_vf.h b/dpdk/drivers/net/liquidio/base/lio_23xx_vf.h deleted file mode 100644 index 8e5362db1..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_23xx_vf.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_23XX_VF_H_ -#define _LIO_23XX_VF_H_ - -#include - -#include "lio_struct.h" - -static const struct lio_config default_cn23xx_conf = { - .card_type = LIO_23XX, - .card_name = LIO_23XX_NAME, - /** IQ attributes */ - .iq = { - .max_iqs = CN23XX_CFG_IO_QUEUES, - .pending_list_size = - (CN23XX_MAX_IQ_DESCRIPTORS * CN23XX_CFG_IO_QUEUES), - .instr_type = OCTEON_64BYTE_INSTR, - }, - - /** OQ attributes */ - .oq = { - .max_oqs = CN23XX_CFG_IO_QUEUES, - .info_ptr = OCTEON_OQ_INFOPTR_MODE, - .refill_threshold = CN23XX_OQ_REFIL_THRESHOLD, - }, - - .num_nic_ports = CN23XX_DEFAULT_NUM_PORTS, - .num_def_rx_descs = CN23XX_MAX_OQ_DESCRIPTORS, - .num_def_tx_descs = CN23XX_MAX_IQ_DESCRIPTORS, - .def_rx_buf_size = CN23XX_OQ_BUF_SIZE, -}; - -static inline const struct lio_config * -lio_get_conf(struct lio_device *lio_dev) -{ - const struct lio_config *default_lio_conf = NULL; - - /* check the LIO Device model & return the corresponding lio - * configuration - */ - default_lio_conf = &default_cn23xx_conf; - - if (default_lio_conf == NULL) { - lio_dev_err(lio_dev, "Configuration verification failed\n"); - return NULL; - } - - return default_lio_conf; -} - -#define CN23XX_VF_BUSY_READING_REG_LOOP_COUNT 100000 - -void cn23xx_vf_ask_pf_to_do_flr(struct lio_device *lio_dev); - -int cn23xx_pfvf_handshake(struct lio_device *lio_dev); - -int cn23xx_vf_setup_device(struct lio_device *lio_dev); - -void cn23xx_vf_handle_mbox(struct lio_device *lio_dev); -#endif /* _LIO_23XX_VF_H_ */ diff --git a/dpdk/drivers/net/liquidio/base/lio_hw_defs.h b/dpdk/drivers/net/liquidio/base/lio_hw_defs.h deleted file mode 100644 index 5e119c124..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_hw_defs.h +++ /dev/null @@ -1,239 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_HW_DEFS_H_ -#define _LIO_HW_DEFS_H_ - -#include - -#ifndef PCI_VENDOR_ID_CAVIUM -#define PCI_VENDOR_ID_CAVIUM 0x177D -#endif - -#define LIO_CN23XX_VF_VID 0x9712 - -/* CN23xx subsystem device ids */ -#define PCI_SUBSYS_DEV_ID_CN2350_210 0x0004 -#define PCI_SUBSYS_DEV_ID_CN2360_210 0x0005 -#define PCI_SUBSYS_DEV_ID_CN2360_225 0x0006 -#define PCI_SUBSYS_DEV_ID_CN2350_225 0x0007 -#define PCI_SUBSYS_DEV_ID_CN2350_210SVPN3 0x0008 -#define PCI_SUBSYS_DEV_ID_CN2360_210SVPN3 0x0009 -#define PCI_SUBSYS_DEV_ID_CN2350_210SVPT 0x000a -#define PCI_SUBSYS_DEV_ID_CN2360_210SVPT 0x000b - -/* --------------------------CONFIG VALUES------------------------ */ - -/* CN23xx IQ configuration macros */ -#define CN23XX_MAX_RINGS_PER_PF 64 -#define CN23XX_MAX_RINGS_PER_VF 8 - -#define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF -#define CN23XX_MAX_IQ_DESCRIPTORS 512 -#define CN23XX_MIN_IQ_DESCRIPTORS 128 - -#define CN23XX_MAX_OUTPUT_QUEUES CN23XX_MAX_RINGS_PER_PF -#define CN23XX_MAX_OQ_DESCRIPTORS 512 -#define CN23XX_MIN_OQ_DESCRIPTORS 128 -#define CN23XX_OQ_BUF_SIZE 1536 - -#define CN23XX_OQ_REFIL_THRESHOLD 16 - -#define CN23XX_DEFAULT_NUM_PORTS 1 - -#define CN23XX_CFG_IO_QUEUES CN23XX_MAX_RINGS_PER_PF - -/* common OCTEON configuration macros */ -#define OCTEON_64BYTE_INSTR 64 -#define OCTEON_OQ_INFOPTR_MODE 1 - -/* Max IOQs per LIO Link */ -#define LIO_MAX_IOQS_PER_IF 64 - -/* Wait time in milliseconds for FLR */ -#define LIO_PCI_FLR_WAIT 100 - -enum lio_card_type { - LIO_23XX /* 23xx */ -}; - -#define LIO_23XX_NAME "23xx" - -#define LIO_DEV_RUNNING 0xc - -#define LIO_OQ_REFILL_THRESHOLD_CFG(cfg) \ - ((cfg)->default_config->oq.refill_threshold) -#define LIO_NUM_DEF_TX_DESCS_CFG(cfg) \ - ((cfg)->default_config->num_def_tx_descs) - -#define LIO_IQ_INSTR_TYPE(cfg) ((cfg)->default_config->iq.instr_type) - -/* The following config values are fixed and should not be modified. */ - -/* Maximum number of Instruction queues */ -#define LIO_MAX_INSTR_QUEUES(lio_dev) CN23XX_MAX_RINGS_PER_VF - -#define LIO_MAX_POSSIBLE_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES -#define LIO_MAX_POSSIBLE_OUTPUT_QUEUES CN23XX_MAX_OUTPUT_QUEUES - -#define LIO_DEVICE_NAME_LEN 32 -#define LIO_BASE_MAJOR_VERSION 1 -#define LIO_BASE_MINOR_VERSION 5 -#define LIO_BASE_MICRO_VERSION 1 - -#define LIO_FW_VERSION_LENGTH 32 - -#define LIO_Q_RECONF_MIN_VERSION "1.7.0" -#define LIO_VF_TRUST_MIN_VERSION "1.7.1" - -/** Tag types used by Octeon cores in its work. */ -enum octeon_tag_type { - OCTEON_ORDERED_TAG = 0, - OCTEON_ATOMIC_TAG = 1, -}; - -/* pre-defined host->NIC tag values */ -#define LIO_CONTROL (0x11111110) -#define LIO_DATA(i) (0x11111111 + (i)) - -/* used for NIC operations */ -#define LIO_OPCODE 1 - -/* Subcodes are used by host driver/apps to identify the sub-operation - * for the core. They only need to by unique for a given subsystem. - */ -#define LIO_OPCODE_SUBCODE(op, sub) \ - ((((op) & 0x0f) << 8) | ((sub) & 0x7f)) - -/** LIO_OPCODE subcodes */ -/* This subcode is sent by core PCI driver to indicate cores are ready. */ -#define LIO_OPCODE_NW_DATA 0x02 /* network packet data */ -#define LIO_OPCODE_CMD 0x03 -#define LIO_OPCODE_INFO 0x04 -#define LIO_OPCODE_PORT_STATS 0x05 -#define LIO_OPCODE_IF_CFG 0x09 - -#define LIO_MIN_RX_BUF_SIZE 64 -#define LIO_MAX_RX_PKTLEN (64 * 1024) - -/* NIC Command types */ -#define LIO_CMD_CHANGE_MTU 0x1 -#define LIO_CMD_CHANGE_DEVFLAGS 0x3 -#define LIO_CMD_RX_CTL 0x4 -#define LIO_CMD_CLEAR_STATS 0x6 -#define LIO_CMD_SET_RSS 0xD -#define LIO_CMD_TNL_RX_CSUM_CTL 0x10 -#define LIO_CMD_TNL_TX_CSUM_CTL 0x11 -#define LIO_CMD_ADD_VLAN_FILTER 0x17 -#define LIO_CMD_DEL_VLAN_FILTER 0x18 -#define LIO_CMD_VXLAN_PORT_CONFIG 0x19 -#define LIO_CMD_QUEUE_COUNT_CTL 0x1f - -#define LIO_CMD_VXLAN_PORT_ADD 0x0 -#define LIO_CMD_VXLAN_PORT_DEL 0x1 -#define LIO_CMD_RXCSUM_ENABLE 0x0 -#define LIO_CMD_TXCSUM_ENABLE 0x0 - -/* RX(packets coming from wire) Checksum verification flags */ -/* TCP/UDP csum */ -#define LIO_L4_CSUM_VERIFIED 0x1 -#define LIO_IP_CSUM_VERIFIED 0x2 - -/* RSS */ -#define LIO_RSS_PARAM_DISABLE_RSS 0x10 -#define LIO_RSS_PARAM_HASH_KEY_UNCHANGED 0x08 -#define LIO_RSS_PARAM_ITABLE_UNCHANGED 0x04 -#define LIO_RSS_PARAM_HASH_INFO_UNCHANGED 0x02 - -#define LIO_RSS_HASH_IPV4 0x100 -#define LIO_RSS_HASH_TCP_IPV4 0x200 -#define LIO_RSS_HASH_IPV6 0x400 -#define LIO_RSS_HASH_TCP_IPV6 0x1000 -#define LIO_RSS_HASH_IPV6_EX 0x800 -#define LIO_RSS_HASH_TCP_IPV6_EX 0x2000 - -#define LIO_RSS_OFFLOAD_ALL ( \ - LIO_RSS_HASH_IPV4 | \ - LIO_RSS_HASH_TCP_IPV4 | \ - LIO_RSS_HASH_IPV6 | \ - LIO_RSS_HASH_TCP_IPV6 | \ - LIO_RSS_HASH_IPV6_EX | \ - LIO_RSS_HASH_TCP_IPV6_EX) - -#define LIO_RSS_MAX_TABLE_SZ 128 -#define LIO_RSS_MAX_KEY_SZ 40 -#define LIO_RSS_PARAM_SIZE 16 - -/* Interface flags communicated between host driver and core app. */ -enum lio_ifflags { - LIO_IFFLAG_PROMISC = 0x01, - LIO_IFFLAG_ALLMULTI = 0x02, - LIO_IFFLAG_UNICAST = 0x10 -}; - -/* Routines for reading and writing CSRs */ -#ifdef RTE_LIBRTE_LIO_DEBUG_REGS -#define lio_write_csr(lio_dev, reg_off, value) \ - do { \ - typeof(lio_dev) _dev = lio_dev; \ - typeof(reg_off) _reg_off = reg_off; \ - typeof(value) _value = value; \ - PMD_REGS_LOG(_dev, \ - "Write32: Reg: 0x%08lx Val: 0x%08lx\n", \ - (unsigned long)_reg_off, \ - (unsigned long)_value); \ - rte_write32(_value, _dev->hw_addr + _reg_off); \ - } while (0) - -#define lio_write_csr64(lio_dev, reg_off, val64) \ - do { \ - typeof(lio_dev) _dev = lio_dev; \ - typeof(reg_off) _reg_off = reg_off; \ - typeof(val64) _val64 = val64; \ - PMD_REGS_LOG( \ - _dev, \ - "Write64: Reg: 0x%08lx Val: 0x%016llx\n", \ - (unsigned long)_reg_off, \ - (unsigned long long)_val64); \ - rte_write64(_val64, _dev->hw_addr + _reg_off); \ - } while (0) - -#define lio_read_csr(lio_dev, reg_off) \ - ({ \ - typeof(lio_dev) _dev = lio_dev; \ - typeof(reg_off) _reg_off = reg_off; \ - uint32_t val = rte_read32(_dev->hw_addr + _reg_off); \ - PMD_REGS_LOG(_dev, \ - "Read32: Reg: 0x%08lx Val: 0x%08lx\n", \ - (unsigned long)_reg_off, \ - (unsigned long)val); \ - val; \ - }) - -#define lio_read_csr64(lio_dev, reg_off) \ - ({ \ - typeof(lio_dev) _dev = lio_dev; \ - typeof(reg_off) _reg_off = reg_off; \ - uint64_t val64 = rte_read64(_dev->hw_addr + _reg_off); \ - PMD_REGS_LOG( \ - _dev, \ - "Read64: Reg: 0x%08lx Val: 0x%016llx\n", \ - (unsigned long)_reg_off, \ - (unsigned long long)val64); \ - val64; \ - }) -#else -#define lio_write_csr(lio_dev, reg_off, value) \ - rte_write32(value, (lio_dev)->hw_addr + (reg_off)) - -#define lio_write_csr64(lio_dev, reg_off, val64) \ - rte_write64(val64, (lio_dev)->hw_addr + (reg_off)) - -#define lio_read_csr(lio_dev, reg_off) \ - rte_read32((lio_dev)->hw_addr + (reg_off)) - -#define lio_read_csr64(lio_dev, reg_off) \ - rte_read64((lio_dev)->hw_addr + (reg_off)) -#endif -#endif /* _LIO_HW_DEFS_H_ */ diff --git a/dpdk/drivers/net/liquidio/base/lio_mbox.c b/dpdk/drivers/net/liquidio/base/lio_mbox.c deleted file mode 100644 index 2ac2b1b33..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_mbox.c +++ /dev/null @@ -1,246 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#include -#include - -#include "lio_logs.h" -#include "lio_struct.h" -#include "lio_mbox.h" - -/** - * lio_mbox_read: - * @mbox: Pointer mailbox - * - * Reads the 8-bytes of data from the mbox register - * Writes back the acknowledgment indicating completion of read - */ -int -lio_mbox_read(struct lio_mbox *mbox) -{ - union lio_mbox_message msg; - int ret = 0; - - msg.mbox_msg64 = rte_read64(mbox->mbox_read_reg); - - if ((msg.mbox_msg64 == LIO_PFVFACK) || (msg.mbox_msg64 == LIO_PFVFSIG)) - return 0; - - if (mbox->state & LIO_MBOX_STATE_REQ_RECEIVING) { - mbox->mbox_req.data[mbox->mbox_req.recv_len - 1] = - msg.mbox_msg64; - mbox->mbox_req.recv_len++; - } else { - if (mbox->state & LIO_MBOX_STATE_RES_RECEIVING) { - mbox->mbox_resp.data[mbox->mbox_resp.recv_len - 1] = - msg.mbox_msg64; - mbox->mbox_resp.recv_len++; - } else { - if ((mbox->state & LIO_MBOX_STATE_IDLE) && - (msg.s.type == LIO_MBOX_REQUEST)) { - mbox->state &= ~LIO_MBOX_STATE_IDLE; - mbox->state |= LIO_MBOX_STATE_REQ_RECEIVING; - mbox->mbox_req.msg.mbox_msg64 = msg.mbox_msg64; - mbox->mbox_req.q_no = mbox->q_no; - mbox->mbox_req.recv_len = 1; - } else { - if ((mbox->state & - LIO_MBOX_STATE_RES_PENDING) && - (msg.s.type == LIO_MBOX_RESPONSE)) { - mbox->state &= - ~LIO_MBOX_STATE_RES_PENDING; - mbox->state |= - LIO_MBOX_STATE_RES_RECEIVING; - mbox->mbox_resp.msg.mbox_msg64 = - msg.mbox_msg64; - mbox->mbox_resp.q_no = mbox->q_no; - mbox->mbox_resp.recv_len = 1; - } else { - rte_write64(LIO_PFVFERR, - mbox->mbox_read_reg); - mbox->state |= LIO_MBOX_STATE_ERROR; - return -1; - } - } - } - } - - if (mbox->state & LIO_MBOX_STATE_REQ_RECEIVING) { - if (mbox->mbox_req.recv_len < msg.s.len) { - ret = 0; - } else { - mbox->state &= ~LIO_MBOX_STATE_REQ_RECEIVING; - mbox->state |= LIO_MBOX_STATE_REQ_RECEIVED; - ret = 1; - } - } else { - if (mbox->state & LIO_MBOX_STATE_RES_RECEIVING) { - if (mbox->mbox_resp.recv_len < msg.s.len) { - ret = 0; - } else { - mbox->state &= ~LIO_MBOX_STATE_RES_RECEIVING; - mbox->state |= LIO_MBOX_STATE_RES_RECEIVED; - ret = 1; - } - } else { - RTE_ASSERT(0); - } - } - - rte_write64(LIO_PFVFACK, mbox->mbox_read_reg); - - return ret; -} - -/** - * lio_mbox_write: - * @lio_dev: Pointer lio device - * @mbox_cmd: Cmd to send to mailbox. - * - * Populates the queue specific mbox structure - * with cmd information. - * Write the cmd to mbox register - */ -int -lio_mbox_write(struct lio_device *lio_dev, - struct lio_mbox_cmd *mbox_cmd) -{ - struct lio_mbox *mbox = lio_dev->mbox[mbox_cmd->q_no]; - uint32_t count, i, ret = LIO_MBOX_STATUS_SUCCESS; - - if ((mbox_cmd->msg.s.type == LIO_MBOX_RESPONSE) && - !(mbox->state & LIO_MBOX_STATE_REQ_RECEIVED)) - return LIO_MBOX_STATUS_FAILED; - - if ((mbox_cmd->msg.s.type == LIO_MBOX_REQUEST) && - !(mbox->state & LIO_MBOX_STATE_IDLE)) - return LIO_MBOX_STATUS_BUSY; - - if (mbox_cmd->msg.s.type == LIO_MBOX_REQUEST) { - rte_memcpy(&mbox->mbox_resp, mbox_cmd, - sizeof(struct lio_mbox_cmd)); - mbox->state = LIO_MBOX_STATE_RES_PENDING; - } - - count = 0; - - while (rte_read64(mbox->mbox_write_reg) != LIO_PFVFSIG) { - rte_delay_ms(1); - if (count++ == 1000) { - ret = LIO_MBOX_STATUS_FAILED; - break; - } - } - - if (ret == LIO_MBOX_STATUS_SUCCESS) { - rte_write64(mbox_cmd->msg.mbox_msg64, mbox->mbox_write_reg); - for (i = 0; i < (uint32_t)(mbox_cmd->msg.s.len - 1); i++) { - count = 0; - while (rte_read64(mbox->mbox_write_reg) != - LIO_PFVFACK) { - rte_delay_ms(1); - if (count++ == 1000) { - ret = LIO_MBOX_STATUS_FAILED; - break; - } - } - rte_write64(mbox_cmd->data[i], mbox->mbox_write_reg); - } - } - - if (mbox_cmd->msg.s.type == LIO_MBOX_RESPONSE) { - mbox->state = LIO_MBOX_STATE_IDLE; - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - } else { - if ((!mbox_cmd->msg.s.resp_needed) || - (ret == LIO_MBOX_STATUS_FAILED)) { - mbox->state &= ~LIO_MBOX_STATE_RES_PENDING; - if (!(mbox->state & (LIO_MBOX_STATE_REQ_RECEIVING | - LIO_MBOX_STATE_REQ_RECEIVED))) - mbox->state = LIO_MBOX_STATE_IDLE; - } - } - - return ret; -} - -/** - * lio_mbox_process_cmd: - * @mbox: Pointer mailbox - * @mbox_cmd: Pointer to command received - * - * Process the cmd received in mbox - */ -static int -lio_mbox_process_cmd(struct lio_mbox *mbox, - struct lio_mbox_cmd *mbox_cmd) -{ - struct lio_device *lio_dev = mbox->lio_dev; - - if (mbox_cmd->msg.s.cmd == LIO_CORES_CRASHED) - lio_dev_err(lio_dev, "Octeon core(s) crashed or got stuck!\n"); - - return 0; -} - -/** - * Process the received mbox message. - */ -int -lio_mbox_process_message(struct lio_mbox *mbox) -{ - struct lio_mbox_cmd mbox_cmd; - - if (mbox->state & LIO_MBOX_STATE_ERROR) { - if (mbox->state & (LIO_MBOX_STATE_RES_PENDING | - LIO_MBOX_STATE_RES_RECEIVING)) { - rte_memcpy(&mbox_cmd, &mbox->mbox_resp, - sizeof(struct lio_mbox_cmd)); - mbox->state = LIO_MBOX_STATE_IDLE; - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - mbox_cmd.recv_status = 1; - if (mbox_cmd.fn) - mbox_cmd.fn(mbox->lio_dev, &mbox_cmd, - mbox_cmd.fn_arg); - - return 0; - } - - mbox->state = LIO_MBOX_STATE_IDLE; - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - - return 0; - } - - if (mbox->state & LIO_MBOX_STATE_RES_RECEIVED) { - rte_memcpy(&mbox_cmd, &mbox->mbox_resp, - sizeof(struct lio_mbox_cmd)); - mbox->state = LIO_MBOX_STATE_IDLE; - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - mbox_cmd.recv_status = 0; - if (mbox_cmd.fn) - mbox_cmd.fn(mbox->lio_dev, &mbox_cmd, mbox_cmd.fn_arg); - - return 0; - } - - if (mbox->state & LIO_MBOX_STATE_REQ_RECEIVED) { - rte_memcpy(&mbox_cmd, &mbox->mbox_req, - sizeof(struct lio_mbox_cmd)); - if (!mbox_cmd.msg.s.resp_needed) { - mbox->state &= ~LIO_MBOX_STATE_REQ_RECEIVED; - if (!(mbox->state & LIO_MBOX_STATE_RES_PENDING)) - mbox->state = LIO_MBOX_STATE_IDLE; - rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg); - } - - lio_mbox_process_cmd(mbox, &mbox_cmd); - - return 0; - } - - RTE_ASSERT(0); - - return 0; -} diff --git a/dpdk/drivers/net/liquidio/base/lio_mbox.h b/dpdk/drivers/net/liquidio/base/lio_mbox.h deleted file mode 100644 index 457917e91..000000000 --- a/dpdk/drivers/net/liquidio/base/lio_mbox.h +++ /dev/null @@ -1,102 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_MBOX_H_ -#define _LIO_MBOX_H_ - -#include - -#include - -/* Macros for Mail Box Communication */ - -#define LIO_MBOX_DATA_MAX 32 - -#define LIO_VF_ACTIVE 0x1 -#define LIO_VF_FLR_REQUEST 0x2 -#define LIO_CORES_CRASHED 0x3 - -/* Macro for Read acknowledgment */ -#define LIO_PFVFACK 0xffffffffffffffff -#define LIO_PFVFSIG 0x1122334455667788 -#define LIO_PFVFERR 0xDEADDEADDEADDEAD - -enum lio_mbox_cmd_status { - LIO_MBOX_STATUS_SUCCESS = 0, - LIO_MBOX_STATUS_FAILED = 1, - LIO_MBOX_STATUS_BUSY = 2 -}; - -enum lio_mbox_message_type { - LIO_MBOX_REQUEST = 0, - LIO_MBOX_RESPONSE = 1 -}; - -union lio_mbox_message { - uint64_t mbox_msg64; - struct { - uint16_t type : 1; - uint16_t resp_needed : 1; - uint16_t cmd : 6; - uint16_t len : 8; - uint8_t params[6]; - } s; -}; - -typedef void (*lio_mbox_callback)(void *, void *, void *); - -struct lio_mbox_cmd { - union lio_mbox_message msg; - uint64_t data[LIO_MBOX_DATA_MAX]; - uint32_t q_no; - uint32_t recv_len; - uint32_t recv_status; - lio_mbox_callback fn; - void *fn_arg; -}; - -enum lio_mbox_state { - LIO_MBOX_STATE_IDLE = 1, - LIO_MBOX_STATE_REQ_RECEIVING = 2, - LIO_MBOX_STATE_REQ_RECEIVED = 4, - LIO_MBOX_STATE_RES_PENDING = 8, - LIO_MBOX_STATE_RES_RECEIVING = 16, - LIO_MBOX_STATE_RES_RECEIVED = 16, - LIO_MBOX_STATE_ERROR = 32 -}; - -struct lio_mbox { - /* A spinlock to protect access to this q_mbox. */ - rte_spinlock_t lock; - - struct lio_device *lio_dev; - - uint32_t q_no; - - enum lio_mbox_state state; - - /* SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */ - void *mbox_int_reg; - - /* SLI_PKT_PF_VF_MBOX_SIG(0) for PF, - * SLI_PKT_PF_VF_MBOX_SIG(1) for VF. - */ - void *mbox_write_reg; - - /* SLI_PKT_PF_VF_MBOX_SIG(1) for PF, - * SLI_PKT_PF_VF_MBOX_SIG(0) for VF. - */ - void *mbox_read_reg; - - struct lio_mbox_cmd mbox_req; - - struct lio_mbox_cmd mbox_resp; - -}; - -int lio_mbox_read(struct lio_mbox *mbox); -int lio_mbox_write(struct lio_device *lio_dev, - struct lio_mbox_cmd *mbox_cmd); -int lio_mbox_process_message(struct lio_mbox *mbox); -#endif /* _LIO_MBOX_H_ */ diff --git a/dpdk/drivers/net/liquidio/lio_ethdev.c b/dpdk/drivers/net/liquidio/lio_ethdev.c deleted file mode 100644 index ebcfbb1a5..000000000 --- a/dpdk/drivers/net/liquidio/lio_ethdev.c +++ /dev/null @@ -1,2147 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "lio_logs.h" -#include "lio_23xx_vf.h" -#include "lio_ethdev.h" -#include "lio_rxtx.h" - -/* Default RSS key in use */ -static uint8_t lio_rss_key[40] = { - 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, - 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, - 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, - 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, - 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA, -}; - -static const struct rte_eth_desc_lim lio_rx_desc_lim = { - .nb_max = CN23XX_MAX_OQ_DESCRIPTORS, - .nb_min = CN23XX_MIN_OQ_DESCRIPTORS, - .nb_align = 1, -}; - -static const struct rte_eth_desc_lim lio_tx_desc_lim = { - .nb_max = CN23XX_MAX_IQ_DESCRIPTORS, - .nb_min = CN23XX_MIN_IQ_DESCRIPTORS, - .nb_align = 1, -}; - -/* Wait for control command to reach nic. */ -static uint16_t -lio_wait_for_ctrl_cmd(struct lio_device *lio_dev, - struct lio_dev_ctrl_cmd *ctrl_cmd) -{ - uint16_t timeout = LIO_MAX_CMD_TIMEOUT; - - while ((ctrl_cmd->cond == 0) && --timeout) { - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - rte_delay_ms(1); - } - - return !timeout; -} - -/** - * \brief Send Rx control command - * @param eth_dev Pointer to the structure rte_eth_dev - * @param start_stop whether to start or stop - */ -static int -lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL; - ctrl_pkt.ncmd.s.param1 = start_stop; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send RX Control message\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "RX Control command timed out\n"); - return -1; - } - - return 0; -} - -/* store statistics names and its offset in stats structure */ -struct rte_lio_xstats_name_off { - char name[RTE_ETH_XSTATS_NAME_SIZE]; - unsigned int offset; -}; - -static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = { - {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)}, - {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)}, - {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)}, - {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)}, - {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)}, - {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)}, - {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)}, - {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)}, - {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)}, - {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)}, - {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)}, - {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)}, - {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)}, - {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) + - sizeof(struct octeon_rx_stats)}, - {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) + - sizeof(struct octeon_rx_stats)}, - {"tx_broadcast_pkts", - (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) + - sizeof(struct octeon_rx_stats)}, - {"tx_multicast_pkts", - (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) + - sizeof(struct octeon_rx_stats)}, - {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) + - sizeof(struct octeon_rx_stats)}, - {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) + - sizeof(struct octeon_rx_stats)}, - {"tx_total_collisions", (offsetof(struct octeon_tx_stats, - total_collisions)) + - sizeof(struct octeon_rx_stats)}, - {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) + - sizeof(struct octeon_rx_stats)}, - {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) + - sizeof(struct octeon_rx_stats)}, -}; - -#define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings) - -/* Get hw stats of the port */ -static int -lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, - unsigned int n) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - uint16_t timeout = LIO_MAX_CMD_TIMEOUT; - struct octeon_link_stats *hw_stats; - struct lio_link_stats_resp *resp; - struct lio_soft_command *sc; - uint32_t resp_size; - unsigned int i; - int retval; - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down\n", - lio_dev->port_id); - return -EINVAL; - } - - if (n < LIO_NB_XSTATS) - return LIO_NB_XSTATS; - - resp_size = sizeof(struct lio_link_stats_resp); - sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); - if (sc == NULL) - return -ENOMEM; - - resp = (struct lio_link_stats_resp *)sc->virtrptr; - lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, - LIO_OPCODE_PORT_STATS, 0, 0, 0); - - /* Setting wait time in seconds */ - sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; - - retval = lio_send_soft_command(lio_dev, sc); - if (retval == LIO_IQ_SEND_FAILED) { - lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n", - retval); - goto get_stats_fail; - } - - while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { - lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]); - lio_process_ordered_list(lio_dev); - rte_delay_ms(1); - } - - retval = resp->status; - if (retval) { - lio_dev_err(lio_dev, "failed to get port stats from firmware\n"); - goto get_stats_fail; - } - - lio_swap_8B_data((uint64_t *)(&resp->link_stats), - sizeof(struct octeon_link_stats) >> 3); - - hw_stats = &resp->link_stats; - - for (i = 0; i < LIO_NB_XSTATS; i++) { - xstats[i].id = i; - xstats[i].value = - *(uint64_t *)(((char *)hw_stats) + - rte_lio_stats_strings[i].offset); - } - - lio_free_soft_command(sc); - - return LIO_NB_XSTATS; - -get_stats_fail: - lio_free_soft_command(sc); - - return -1; -} - -static int -lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev, - struct rte_eth_xstat_name *xstats_names, - unsigned limit __rte_unused) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - unsigned int i; - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down\n", - lio_dev->port_id); - return -EINVAL; - } - - if (xstats_names == NULL) - return LIO_NB_XSTATS; - - /* Note: limit checked in rte_eth_xstats_names() */ - - for (i = 0; i < LIO_NB_XSTATS; i++) { - snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), - "%s", rte_lio_stats_strings[i].name); - } - - return LIO_NB_XSTATS; -} - -/* Reset hw stats for the port */ -static int -lio_dev_xstats_reset(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - int ret; - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down\n", - lio_dev->port_id); - return -EINVAL; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - ret = lio_send_ctrl_pkt(lio_dev, &ctrl_pkt); - if (ret != 0) { - lio_dev_err(lio_dev, "Failed to send clear stats command\n"); - return ret; - } - - ret = lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd); - if (ret != 0) { - lio_dev_err(lio_dev, "Clear stats command timed out\n"); - return ret; - } - - /* clear stored per queue stats */ - if (*eth_dev->dev_ops->stats_reset == NULL) - return 0; - return (*eth_dev->dev_ops->stats_reset)(eth_dev); -} - -/* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */ -static int -lio_dev_stats_get(struct rte_eth_dev *eth_dev, - struct rte_eth_stats *stats) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_droq_stats *oq_stats; - struct lio_iq_stats *iq_stats; - struct lio_instr_queue *txq; - struct lio_droq *droq; - int i, iq_no, oq_no; - uint64_t bytes = 0; - uint64_t pkts = 0; - uint64_t drop = 0; - - for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { - iq_no = lio_dev->linfo.txpciq[i].s.q_no; - txq = lio_dev->instr_queue[iq_no]; - if (txq != NULL) { - iq_stats = &txq->stats; - pkts += iq_stats->tx_done; - drop += iq_stats->tx_dropped; - bytes += iq_stats->tx_tot_bytes; - } - } - - stats->opackets = pkts; - stats->obytes = bytes; - stats->oerrors = drop; - - pkts = 0; - drop = 0; - bytes = 0; - - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - oq_no = lio_dev->linfo.rxpciq[i].s.q_no; - droq = lio_dev->droq[oq_no]; - if (droq != NULL) { - oq_stats = &droq->stats; - pkts += oq_stats->rx_pkts_received; - drop += (oq_stats->rx_dropped + - oq_stats->dropped_toomany + - oq_stats->dropped_nomem); - bytes += oq_stats->rx_bytes_received; - } - } - stats->ibytes = bytes; - stats->ipackets = pkts; - stats->ierrors = drop; - - return 0; -} - -static int -lio_dev_stats_reset(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_droq_stats *oq_stats; - struct lio_iq_stats *iq_stats; - struct lio_instr_queue *txq; - struct lio_droq *droq; - int i, iq_no, oq_no; - - for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { - iq_no = lio_dev->linfo.txpciq[i].s.q_no; - txq = lio_dev->instr_queue[iq_no]; - if (txq != NULL) { - iq_stats = &txq->stats; - memset(iq_stats, 0, sizeof(struct lio_iq_stats)); - } - } - - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - oq_no = lio_dev->linfo.rxpciq[i].s.q_no; - droq = lio_dev->droq[oq_no]; - if (droq != NULL) { - oq_stats = &droq->stats; - memset(oq_stats, 0, sizeof(struct lio_droq_stats)); - } - } - - return 0; -} - -static int -lio_dev_info_get(struct rte_eth_dev *eth_dev, - struct rte_eth_dev_info *devinfo) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - - switch (pci_dev->id.subsystem_device_id) { - /* CN23xx 10G cards */ - case PCI_SUBSYS_DEV_ID_CN2350_210: - case PCI_SUBSYS_DEV_ID_CN2360_210: - case PCI_SUBSYS_DEV_ID_CN2350_210SVPN3: - case PCI_SUBSYS_DEV_ID_CN2360_210SVPN3: - case PCI_SUBSYS_DEV_ID_CN2350_210SVPT: - case PCI_SUBSYS_DEV_ID_CN2360_210SVPT: - devinfo->speed_capa = RTE_ETH_LINK_SPEED_10G; - break; - /* CN23xx 25G cards */ - case PCI_SUBSYS_DEV_ID_CN2350_225: - case PCI_SUBSYS_DEV_ID_CN2360_225: - devinfo->speed_capa = RTE_ETH_LINK_SPEED_25G; - break; - default: - devinfo->speed_capa = RTE_ETH_LINK_SPEED_10G; - lio_dev_err(lio_dev, - "Unknown CN23XX subsystem device id. Setting 10G as default link speed.\n"); - return -EINVAL; - } - - devinfo->max_rx_queues = lio_dev->max_rx_queues; - devinfo->max_tx_queues = lio_dev->max_tx_queues; - - devinfo->min_rx_bufsize = LIO_MIN_RX_BUF_SIZE; - devinfo->max_rx_pktlen = LIO_MAX_RX_PKTLEN; - - devinfo->max_mac_addrs = 1; - - devinfo->rx_offload_capa = (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | - RTE_ETH_RX_OFFLOAD_UDP_CKSUM | - RTE_ETH_RX_OFFLOAD_TCP_CKSUM | - RTE_ETH_RX_OFFLOAD_VLAN_STRIP | - RTE_ETH_RX_OFFLOAD_RSS_HASH); - devinfo->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | - RTE_ETH_TX_OFFLOAD_UDP_CKSUM | - RTE_ETH_TX_OFFLOAD_TCP_CKSUM | - RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM); - - devinfo->rx_desc_lim = lio_rx_desc_lim; - devinfo->tx_desc_lim = lio_tx_desc_lim; - - devinfo->reta_size = LIO_RSS_MAX_TABLE_SZ; - devinfo->hash_key_size = LIO_RSS_MAX_KEY_SZ; - devinfo->flow_type_rss_offloads = (RTE_ETH_RSS_IPV4 | - RTE_ETH_RSS_NONFRAG_IPV4_TCP | - RTE_ETH_RSS_IPV6 | - RTE_ETH_RSS_NONFRAG_IPV6_TCP | - RTE_ETH_RSS_IPV6_EX | - RTE_ETH_RSS_IPV6_TCP_EX); - return 0; -} - -static int -lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - PMD_INIT_FUNC_TRACE(); - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't set MTU\n", - lio_dev->port_id); - return -EINVAL; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_MTU; - ctrl_pkt.ncmd.s.param1 = mtu; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send command to change MTU\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Command to change MTU timed out\n"); - return -1; - } - - return 0; -} - -static int -lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - struct lio_rss_set *rss_param; - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - int i, j, index; - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't update reta\n", - lio_dev->port_id); - return -EINVAL; - } - - if (reta_size != LIO_RSS_MAX_TABLE_SZ) { - lio_dev_err(lio_dev, - "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n", - reta_size, LIO_RSS_MAX_TABLE_SZ); - return -EINVAL; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0]; - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS; - ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - rss_param->param.flags = 0xF; - rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED; - rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ; - - for (i = 0; i < (reta_size / RTE_ETH_RETA_GROUP_SIZE); i++) { - for (j = 0; j < RTE_ETH_RETA_GROUP_SIZE; j++) { - if ((reta_conf[i].mask) & ((uint64_t)1 << j)) { - index = (i * RTE_ETH_RETA_GROUP_SIZE) + j; - rss_state->itable[index] = reta_conf[i].reta[j]; - } - } - } - - rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ; - memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size); - - lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3); - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to set rss hash\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Set rss hash timed out\n"); - return -1; - } - - return 0; -} - -static int -lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - int i, num; - - if (reta_size != LIO_RSS_MAX_TABLE_SZ) { - lio_dev_err(lio_dev, - "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n", - reta_size, LIO_RSS_MAX_TABLE_SZ); - return -EINVAL; - } - - num = reta_size / RTE_ETH_RETA_GROUP_SIZE; - - for (i = 0; i < num; i++) { - memcpy(reta_conf->reta, - &rss_state->itable[i * RTE_ETH_RETA_GROUP_SIZE], - RTE_ETH_RETA_GROUP_SIZE); - reta_conf++; - } - - return 0; -} - -static int -lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev, - struct rte_eth_rss_conf *rss_conf) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - uint8_t *hash_key = NULL; - uint64_t rss_hf = 0; - - if (rss_state->hash_disable) { - lio_dev_info(lio_dev, "RSS disabled in nic\n"); - rss_conf->rss_hf = 0; - return 0; - } - - /* Get key value */ - hash_key = rss_conf->rss_key; - if (hash_key != NULL) - memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size); - - if (rss_state->ip) - rss_hf |= RTE_ETH_RSS_IPV4; - if (rss_state->tcp_hash) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV4_TCP; - if (rss_state->ipv6) - rss_hf |= RTE_ETH_RSS_IPV6; - if (rss_state->ipv6_tcp_hash) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV6_TCP; - if (rss_state->ipv6_ex) - rss_hf |= RTE_ETH_RSS_IPV6_EX; - if (rss_state->ipv6_tcp_ex_hash) - rss_hf |= RTE_ETH_RSS_IPV6_TCP_EX; - - rss_conf->rss_hf = rss_hf; - - return 0; -} - -static int -lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev, - struct rte_eth_rss_conf *rss_conf) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - struct lio_rss_set *rss_param; - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't update hash\n", - lio_dev->port_id); - return -EINVAL; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0]; - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS; - ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - rss_param->param.flags = 0xF; - - if (rss_conf->rss_key) { - rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED; - rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ; - rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ; - memcpy(rss_state->hash_key, rss_conf->rss_key, - rss_state->hash_key_size); - memcpy(rss_param->key, rss_state->hash_key, - rss_state->hash_key_size); - } - - if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) { - /* Can't disable rss through hash flags, - * if it is enabled by default during init - */ - if (!rss_state->hash_disable) - return -EINVAL; - - /* This is for --disable-rss during testpmd launch */ - rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS; - } else { - uint32_t hashinfo = 0; - - /* Can't enable rss if disabled by default during init */ - if (rss_state->hash_disable) - return -EINVAL; - - if (rss_conf->rss_hf & RTE_ETH_RSS_IPV4) { - hashinfo |= LIO_RSS_HASH_IPV4; - rss_state->ip = 1; - } else { - rss_state->ip = 0; - } - - if (rss_conf->rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP) { - hashinfo |= LIO_RSS_HASH_TCP_IPV4; - rss_state->tcp_hash = 1; - } else { - rss_state->tcp_hash = 0; - } - - if (rss_conf->rss_hf & RTE_ETH_RSS_IPV6) { - hashinfo |= LIO_RSS_HASH_IPV6; - rss_state->ipv6 = 1; - } else { - rss_state->ipv6 = 0; - } - - if (rss_conf->rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) { - hashinfo |= LIO_RSS_HASH_TCP_IPV6; - rss_state->ipv6_tcp_hash = 1; - } else { - rss_state->ipv6_tcp_hash = 0; - } - - if (rss_conf->rss_hf & RTE_ETH_RSS_IPV6_EX) { - hashinfo |= LIO_RSS_HASH_IPV6_EX; - rss_state->ipv6_ex = 1; - } else { - rss_state->ipv6_ex = 0; - } - - if (rss_conf->rss_hf & RTE_ETH_RSS_IPV6_TCP_EX) { - hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX; - rss_state->ipv6_tcp_ex_hash = 1; - } else { - rss_state->ipv6_tcp_ex_hash = 0; - } - - rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED; - rss_param->param.hashinfo = hashinfo; - } - - lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3); - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to set rss hash\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Set rss hash timed out\n"); - return -1; - } - - return 0; -} - -/** - * Add vxlan dest udp port for an interface. - * - * @param eth_dev - * Pointer to the structure rte_eth_dev - * @param udp_tnl - * udp tunnel conf - * - * @return - * On success return 0 - * On failure return -1 - */ -static int -lio_dev_udp_tunnel_add(struct rte_eth_dev *eth_dev, - struct rte_eth_udp_tunnel *udp_tnl) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - if (udp_tnl == NULL) - return -EINVAL; - - if (udp_tnl->prot_type != RTE_ETH_TUNNEL_TYPE_VXLAN) { - lio_dev_err(lio_dev, "Unsupported tunnel type\n"); - return -1; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG; - ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port; - ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_ADD; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_ADD command\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "VXLAN_PORT_ADD command timed out\n"); - return -1; - } - - return 0; -} - -/** - * Remove vxlan dest udp port for an interface. - * - * @param eth_dev - * Pointer to the structure rte_eth_dev - * @param udp_tnl - * udp tunnel conf - * - * @return - * On success return 0 - * On failure return -1 - */ -static int -lio_dev_udp_tunnel_del(struct rte_eth_dev *eth_dev, - struct rte_eth_udp_tunnel *udp_tnl) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - if (udp_tnl == NULL) - return -EINVAL; - - if (udp_tnl->prot_type != RTE_ETH_TUNNEL_TYPE_VXLAN) { - lio_dev_err(lio_dev, "Unsupported tunnel type\n"); - return -1; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_VXLAN_PORT_CONFIG; - ctrl_pkt.ncmd.s.param1 = udp_tnl->udp_port; - ctrl_pkt.ncmd.s.more = LIO_CMD_VXLAN_PORT_DEL; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send VXLAN_PORT_DEL command\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "VXLAN_PORT_DEL command timed out\n"); - return -1; - } - - return 0; -} - -static int -lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - if (lio_dev->linfo.vlan_is_admin_assigned) - return -EPERM; - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = on ? - LIO_CMD_ADD_VLAN_FILTER : LIO_CMD_DEL_VLAN_FILTER; - ctrl_pkt.ncmd.s.param1 = vlan_id; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to %s VLAN port\n", - on ? "add" : "remove"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Command to %s VLAN port timed out\n", - on ? "add" : "remove"); - return -1; - } - - return 0; -} - -static uint64_t -lio_hweight64(uint64_t w) -{ - uint64_t res = w - ((w >> 1) & 0x5555555555555555ul); - - res = - (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); - res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; - res = res + (res >> 8); - res = res + (res >> 16); - - return (res + (res >> 32)) & 0x00000000000000FFul; -} - -static int -lio_dev_link_update(struct rte_eth_dev *eth_dev, - int wait_to_complete __rte_unused) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct rte_eth_link link; - - /* Initialize */ - memset(&link, 0, sizeof(link)); - link.link_status = RTE_ETH_LINK_DOWN; - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX; - link.link_autoneg = RTE_ETH_LINK_AUTONEG; - - /* Return what we found */ - if (lio_dev->linfo.link.s.link_up == 0) { - /* Interface is down */ - return rte_eth_linkstatus_set(eth_dev, &link); - } - - link.link_status = RTE_ETH_LINK_UP; /* Interface is up */ - link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - switch (lio_dev->linfo.link.s.speed) { - case LIO_LINK_SPEED_10000: - link.link_speed = RTE_ETH_SPEED_NUM_10G; - break; - case LIO_LINK_SPEED_25000: - link.link_speed = RTE_ETH_SPEED_NUM_25G; - break; - default: - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX; - } - - return rte_eth_linkstatus_set(eth_dev, &link); -} - -/** - * \brief Net device enable, disable allmulticast - * @param eth_dev Pointer to the structure rte_eth_dev - * - * @return - * On success return 0 - * On failure return negative errno - */ -static int -lio_change_dev_flag(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - /* Create a ctrl pkt command to be sent to core app. */ - ctrl_pkt.ncmd.s.cmd = LIO_CMD_CHANGE_DEVFLAGS; - ctrl_pkt.ncmd.s.param1 = lio_dev->ifflags; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send change flag message\n"); - return -EAGAIN; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Change dev flag command timed out\n"); - return -ETIMEDOUT; - } - - return 0; -} - -static int -lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) { - lio_dev_err(lio_dev, "Require firmware version >= %s\n", - LIO_VF_TRUST_MIN_VERSION); - return -EAGAIN; - } - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n", - lio_dev->port_id); - return -EAGAIN; - } - - lio_dev->ifflags |= LIO_IFFLAG_PROMISC; - return lio_change_dev_flag(eth_dev); -} - -static int -lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) { - lio_dev_err(lio_dev, "Require firmware version >= %s\n", - LIO_VF_TRUST_MIN_VERSION); - return -EAGAIN; - } - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n", - lio_dev->port_id); - return -EAGAIN; - } - - lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC; - return lio_change_dev_flag(eth_dev); -} - -static int -lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't enable multicast\n", - lio_dev->port_id); - return -EAGAIN; - } - - lio_dev->ifflags |= LIO_IFFLAG_ALLMULTI; - return lio_change_dev_flag(eth_dev); -} - -static int -lio_dev_allmulticast_disable(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (!lio_dev->intf_open) { - lio_dev_err(lio_dev, "Port %d down, can't disable multicast\n", - lio_dev->port_id); - return -EAGAIN; - } - - lio_dev->ifflags &= ~LIO_IFFLAG_ALLMULTI; - return lio_change_dev_flag(eth_dev); -} - -static void -lio_dev_rss_configure(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - struct rte_eth_rss_reta_entry64 reta_conf[8]; - struct rte_eth_rss_conf rss_conf; - uint16_t i; - - /* Configure the RSS key and the RSS protocols used to compute - * the RSS hash of input packets. - */ - rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf; - if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) { - rss_state->hash_disable = 1; - lio_dev_rss_hash_update(eth_dev, &rss_conf); - return; - } - - if (rss_conf.rss_key == NULL) - rss_conf.rss_key = lio_rss_key; /* Default hash key */ - - lio_dev_rss_hash_update(eth_dev, &rss_conf); - - memset(reta_conf, 0, sizeof(reta_conf)); - for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) { - uint8_t q_idx, conf_idx, reta_idx; - - q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ? - i % eth_dev->data->nb_rx_queues : 0); - conf_idx = i / RTE_ETH_RETA_GROUP_SIZE; - reta_idx = i % RTE_ETH_RETA_GROUP_SIZE; - reta_conf[conf_idx].reta[reta_idx] = q_idx; - reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx); - } - - lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ); -} - -static void -lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_rss_ctx *rss_state = &lio_dev->rss_state; - struct rte_eth_rss_conf rss_conf; - - switch (eth_dev->data->dev_conf.rxmode.mq_mode) { - case RTE_ETH_MQ_RX_RSS: - lio_dev_rss_configure(eth_dev); - break; - case RTE_ETH_MQ_RX_NONE: - /* if mq_mode is none, disable rss mode. */ - default: - memset(&rss_conf, 0, sizeof(rss_conf)); - rss_state->hash_disable = 1; - lio_dev_rss_hash_update(eth_dev, &rss_conf); - } -} - -/** - * Setup our receive queue/ringbuffer. This is the - * queue the Octeon uses to send us packets and - * responses. We are given a memory pool for our - * packet buffers that are used to populate the receive - * queue. - * - * @param eth_dev - * Pointer to the structure rte_eth_dev - * @param q_no - * Queue number - * @param num_rx_descs - * Number of entries in the queue - * @param socket_id - * Where to allocate memory - * @param rx_conf - * Pointer to the struction rte_eth_rxconf - * @param mp - * Pointer to the packet pool - * - * @return - * - On success, return 0 - * - On failure, return -1 - */ -static int -lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no, - uint16_t num_rx_descs, unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf __rte_unused, - struct rte_mempool *mp) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct rte_pktmbuf_pool_private *mbp_priv; - uint32_t fw_mapped_oq; - uint16_t buf_size; - - if (q_no >= lio_dev->nb_rx_queues) { - lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no); - return -EINVAL; - } - - lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no); - - fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no; - - /* Free previous allocation if any */ - if (eth_dev->data->rx_queues[q_no] != NULL) { - lio_dev_rx_queue_release(eth_dev, q_no); - eth_dev->data->rx_queues[q_no] = NULL; - } - - mbp_priv = rte_mempool_get_priv(mp); - buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM; - - if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp, - socket_id)) { - lio_dev_err(lio_dev, "droq allocation failed\n"); - return -1; - } - - eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq]; - - return 0; -} - -/** - * Release the receive queue/ringbuffer. Called by - * the upper layers. - * - * @param eth_dev - * Pointer to Ethernet device structure. - * @param q_no - * Receive queue index. - * - * @return - * - nothing - */ -void -lio_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t q_no) -{ - struct lio_droq *droq = dev->data->rx_queues[q_no]; - int oq_no; - - if (droq) { - oq_no = droq->q_no; - lio_delete_droq_queue(droq->lio_dev, oq_no); - } -} - -/** - * Allocate and initialize SW ring. Initialize associated HW registers. - * - * @param eth_dev - * Pointer to structure rte_eth_dev - * - * @param q_no - * Queue number - * - * @param num_tx_descs - * Number of ringbuffer descriptors - * - * @param socket_id - * NUMA socket id, used for memory allocations - * - * @param tx_conf - * Pointer to the structure rte_eth_txconf - * - * @return - * - On success, return 0 - * - On failure, return -errno value - */ -static int -lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no, - uint16_t num_tx_descs, unsigned int socket_id, - const struct rte_eth_txconf *tx_conf __rte_unused) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no; - int retval; - - if (q_no >= lio_dev->nb_tx_queues) { - lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no); - return -EINVAL; - } - - lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no); - - /* Free previous allocation if any */ - if (eth_dev->data->tx_queues[q_no] != NULL) { - lio_dev_tx_queue_release(eth_dev, q_no); - eth_dev->data->tx_queues[q_no] = NULL; - } - - retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no], - num_tx_descs, lio_dev, socket_id); - - if (retval) { - lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n"); - return retval; - } - - retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq, - lio_dev->instr_queue[fw_mapped_iq]->nb_desc, - socket_id); - - if (retval) { - lio_delete_instruction_queue(lio_dev, fw_mapped_iq); - return retval; - } - - eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq]; - - return 0; -} - -/** - * Release the transmit queue/ringbuffer. Called by - * the upper layers. - * - * @param eth_dev - * Pointer to Ethernet device structure. - * @param q_no - * Transmit queue index. - * - * @return - * - nothing - */ -void -lio_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_no) -{ - struct lio_instr_queue *tq = dev->data->tx_queues[q_no]; - uint32_t fw_mapped_iq_no; - - - if (tq) { - /* Free sg_list */ - lio_delete_sglist(tq); - - fw_mapped_iq_no = tq->txpciq.s.q_no; - lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no); - } -} - -/** - * Api to check link state. - */ -static void -lio_dev_get_link_status(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - uint16_t timeout = LIO_MAX_CMD_TIMEOUT; - struct lio_link_status_resp *resp; - union octeon_link_status *ls; - struct lio_soft_command *sc; - uint32_t resp_size; - - if (!lio_dev->intf_open) - return; - - resp_size = sizeof(struct lio_link_status_resp); - sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); - if (sc == NULL) - return; - - resp = (struct lio_link_status_resp *)sc->virtrptr; - lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, - LIO_OPCODE_INFO, 0, 0, 0); - - /* Setting wait time in seconds */ - sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; - - if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED) - goto get_status_fail; - - while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { - lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]); - rte_delay_ms(1); - } - - if (resp->status) - goto get_status_fail; - - ls = &resp->link_info.link; - - lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3); - - if (lio_dev->linfo.link.link_status64 != ls->link_status64) { - if (ls->s.mtu < eth_dev->data->mtu) { - lio_dev_info(lio_dev, "Lowered VF MTU to %d as PF MTU dropped\n", - ls->s.mtu); - eth_dev->data->mtu = ls->s.mtu; - } - lio_dev->linfo.link.link_status64 = ls->link_status64; - lio_dev_link_update(eth_dev, 0); - } - - lio_free_soft_command(sc); - - return; - -get_status_fail: - lio_free_soft_command(sc); -} - -/* This function will be invoked every LSC_TIMEOUT ns (100ms) - * and will update link state if it changes. - */ -static void -lio_sync_link_state_check(void *eth_dev) -{ - struct lio_device *lio_dev = - (((struct rte_eth_dev *)eth_dev)->data->dev_private); - - if (lio_dev->port_configured) - lio_dev_get_link_status(eth_dev); - - /* Schedule periodic link status check. - * Stop check if interface is close and start again while opening. - */ - if (lio_dev->intf_open) - rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check, - eth_dev); -} - -static int -lio_dev_start(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - uint16_t timeout = LIO_MAX_CMD_TIMEOUT; - int ret = 0; - - lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id); - - if (lio_dev->fn_list.enable_io_queues(lio_dev)) - return -1; - - if (lio_send_rx_ctrl_cmd(eth_dev, 1)) - return -1; - - /* Ready for link status updates */ - lio_dev->intf_open = 1; - rte_mb(); - - /* Configure RSS if device configured with multiple RX queues. */ - lio_dev_mq_rx_configure(eth_dev); - - /* Before update the link info, - * must set linfo.link.link_status64 to 0. - */ - lio_dev->linfo.link.link_status64 = 0; - - /* start polling for lsc */ - ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT, - lio_sync_link_state_check, - eth_dev); - if (ret) { - lio_dev_err(lio_dev, - "link state check handler creation failed\n"); - goto dev_lsc_handle_error; - } - - while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout)) - rte_delay_ms(1); - - if (lio_dev->linfo.link.link_status64 == 0) { - ret = -1; - goto dev_mtu_set_error; - } - - ret = lio_dev_mtu_set(eth_dev, eth_dev->data->mtu); - if (ret != 0) - goto dev_mtu_set_error; - - return 0; - -dev_mtu_set_error: - rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev); - -dev_lsc_handle_error: - lio_dev->intf_open = 0; - lio_send_rx_ctrl_cmd(eth_dev, 0); - - return ret; -} - -/* Stop device and disable input/output functions */ -static int -lio_dev_stop(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - lio_dev_info(lio_dev, "Stopping port %d\n", eth_dev->data->port_id); - eth_dev->data->dev_started = 0; - lio_dev->intf_open = 0; - rte_mb(); - - /* Cancel callback if still running. */ - rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev); - - lio_send_rx_ctrl_cmd(eth_dev, 0); - - lio_wait_for_instr_fetch(lio_dev); - - /* Clear recorded link status */ - lio_dev->linfo.link.link_status64 = 0; - - return 0; -} - -static int -lio_dev_set_link_up(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (!lio_dev->intf_open) { - lio_dev_info(lio_dev, "Port is stopped, Start the port first\n"); - return 0; - } - - if (lio_dev->linfo.link.s.link_up) { - lio_dev_info(lio_dev, "Link is already UP\n"); - return 0; - } - - if (lio_send_rx_ctrl_cmd(eth_dev, 1)) { - lio_dev_err(lio_dev, "Unable to set Link UP\n"); - return -1; - } - - lio_dev->linfo.link.s.link_up = 1; - eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; - - return 0; -} - -static int -lio_dev_set_link_down(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - if (!lio_dev->intf_open) { - lio_dev_info(lio_dev, "Port is stopped, Start the port first\n"); - return 0; - } - - if (!lio_dev->linfo.link.s.link_up) { - lio_dev_info(lio_dev, "Link is already DOWN\n"); - return 0; - } - - lio_dev->linfo.link.s.link_up = 0; - eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; - - if (lio_send_rx_ctrl_cmd(eth_dev, 0)) { - lio_dev->linfo.link.s.link_up = 1; - eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; - lio_dev_err(lio_dev, "Unable to set Link Down\n"); - return -1; - } - - return 0; -} - -/** - * Reset and stop the device. This occurs on the first - * call to this routine. Subsequent calls will simply - * return. NB: This will require the NIC to be rebooted. - * - * @param eth_dev - * Pointer to the structure rte_eth_dev - * - * @return - * - nothing - */ -static int -lio_dev_close(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - int ret = 0; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id); - - if (lio_dev->intf_open) - ret = lio_dev_stop(eth_dev); - - /* Reset ioq regs */ - lio_dev->fn_list.setup_device_regs(lio_dev); - - if (lio_dev->pci_dev->kdrv == RTE_PCI_KDRV_IGB_UIO) { - cn23xx_vf_ask_pf_to_do_flr(lio_dev); - rte_delay_ms(LIO_PCI_FLR_WAIT); - } - - /* lio_free_mbox */ - lio_dev->fn_list.free_mbox(lio_dev); - - /* Free glist resources */ - rte_free(lio_dev->glist_head); - rte_free(lio_dev->glist_lock); - lio_dev->glist_head = NULL; - lio_dev->glist_lock = NULL; - - lio_dev->port_configured = 0; - - /* Delete all queues */ - lio_dev_clear_queues(eth_dev); - - return ret; -} - -/** - * Enable tunnel rx checksum verification from firmware. - */ -static void -lio_enable_hw_tunnel_rx_checksum(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_RX_CSUM_CTL; - ctrl_pkt.ncmd.s.param1 = LIO_CMD_RXCSUM_ENABLE; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send TNL_RX_CSUM command\n"); - return; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) - lio_dev_err(lio_dev, "TNL_RX_CSUM command timed out\n"); -} - -/** - * Enable checksum calculation for inner packet in a tunnel. - */ -static void -lio_enable_hw_tunnel_tx_checksum(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_TNL_TX_CSUM_CTL; - ctrl_pkt.ncmd.s.param1 = LIO_CMD_TXCSUM_ENABLE; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send TNL_TX_CSUM command\n"); - return; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) - lio_dev_err(lio_dev, "TNL_TX_CSUM command timed out\n"); -} - -static int -lio_send_queue_count_update(struct rte_eth_dev *eth_dev, int num_txq, - int num_rxq) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct lio_dev_ctrl_cmd ctrl_cmd; - struct lio_ctrl_pkt ctrl_pkt; - - if (strcmp(lio_dev->firmware_version, LIO_Q_RECONF_MIN_VERSION) < 0) { - lio_dev_err(lio_dev, "Require firmware version >= %s\n", - LIO_Q_RECONF_MIN_VERSION); - return -ENOTSUP; - } - - /* flush added to prevent cmd failure - * incase the queue is full - */ - lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); - - memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); - memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); - - ctrl_cmd.eth_dev = eth_dev; - ctrl_cmd.cond = 0; - - ctrl_pkt.ncmd.s.cmd = LIO_CMD_QUEUE_COUNT_CTL; - ctrl_pkt.ncmd.s.param1 = num_txq; - ctrl_pkt.ncmd.s.param2 = num_rxq; - ctrl_pkt.ctrl_cmd = &ctrl_cmd; - - if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { - lio_dev_err(lio_dev, "Failed to send queue count control command\n"); - return -1; - } - - if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { - lio_dev_err(lio_dev, "Queue count control command timed out\n"); - return -1; - } - - return 0; -} - -static int -lio_reconf_queues(struct rte_eth_dev *eth_dev, int num_txq, int num_rxq) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - int ret; - - if (lio_dev->nb_rx_queues != num_rxq || - lio_dev->nb_tx_queues != num_txq) { - if (lio_send_queue_count_update(eth_dev, num_txq, num_rxq)) - return -1; - lio_dev->nb_rx_queues = num_rxq; - lio_dev->nb_tx_queues = num_txq; - } - - if (lio_dev->intf_open) { - ret = lio_dev_stop(eth_dev); - if (ret != 0) - return ret; - } - - /* Reset ioq registers */ - if (lio_dev->fn_list.setup_device_regs(lio_dev)) { - lio_dev_err(lio_dev, "Failed to configure device registers\n"); - return -1; - } - - return 0; -} - -static int -lio_dev_configure(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - uint16_t timeout = LIO_MAX_CMD_TIMEOUT; - int retval, num_iqueues, num_oqueues; - uint8_t mac[RTE_ETHER_ADDR_LEN], i; - struct lio_if_cfg_resp *resp; - struct lio_soft_command *sc; - union lio_if_cfg if_cfg; - uint32_t resp_size; - - PMD_INIT_FUNC_TRACE(); - - if (eth_dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) - eth_dev->data->dev_conf.rxmode.offloads |= - RTE_ETH_RX_OFFLOAD_RSS_HASH; - - /* Inform firmware about change in number of queues to use. - * Disable IO queues and reset registers for re-configuration. - */ - if (lio_dev->port_configured) - return lio_reconf_queues(eth_dev, - eth_dev->data->nb_tx_queues, - eth_dev->data->nb_rx_queues); - - lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues; - lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues; - - /* Set max number of queues which can be re-configured. */ - lio_dev->max_rx_queues = eth_dev->data->nb_rx_queues; - lio_dev->max_tx_queues = eth_dev->data->nb_tx_queues; - - resp_size = sizeof(struct lio_if_cfg_resp); - sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); - if (sc == NULL) - return -ENOMEM; - - resp = (struct lio_if_cfg_resp *)sc->virtrptr; - - /* Firmware doesn't have capability to reconfigure the queues, - * Claim all queues, and use as many required - */ - if_cfg.if_cfg64 = 0; - if_cfg.s.num_iqueues = lio_dev->nb_tx_queues; - if_cfg.s.num_oqueues = lio_dev->nb_rx_queues; - if_cfg.s.base_queue = 0; - - if_cfg.s.gmx_port_id = lio_dev->pf_num; - - lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, - LIO_OPCODE_IF_CFG, 0, - if_cfg.if_cfg64, 0); - - /* Setting wait time in seconds */ - sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; - - retval = lio_send_soft_command(lio_dev, sc); - if (retval == LIO_IQ_SEND_FAILED) { - lio_dev_err(lio_dev, "iq/oq config failed status: %x\n", - retval); - /* Soft instr is freed by driver in case of failure. */ - goto nic_config_fail; - } - - /* Sleep on a wait queue till the cond flag indicates that the - * response arrived or timed-out. - */ - while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { - lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]); - lio_process_ordered_list(lio_dev); - rte_delay_ms(1); - } - - retval = resp->status; - if (retval) { - lio_dev_err(lio_dev, "iq/oq config failed\n"); - goto nic_config_fail; - } - - strlcpy(lio_dev->firmware_version, - resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH); - - lio_swap_8B_data((uint64_t *)(&resp->cfg_info), - sizeof(struct octeon_if_cfg_info) >> 3); - - num_iqueues = lio_hweight64(resp->cfg_info.iqmask); - num_oqueues = lio_hweight64(resp->cfg_info.oqmask); - - if (!(num_iqueues) || !(num_oqueues)) { - lio_dev_err(lio_dev, - "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n", - (unsigned long)resp->cfg_info.iqmask, - (unsigned long)resp->cfg_info.oqmask); - goto nic_config_fail; - } - - lio_dev_dbg(lio_dev, - "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n", - eth_dev->data->port_id, - (unsigned long)resp->cfg_info.iqmask, - (unsigned long)resp->cfg_info.oqmask, - num_iqueues, num_oqueues); - - lio_dev->linfo.num_rxpciq = num_oqueues; - lio_dev->linfo.num_txpciq = num_iqueues; - - for (i = 0; i < num_oqueues; i++) { - lio_dev->linfo.rxpciq[i].rxpciq64 = - resp->cfg_info.linfo.rxpciq[i].rxpciq64; - lio_dev_dbg(lio_dev, "index %d OQ %d\n", - i, lio_dev->linfo.rxpciq[i].s.q_no); - } - - for (i = 0; i < num_iqueues; i++) { - lio_dev->linfo.txpciq[i].txpciq64 = - resp->cfg_info.linfo.txpciq[i].txpciq64; - lio_dev_dbg(lio_dev, "index %d IQ %d\n", - i, lio_dev->linfo.txpciq[i].s.q_no); - } - - lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr; - lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport; - lio_dev->linfo.link.link_status64 = - resp->cfg_info.linfo.link.link_status64; - - /* 64-bit swap required on LE machines */ - lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1); - for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) - mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) + - 2 + i)); - - /* Copy the permanent MAC address */ - rte_ether_addr_copy((struct rte_ether_addr *)mac, - ð_dev->data->mac_addrs[0]); - - /* enable firmware checksum support for tunnel packets */ - lio_enable_hw_tunnel_rx_checksum(eth_dev); - lio_enable_hw_tunnel_tx_checksum(eth_dev); - - lio_dev->glist_lock = - rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0); - if (lio_dev->glist_lock == NULL) - return -ENOMEM; - - lio_dev->glist_head = - rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues, - 0); - if (lio_dev->glist_head == NULL) { - rte_free(lio_dev->glist_lock); - lio_dev->glist_lock = NULL; - return -ENOMEM; - } - - lio_dev_link_update(eth_dev, 0); - - lio_dev->port_configured = 1; - - lio_free_soft_command(sc); - - /* Reset ioq regs */ - lio_dev->fn_list.setup_device_regs(lio_dev); - - /* Free iq_0 used during init */ - lio_free_instr_queue0(lio_dev); - - return 0; - -nic_config_fail: - lio_dev_err(lio_dev, "Failed retval %d\n", retval); - lio_free_soft_command(sc); - lio_free_instr_queue0(lio_dev); - - return -ENODEV; -} - -/* Define our ethernet definitions */ -static const struct eth_dev_ops liovf_eth_dev_ops = { - .dev_configure = lio_dev_configure, - .dev_start = lio_dev_start, - .dev_stop = lio_dev_stop, - .dev_set_link_up = lio_dev_set_link_up, - .dev_set_link_down = lio_dev_set_link_down, - .dev_close = lio_dev_close, - .promiscuous_enable = lio_dev_promiscuous_enable, - .promiscuous_disable = lio_dev_promiscuous_disable, - .allmulticast_enable = lio_dev_allmulticast_enable, - .allmulticast_disable = lio_dev_allmulticast_disable, - .link_update = lio_dev_link_update, - .stats_get = lio_dev_stats_get, - .xstats_get = lio_dev_xstats_get, - .xstats_get_names = lio_dev_xstats_get_names, - .stats_reset = lio_dev_stats_reset, - .xstats_reset = lio_dev_xstats_reset, - .dev_infos_get = lio_dev_info_get, - .vlan_filter_set = lio_dev_vlan_filter_set, - .rx_queue_setup = lio_dev_rx_queue_setup, - .rx_queue_release = lio_dev_rx_queue_release, - .tx_queue_setup = lio_dev_tx_queue_setup, - .tx_queue_release = lio_dev_tx_queue_release, - .reta_update = lio_dev_rss_reta_update, - .reta_query = lio_dev_rss_reta_query, - .rss_hash_conf_get = lio_dev_rss_hash_conf_get, - .rss_hash_update = lio_dev_rss_hash_update, - .udp_tunnel_port_add = lio_dev_udp_tunnel_add, - .udp_tunnel_port_del = lio_dev_udp_tunnel_del, - .mtu_set = lio_dev_mtu_set, -}; - -static void -lio_check_pf_hs_response(void *lio_dev) -{ - struct lio_device *dev = lio_dev; - - /* check till response arrives */ - if (dev->pfvf_hsword.coproc_tics_per_us) - return; - - cn23xx_vf_handle_mbox(dev); - - rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev); -} - -/** - * \brief Identify the LIO device and to map the BAR address space - * @param lio_dev lio device - */ -static int -lio_chip_specific_setup(struct lio_device *lio_dev) -{ - struct rte_pci_device *pdev = lio_dev->pci_dev; - uint32_t dev_id = pdev->id.device_id; - const char *s; - int ret = 1; - - switch (dev_id) { - case LIO_CN23XX_VF_VID: - lio_dev->chip_id = LIO_CN23XX_VF_VID; - ret = cn23xx_vf_setup_device(lio_dev); - s = "CN23XX VF"; - break; - default: - s = "?"; - lio_dev_err(lio_dev, "Unsupported Chip\n"); - } - - if (!ret) - lio_dev_info(lio_dev, "DEVICE : %s\n", s); - - return ret; -} - -static int -lio_first_time_init(struct lio_device *lio_dev, - struct rte_pci_device *pdev) -{ - int dpdk_queues; - - PMD_INIT_FUNC_TRACE(); - - /* set dpdk specific pci device pointer */ - lio_dev->pci_dev = pdev; - - /* Identify the LIO type and set device ops */ - if (lio_chip_specific_setup(lio_dev)) { - lio_dev_err(lio_dev, "Chip specific setup failed\n"); - return -1; - } - - /* Initialize soft command buffer pool */ - if (lio_setup_sc_buffer_pool(lio_dev)) { - lio_dev_err(lio_dev, "sc buffer pool allocation failed\n"); - return -1; - } - - /* Initialize lists to manage the requests of different types that - * arrive from applications for this lio device. - */ - lio_setup_response_list(lio_dev); - - if (lio_dev->fn_list.setup_mbox(lio_dev)) { - lio_dev_err(lio_dev, "Mailbox setup failed\n"); - goto error; - } - - /* Check PF response */ - lio_check_pf_hs_response((void *)lio_dev); - - /* Do handshake and exit if incompatible PF driver */ - if (cn23xx_pfvf_handshake(lio_dev)) - goto error; - - /* Request and wait for device reset. */ - if (pdev->kdrv == RTE_PCI_KDRV_IGB_UIO) { - cn23xx_vf_ask_pf_to_do_flr(lio_dev); - /* FLR wait time doubled as a precaution. */ - rte_delay_ms(LIO_PCI_FLR_WAIT * 2); - } - - if (lio_dev->fn_list.setup_device_regs(lio_dev)) { - lio_dev_err(lio_dev, "Failed to configure device registers\n"); - goto error; - } - - if (lio_setup_instr_queue0(lio_dev)) { - lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n"); - goto error; - } - - dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf; - - lio_dev->max_tx_queues = dpdk_queues; - lio_dev->max_rx_queues = dpdk_queues; - - /* Enable input and output queues for this device */ - if (lio_dev->fn_list.enable_io_queues(lio_dev)) - goto error; - - return 0; - -error: - lio_free_sc_buffer_pool(lio_dev); - if (lio_dev->mbox[0]) - lio_dev->fn_list.free_mbox(lio_dev); - if (lio_dev->instr_queue[0]) - lio_free_instr_queue0(lio_dev); - - return -1; -} - -static int -lio_eth_dev_uninit(struct rte_eth_dev *eth_dev) -{ - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - /* lio_free_sc_buffer_pool */ - lio_free_sc_buffer_pool(lio_dev); - - return 0; -} - -static int -lio_eth_dev_init(struct rte_eth_dev *eth_dev) -{ - struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev); - struct lio_device *lio_dev = LIO_DEV(eth_dev); - - PMD_INIT_FUNC_TRACE(); - - eth_dev->rx_pkt_burst = &lio_dev_recv_pkts; - eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts; - - /* Primary does the initialization. */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - rte_eth_copy_pci_info(eth_dev, pdev); - - if (pdev->mem_resource[0].addr) { - lio_dev->hw_addr = pdev->mem_resource[0].addr; - } else { - PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n"); - return -ENODEV; - } - - lio_dev->eth_dev = eth_dev; - /* set lio device print string */ - snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string), - "%s[%02x:%02x.%x]", pdev->driver->driver.name, - pdev->addr.bus, pdev->addr.devid, pdev->addr.function); - - lio_dev->port_id = eth_dev->data->port_id; - - if (lio_first_time_init(lio_dev, pdev)) { - lio_dev_err(lio_dev, "Device init failed\n"); - return -EINVAL; - } - - eth_dev->dev_ops = &liovf_eth_dev_ops; - eth_dev->data->mac_addrs = rte_zmalloc("lio", RTE_ETHER_ADDR_LEN, 0); - if (eth_dev->data->mac_addrs == NULL) { - lio_dev_err(lio_dev, - "MAC addresses memory allocation failed\n"); - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - return -ENOMEM; - } - - rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING); - rte_wmb(); - - lio_dev->port_configured = 0; - /* Always allow unicast packets */ - lio_dev->ifflags |= LIO_IFFLAG_UNICAST; - - return 0; -} - -static int -lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev) -{ - return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device), - lio_eth_dev_init); -} - -static int -lio_eth_dev_pci_remove(struct rte_pci_device *pci_dev) -{ - return rte_eth_dev_pci_generic_remove(pci_dev, - lio_eth_dev_uninit); -} - -/* Set of PCI devices this driver supports */ -static const struct rte_pci_id pci_id_liovf_map[] = { - { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) }, - { .vendor_id = 0, /* sentinel */ } -}; - -static struct rte_pci_driver rte_liovf_pmd = { - .id_table = pci_id_liovf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, - .probe = lio_eth_dev_pci_probe, - .remove = lio_eth_dev_pci_remove, -}; - -RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd); -RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map); -RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci"); -RTE_LOG_REGISTER_SUFFIX(lio_logtype_init, init, NOTICE); -RTE_LOG_REGISTER_SUFFIX(lio_logtype_driver, driver, NOTICE); diff --git a/dpdk/drivers/net/liquidio/lio_ethdev.h b/dpdk/drivers/net/liquidio/lio_ethdev.h deleted file mode 100644 index ece2b0385..000000000 --- a/dpdk/drivers/net/liquidio/lio_ethdev.h +++ /dev/null @@ -1,179 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_ETHDEV_H_ -#define _LIO_ETHDEV_H_ - -#include - -#include "lio_struct.h" - -/* timeout to check link state updates from firmware in us */ -#define LIO_LSC_TIMEOUT 100000 /* 100000us (100ms) */ -#define LIO_MAX_CMD_TIMEOUT 10000 /* 10000ms (10s) */ - -/* The max frame size with default MTU */ -#define LIO_ETH_MAX_LEN (RTE_ETHER_MTU + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN) - -#define LIO_DEV(_eth_dev) ((_eth_dev)->data->dev_private) - -/* LIO Response condition variable */ -struct lio_dev_ctrl_cmd { - struct rte_eth_dev *eth_dev; - uint64_t cond; -}; - -enum lio_bus_speed { - LIO_LINK_SPEED_UNKNOWN = 0, - LIO_LINK_SPEED_10000 = 10000, - LIO_LINK_SPEED_25000 = 25000 -}; - -struct octeon_if_cfg_info { - uint64_t iqmask; /** mask for IQs enabled for the port */ - uint64_t oqmask; /** mask for OQs enabled for the port */ - struct octeon_link_info linfo; /** initial link information */ - char lio_firmware_version[LIO_FW_VERSION_LENGTH]; -}; - -/** Stats for each NIC port in RX direction. */ -struct octeon_rx_stats { - /* link-level stats */ - uint64_t total_rcvd; - uint64_t bytes_rcvd; - uint64_t total_bcst; - uint64_t total_mcst; - uint64_t runts; - uint64_t ctl_rcvd; - uint64_t fifo_err; /* Accounts for over/under-run of buffers */ - uint64_t dmac_drop; - uint64_t fcs_err; - uint64_t jabber_err; - uint64_t l2_err; - uint64_t frame_err; - - /* firmware stats */ - uint64_t fw_total_rcvd; - uint64_t fw_total_fwd; - uint64_t fw_total_fwd_bytes; - uint64_t fw_err_pko; - uint64_t fw_err_link; - uint64_t fw_err_drop; - uint64_t fw_rx_vxlan; - uint64_t fw_rx_vxlan_err; - - /* LRO */ - uint64_t fw_lro_pkts; /* Number of packets that are LROed */ - uint64_t fw_lro_octs; /* Number of octets that are LROed */ - uint64_t fw_total_lro; /* Number of LRO packets formed */ - uint64_t fw_lro_aborts; /* Number of times lRO of packet aborted */ - uint64_t fw_lro_aborts_port; - uint64_t fw_lro_aborts_seq; - uint64_t fw_lro_aborts_tsval; - uint64_t fw_lro_aborts_timer; - /* intrmod: packet forward rate */ - uint64_t fwd_rate; -}; - -/** Stats for each NIC port in RX direction. */ -struct octeon_tx_stats { - /* link-level stats */ - uint64_t total_pkts_sent; - uint64_t total_bytes_sent; - uint64_t mcast_pkts_sent; - uint64_t bcast_pkts_sent; - uint64_t ctl_sent; - uint64_t one_collision_sent; /* Packets sent after one collision */ - /* Packets sent after multiple collision */ - uint64_t multi_collision_sent; - /* Packets not sent due to max collisions */ - uint64_t max_collision_fail; - /* Packets not sent due to max deferrals */ - uint64_t max_deferral_fail; - /* Accounts for over/under-run of buffers */ - uint64_t fifo_err; - uint64_t runts; - uint64_t total_collisions; /* Total number of collisions detected */ - - /* firmware stats */ - uint64_t fw_total_sent; - uint64_t fw_total_fwd; - uint64_t fw_total_fwd_bytes; - uint64_t fw_err_pko; - uint64_t fw_err_link; - uint64_t fw_err_drop; - uint64_t fw_err_tso; - uint64_t fw_tso; /* number of tso requests */ - uint64_t fw_tso_fwd; /* number of packets segmented in tso */ - uint64_t fw_tx_vxlan; -}; - -struct octeon_link_stats { - struct octeon_rx_stats fromwire; - struct octeon_tx_stats fromhost; -}; - -union lio_if_cfg { - uint64_t if_cfg64; - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t base_queue : 16; - uint64_t num_iqueues : 16; - uint64_t num_oqueues : 16; - uint64_t gmx_port_id : 8; - uint64_t vf_id : 8; -#else - uint64_t vf_id : 8; - uint64_t gmx_port_id : 8; - uint64_t num_oqueues : 16; - uint64_t num_iqueues : 16; - uint64_t base_queue : 16; -#endif - } s; -}; - -struct lio_if_cfg_resp { - uint64_t rh; - struct octeon_if_cfg_info cfg_info; - uint64_t status; -}; - -struct lio_link_stats_resp { - uint64_t rh; - struct octeon_link_stats link_stats; - uint64_t status; -}; - -struct lio_link_status_resp { - uint64_t rh; - struct octeon_link_info link_info; - uint64_t status; -}; - -struct lio_rss_set { - struct param { -#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - uint64_t flags : 16; - uint64_t hashinfo : 32; - uint64_t itablesize : 16; - uint64_t hashkeysize : 16; - uint64_t reserved : 48; -#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t itablesize : 16; - uint64_t hashinfo : 32; - uint64_t flags : 16; - uint64_t reserved : 48; - uint64_t hashkeysize : 16; -#endif - } param; - - uint8_t itable[LIO_RSS_MAX_TABLE_SZ]; - uint8_t key[LIO_RSS_MAX_KEY_SZ]; -}; - -void lio_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t q_no); - -void lio_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_no); - -#endif /* _LIO_ETHDEV_H_ */ diff --git a/dpdk/drivers/net/liquidio/lio_logs.h b/dpdk/drivers/net/liquidio/lio_logs.h deleted file mode 100644 index f22782708..000000000 --- a/dpdk/drivers/net/liquidio/lio_logs.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_LOGS_H_ -#define _LIO_LOGS_H_ - -extern int lio_logtype_driver; -#define lio_dev_printf(lio_dev, level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, lio_logtype_driver, \ - "%s" fmt, (lio_dev)->dev_string, ##args) - -#define lio_dev_info(lio_dev, fmt, args...) \ - lio_dev_printf(lio_dev, INFO, "INFO: " fmt, ##args) - -#define lio_dev_err(lio_dev, fmt, args...) \ - lio_dev_printf(lio_dev, ERR, "ERROR: %s() " fmt, __func__, ##args) - -extern int lio_logtype_init; -#define PMD_INIT_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, lio_logtype_init, \ - fmt, ## args) - -/* Enable these through config options */ -#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, "%s() >>\n", __func__) - -#define lio_dev_dbg(lio_dev, fmt, args...) \ - lio_dev_printf(lio_dev, DEBUG, "DEBUG: %s() " fmt, __func__, ##args) - -#ifdef RTE_LIBRTE_LIO_DEBUG_RX -#define PMD_RX_LOG(lio_dev, level, fmt, args...) \ - lio_dev_printf(lio_dev, level, "RX: %s() " fmt, __func__, ##args) -#else /* !RTE_LIBRTE_LIO_DEBUG_RX */ -#define PMD_RX_LOG(lio_dev, level, fmt, args...) do { } while (0) -#endif /* RTE_LIBRTE_LIO_DEBUG_RX */ - -#ifdef RTE_LIBRTE_LIO_DEBUG_TX -#define PMD_TX_LOG(lio_dev, level, fmt, args...) \ - lio_dev_printf(lio_dev, level, "TX: %s() " fmt, __func__, ##args) -#else /* !RTE_LIBRTE_LIO_DEBUG_TX */ -#define PMD_TX_LOG(lio_dev, level, fmt, args...) do { } while (0) -#endif /* RTE_LIBRTE_LIO_DEBUG_TX */ - -#ifdef RTE_LIBRTE_LIO_DEBUG_MBOX -#define PMD_MBOX_LOG(lio_dev, level, fmt, args...) \ - lio_dev_printf(lio_dev, level, "MBOX: %s() " fmt, __func__, ##args) -#else /* !RTE_LIBRTE_LIO_DEBUG_MBOX */ -#define PMD_MBOX_LOG(level, fmt, args...) do { } while (0) -#endif /* RTE_LIBRTE_LIO_DEBUG_MBOX */ - -#ifdef RTE_LIBRTE_LIO_DEBUG_REGS -#define PMD_REGS_LOG(lio_dev, fmt, args...) \ - lio_dev_printf(lio_dev, DEBUG, "REGS: " fmt, ##args) -#else /* !RTE_LIBRTE_LIO_DEBUG_REGS */ -#define PMD_REGS_LOG(level, fmt, args...) do { } while (0) -#endif /* RTE_LIBRTE_LIO_DEBUG_REGS */ - -#endif /* _LIO_LOGS_H_ */ diff --git a/dpdk/drivers/net/liquidio/lio_rxtx.c b/dpdk/drivers/net/liquidio/lio_rxtx.c deleted file mode 100644 index e09798ddd..000000000 --- a/dpdk/drivers/net/liquidio/lio_rxtx.c +++ /dev/null @@ -1,1804 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#include -#include -#include - -#include "lio_logs.h" -#include "lio_struct.h" -#include "lio_ethdev.h" -#include "lio_rxtx.h" - -#define LIO_MAX_SG 12 -/* Flush iq if available tx_desc fall below LIO_FLUSH_WM */ -#define LIO_FLUSH_WM(_iq) ((_iq)->nb_desc / 2) -#define LIO_PKT_IN_DONE_CNT_MASK 0x00000000FFFFFFFFULL - -static void -lio_droq_compute_max_packet_bufs(struct lio_droq *droq) -{ - uint32_t count = 0; - - do { - count += droq->buffer_size; - } while (count < LIO_MAX_RX_PKTLEN); -} - -static void -lio_droq_reset_indices(struct lio_droq *droq) -{ - droq->read_idx = 0; - droq->write_idx = 0; - droq->refill_idx = 0; - droq->refill_count = 0; - rte_atomic64_set(&droq->pkts_pending, 0); -} - -static void -lio_droq_destroy_ring_buffers(struct lio_droq *droq) -{ - uint32_t i; - - for (i = 0; i < droq->nb_desc; i++) { - if (droq->recv_buf_list[i].buffer) { - rte_pktmbuf_free((struct rte_mbuf *) - droq->recv_buf_list[i].buffer); - droq->recv_buf_list[i].buffer = NULL; - } - } - - lio_droq_reset_indices(droq); -} - -static int -lio_droq_setup_ring_buffers(struct lio_device *lio_dev, - struct lio_droq *droq) -{ - struct lio_droq_desc *desc_ring = droq->desc_ring; - uint32_t i; - void *buf; - - for (i = 0; i < droq->nb_desc; i++) { - buf = rte_pktmbuf_alloc(droq->mpool); - if (buf == NULL) { - lio_dev_err(lio_dev, "buffer alloc failed\n"); - droq->stats.rx_alloc_failure++; - lio_droq_destroy_ring_buffers(droq); - return -ENOMEM; - } - - droq->recv_buf_list[i].buffer = buf; - droq->info_list[i].length = 0; - - /* map ring buffers into memory */ - desc_ring[i].info_ptr = lio_map_ring_info(droq, i); - desc_ring[i].buffer_ptr = - lio_map_ring(droq->recv_buf_list[i].buffer); - } - - lio_droq_reset_indices(droq); - - lio_droq_compute_max_packet_bufs(droq); - - return 0; -} - -static void -lio_dma_zone_free(struct lio_device *lio_dev, const struct rte_memzone *mz) -{ - const struct rte_memzone *mz_tmp; - int ret = 0; - - if (mz == NULL) { - lio_dev_err(lio_dev, "Memzone NULL\n"); - return; - } - - mz_tmp = rte_memzone_lookup(mz->name); - if (mz_tmp == NULL) { - lio_dev_err(lio_dev, "Memzone %s Not Found\n", mz->name); - return; - } - - ret = rte_memzone_free(mz); - if (ret) - lio_dev_err(lio_dev, "Memzone free Failed ret %d\n", ret); -} - -/** - * Frees the space for descriptor ring for the droq. - * - * @param lio_dev - pointer to the lio device structure - * @param q_no - droq no. - */ -static void -lio_delete_droq(struct lio_device *lio_dev, uint32_t q_no) -{ - struct lio_droq *droq = lio_dev->droq[q_no]; - - lio_dev_dbg(lio_dev, "OQ[%d]\n", q_no); - - lio_droq_destroy_ring_buffers(droq); - rte_free(droq->recv_buf_list); - droq->recv_buf_list = NULL; - lio_dma_zone_free(lio_dev, droq->info_mz); - lio_dma_zone_free(lio_dev, droq->desc_ring_mz); - - memset(droq, 0, LIO_DROQ_SIZE); -} - -static void * -lio_alloc_info_buffer(struct lio_device *lio_dev, - struct lio_droq *droq, unsigned int socket_id) -{ - droq->info_mz = rte_eth_dma_zone_reserve(lio_dev->eth_dev, - "info_list", droq->q_no, - (droq->nb_desc * - LIO_DROQ_INFO_SIZE), - RTE_CACHE_LINE_SIZE, - socket_id); - - if (droq->info_mz == NULL) - return NULL; - - droq->info_list_dma = droq->info_mz->iova; - droq->info_alloc_size = droq->info_mz->len; - droq->info_base_addr = (size_t)droq->info_mz->addr; - - return droq->info_mz->addr; -} - -/** - * Allocates space for the descriptor ring for the droq and - * sets the base addr, num desc etc in Octeon registers. - * - * @param lio_dev - pointer to the lio device structure - * @param q_no - droq no. - * @param app_ctx - pointer to application context - * @return Success: 0 Failure: -1 - */ -static int -lio_init_droq(struct lio_device *lio_dev, uint32_t q_no, - uint32_t num_descs, uint32_t desc_size, - struct rte_mempool *mpool, unsigned int socket_id) -{ - uint32_t c_refill_threshold; - uint32_t desc_ring_size; - struct lio_droq *droq; - - lio_dev_dbg(lio_dev, "OQ[%d]\n", q_no); - - droq = lio_dev->droq[q_no]; - droq->lio_dev = lio_dev; - droq->q_no = q_no; - droq->mpool = mpool; - - c_refill_threshold = LIO_OQ_REFILL_THRESHOLD_CFG(lio_dev); - - droq->nb_desc = num_descs; - droq->buffer_size = desc_size; - - desc_ring_size = droq->nb_desc * LIO_DROQ_DESC_SIZE; - droq->desc_ring_mz = rte_eth_dma_zone_reserve(lio_dev->eth_dev, - "droq", q_no, - desc_ring_size, - RTE_CACHE_LINE_SIZE, - socket_id); - - if (droq->desc_ring_mz == NULL) { - lio_dev_err(lio_dev, - "Output queue %d ring alloc failed\n", q_no); - return -1; - } - - droq->desc_ring_dma = droq->desc_ring_mz->iova; - droq->desc_ring = (struct lio_droq_desc *)droq->desc_ring_mz->addr; - - lio_dev_dbg(lio_dev, "droq[%d]: desc_ring: virt: 0x%p, dma: %lx\n", - q_no, droq->desc_ring, (unsigned long)droq->desc_ring_dma); - lio_dev_dbg(lio_dev, "droq[%d]: num_desc: %d\n", q_no, - droq->nb_desc); - - droq->info_list = lio_alloc_info_buffer(lio_dev, droq, socket_id); - if (droq->info_list == NULL) { - lio_dev_err(lio_dev, "Cannot allocate memory for info list.\n"); - goto init_droq_fail; - } - - droq->recv_buf_list = rte_zmalloc_socket("recv_buf_list", - (droq->nb_desc * - LIO_DROQ_RECVBUF_SIZE), - RTE_CACHE_LINE_SIZE, - socket_id); - if (droq->recv_buf_list == NULL) { - lio_dev_err(lio_dev, - "Output queue recv buf list alloc failed\n"); - goto init_droq_fail; - } - - if (lio_droq_setup_ring_buffers(lio_dev, droq)) - goto init_droq_fail; - - droq->refill_threshold = c_refill_threshold; - - rte_spinlock_init(&droq->lock); - - lio_dev->fn_list.setup_oq_regs(lio_dev, q_no); - - lio_dev->io_qmask.oq |= (1ULL << q_no); - - return 0; - -init_droq_fail: - lio_delete_droq(lio_dev, q_no); - - return -1; -} - -int -lio_setup_droq(struct lio_device *lio_dev, int oq_no, int num_descs, - int desc_size, struct rte_mempool *mpool, unsigned int socket_id) -{ - struct lio_droq *droq; - - PMD_INIT_FUNC_TRACE(); - - /* Allocate the DS for the new droq. */ - droq = rte_zmalloc_socket("ethdev RX queue", sizeof(*droq), - RTE_CACHE_LINE_SIZE, socket_id); - if (droq == NULL) - return -ENOMEM; - - lio_dev->droq[oq_no] = droq; - - /* Initialize the Droq */ - if (lio_init_droq(lio_dev, oq_no, num_descs, desc_size, mpool, - socket_id)) { - lio_dev_err(lio_dev, "Droq[%u] Initialization Failed\n", oq_no); - rte_free(lio_dev->droq[oq_no]); - lio_dev->droq[oq_no] = NULL; - return -ENOMEM; - } - - lio_dev->num_oqs++; - - lio_dev_dbg(lio_dev, "Total number of OQ: %d\n", lio_dev->num_oqs); - - /* Send credit for octeon output queues. credits are always - * sent after the output queue is enabled. - */ - rte_write32(lio_dev->droq[oq_no]->nb_desc, - lio_dev->droq[oq_no]->pkts_credit_reg); - rte_wmb(); - - return 0; -} - -static inline uint32_t -lio_droq_get_bufcount(uint32_t buf_size, uint32_t total_len) -{ - uint32_t buf_cnt = 0; - - while (total_len > (buf_size * buf_cnt)) - buf_cnt++; - - return buf_cnt; -} - -/* If we were not able to refill all buffers, try to move around - * the buffers that were not dispatched. - */ -static inline uint32_t -lio_droq_refill_pullup_descs(struct lio_droq *droq, - struct lio_droq_desc *desc_ring) -{ - uint32_t refill_index = droq->refill_idx; - uint32_t desc_refilled = 0; - - while (refill_index != droq->read_idx) { - if (droq->recv_buf_list[refill_index].buffer) { - droq->recv_buf_list[droq->refill_idx].buffer = - droq->recv_buf_list[refill_index].buffer; - desc_ring[droq->refill_idx].buffer_ptr = - desc_ring[refill_index].buffer_ptr; - droq->recv_buf_list[refill_index].buffer = NULL; - desc_ring[refill_index].buffer_ptr = 0; - do { - droq->refill_idx = lio_incr_index( - droq->refill_idx, 1, - droq->nb_desc); - desc_refilled++; - droq->refill_count--; - } while (droq->recv_buf_list[droq->refill_idx].buffer); - } - refill_index = lio_incr_index(refill_index, 1, - droq->nb_desc); - } /* while */ - - return desc_refilled; -} - -/* lio_droq_refill - * - * @param droq - droq in which descriptors require new buffers. - * - * Description: - * Called during normal DROQ processing in interrupt mode or by the poll - * thread to refill the descriptors from which buffers were dispatched - * to upper layers. Attempts to allocate new buffers. If that fails, moves - * up buffers (that were not dispatched) to form a contiguous ring. - * - * Returns: - * No of descriptors refilled. - * - * Locks: - * This routine is called with droq->lock held. - */ -static uint32_t -lio_droq_refill(struct lio_droq *droq) -{ - struct lio_droq_desc *desc_ring; - uint32_t desc_refilled = 0; - void *buf = NULL; - - desc_ring = droq->desc_ring; - - while (droq->refill_count && (desc_refilled < droq->nb_desc)) { - /* If a valid buffer exists (happens if there is no dispatch), - * reuse the buffer, else allocate. - */ - if (droq->recv_buf_list[droq->refill_idx].buffer == NULL) { - buf = rte_pktmbuf_alloc(droq->mpool); - /* If a buffer could not be allocated, no point in - * continuing - */ - if (buf == NULL) { - droq->stats.rx_alloc_failure++; - break; - } - - droq->recv_buf_list[droq->refill_idx].buffer = buf; - } - - desc_ring[droq->refill_idx].buffer_ptr = - lio_map_ring(droq->recv_buf_list[droq->refill_idx].buffer); - /* Reset any previous values in the length field. */ - droq->info_list[droq->refill_idx].length = 0; - - droq->refill_idx = lio_incr_index(droq->refill_idx, 1, - droq->nb_desc); - desc_refilled++; - droq->refill_count--; - } - - if (droq->refill_count) - desc_refilled += lio_droq_refill_pullup_descs(droq, desc_ring); - - /* if droq->refill_count - * The refill count would not change in pass two. We only moved buffers - * to close the gap in the ring, but we would still have the same no. of - * buffers to refill. - */ - return desc_refilled; -} - -static int -lio_droq_fast_process_packet(struct lio_device *lio_dev, - struct lio_droq *droq, - struct rte_mbuf **rx_pkts) -{ - struct rte_mbuf *nicbuf = NULL; - struct lio_droq_info *info; - uint32_t total_len = 0; - int data_total_len = 0; - uint32_t pkt_len = 0; - union octeon_rh *rh; - int data_pkts = 0; - - info = &droq->info_list[droq->read_idx]; - lio_swap_8B_data((uint64_t *)info, 2); - - if (!info->length) - return -1; - - /* Len of resp hdr in included in the received data len. */ - info->length -= OCTEON_RH_SIZE; - rh = &info->rh; - - total_len += (uint32_t)info->length; - - if (lio_opcode_slow_path(rh)) { - uint32_t buf_cnt; - - buf_cnt = lio_droq_get_bufcount(droq->buffer_size, - (uint32_t)info->length); - droq->read_idx = lio_incr_index(droq->read_idx, buf_cnt, - droq->nb_desc); - droq->refill_count += buf_cnt; - } else { - if (info->length <= droq->buffer_size) { - if (rh->r_dh.has_hash) - pkt_len = (uint32_t)(info->length - 8); - else - pkt_len = (uint32_t)info->length; - - nicbuf = droq->recv_buf_list[droq->read_idx].buffer; - droq->recv_buf_list[droq->read_idx].buffer = NULL; - droq->read_idx = lio_incr_index( - droq->read_idx, 1, - droq->nb_desc); - droq->refill_count++; - - if (likely(nicbuf != NULL)) { - /* We don't have a way to pass flags yet */ - nicbuf->ol_flags = 0; - if (rh->r_dh.has_hash) { - uint64_t *hash_ptr; - - nicbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH; - hash_ptr = rte_pktmbuf_mtod(nicbuf, - uint64_t *); - lio_swap_8B_data(hash_ptr, 1); - nicbuf->hash.rss = (uint32_t)*hash_ptr; - nicbuf->data_off += 8; - } - - nicbuf->pkt_len = pkt_len; - nicbuf->data_len = pkt_len; - nicbuf->port = lio_dev->port_id; - /* Store the mbuf */ - rx_pkts[data_pkts++] = nicbuf; - data_total_len += pkt_len; - } - - /* Prefetch buffer pointers when on a cache line - * boundary - */ - if ((droq->read_idx & 3) == 0) { - rte_prefetch0( - &droq->recv_buf_list[droq->read_idx]); - rte_prefetch0( - &droq->info_list[droq->read_idx]); - } - } else { - struct rte_mbuf *first_buf = NULL; - struct rte_mbuf *last_buf = NULL; - - while (pkt_len < info->length) { - int cpy_len = 0; - - cpy_len = ((pkt_len + droq->buffer_size) > - info->length) - ? ((uint32_t)info->length - - pkt_len) - : droq->buffer_size; - - nicbuf = - droq->recv_buf_list[droq->read_idx].buffer; - droq->recv_buf_list[droq->read_idx].buffer = - NULL; - - if (likely(nicbuf != NULL)) { - /* Note the first seg */ - if (!pkt_len) - first_buf = nicbuf; - - nicbuf->port = lio_dev->port_id; - /* We don't have a way to pass - * flags yet - */ - nicbuf->ol_flags = 0; - if ((!pkt_len) && (rh->r_dh.has_hash)) { - uint64_t *hash_ptr; - - nicbuf->ol_flags |= - RTE_MBUF_F_RX_RSS_HASH; - hash_ptr = rte_pktmbuf_mtod( - nicbuf, uint64_t *); - lio_swap_8B_data(hash_ptr, 1); - nicbuf->hash.rss = - (uint32_t)*hash_ptr; - nicbuf->data_off += 8; - nicbuf->pkt_len = cpy_len - 8; - nicbuf->data_len = cpy_len - 8; - } else { - nicbuf->pkt_len = cpy_len; - nicbuf->data_len = cpy_len; - } - - if (pkt_len) - first_buf->nb_segs++; - - if (last_buf) - last_buf->next = nicbuf; - - last_buf = nicbuf; - } else { - PMD_RX_LOG(lio_dev, ERR, "no buf\n"); - } - - pkt_len += cpy_len; - droq->read_idx = lio_incr_index( - droq->read_idx, - 1, droq->nb_desc); - droq->refill_count++; - - /* Prefetch buffer pointers when on a - * cache line boundary - */ - if ((droq->read_idx & 3) == 0) { - rte_prefetch0(&droq->recv_buf_list - [droq->read_idx]); - - rte_prefetch0( - &droq->info_list[droq->read_idx]); - } - } - rx_pkts[data_pkts++] = first_buf; - if (rh->r_dh.has_hash) - data_total_len += (pkt_len - 8); - else - data_total_len += pkt_len; - } - - /* Inform upper layer about packet checksum verification */ - struct rte_mbuf *m = rx_pkts[data_pkts - 1]; - - if (rh->r_dh.csum_verified & LIO_IP_CSUM_VERIFIED) - m->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; - - if (rh->r_dh.csum_verified & LIO_L4_CSUM_VERIFIED) - m->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; - } - - if (droq->refill_count >= droq->refill_threshold) { - int desc_refilled = lio_droq_refill(droq); - - /* Flush the droq descriptor data to memory to be sure - * that when we update the credits the data in memory is - * accurate. - */ - rte_wmb(); - rte_write32(desc_refilled, droq->pkts_credit_reg); - /* make sure mmio write completes */ - rte_wmb(); - } - - info->length = 0; - info->rh.rh64 = 0; - - droq->stats.pkts_received++; - droq->stats.rx_pkts_received += data_pkts; - droq->stats.rx_bytes_received += data_total_len; - droq->stats.bytes_received += total_len; - - return data_pkts; -} - -static uint32_t -lio_droq_fast_process_packets(struct lio_device *lio_dev, - struct lio_droq *droq, - struct rte_mbuf **rx_pkts, - uint32_t pkts_to_process) -{ - int ret, data_pkts = 0; - uint32_t pkt; - - for (pkt = 0; pkt < pkts_to_process; pkt++) { - ret = lio_droq_fast_process_packet(lio_dev, droq, - &rx_pkts[data_pkts]); - if (ret < 0) { - lio_dev_err(lio_dev, "Port[%d] DROQ[%d] idx: %d len:0, pkt_cnt: %d\n", - lio_dev->port_id, droq->q_no, - droq->read_idx, pkts_to_process); - break; - } - data_pkts += ret; - } - - rte_atomic64_sub(&droq->pkts_pending, pkt); - - return data_pkts; -} - -static inline uint32_t -lio_droq_check_hw_for_pkts(struct lio_droq *droq) -{ - uint32_t last_count; - uint32_t pkt_count; - - pkt_count = rte_read32(droq->pkts_sent_reg); - - last_count = pkt_count - droq->pkt_count; - droq->pkt_count = pkt_count; - - if (last_count) - rte_atomic64_add(&droq->pkts_pending, last_count); - - return last_count; -} - -uint16_t -lio_dev_recv_pkts(void *rx_queue, - struct rte_mbuf **rx_pkts, - uint16_t budget) -{ - struct lio_droq *droq = rx_queue; - struct lio_device *lio_dev = droq->lio_dev; - uint32_t pkts_processed = 0; - uint32_t pkt_count = 0; - - lio_droq_check_hw_for_pkts(droq); - - pkt_count = rte_atomic64_read(&droq->pkts_pending); - if (!pkt_count) - return 0; - - if (pkt_count > budget) - pkt_count = budget; - - /* Grab the lock */ - rte_spinlock_lock(&droq->lock); - pkts_processed = lio_droq_fast_process_packets(lio_dev, - droq, rx_pkts, - pkt_count); - - if (droq->pkt_count) { - rte_write32(droq->pkt_count, droq->pkts_sent_reg); - droq->pkt_count = 0; - } - - /* Release the spin lock */ - rte_spinlock_unlock(&droq->lock); - - return pkts_processed; -} - -void -lio_delete_droq_queue(struct lio_device *lio_dev, - int oq_no) -{ - lio_delete_droq(lio_dev, oq_no); - lio_dev->num_oqs--; - rte_free(lio_dev->droq[oq_no]); - lio_dev->droq[oq_no] = NULL; -} - -/** - * lio_init_instr_queue() - * @param lio_dev - pointer to the lio device structure. - * @param txpciq - queue to be initialized. - * - * Called at driver init time for each input queue. iq_conf has the - * configuration parameters for the queue. - * - * @return Success: 0 Failure: -1 - */ -static int -lio_init_instr_queue(struct lio_device *lio_dev, - union octeon_txpciq txpciq, - uint32_t num_descs, unsigned int socket_id) -{ - uint32_t iq_no = (uint32_t)txpciq.s.q_no; - struct lio_instr_queue *iq; - uint32_t instr_type; - uint32_t q_size; - - instr_type = LIO_IQ_INSTR_TYPE(lio_dev); - - q_size = instr_type * num_descs; - iq = lio_dev->instr_queue[iq_no]; - iq->iq_mz = rte_eth_dma_zone_reserve(lio_dev->eth_dev, - "instr_queue", iq_no, q_size, - RTE_CACHE_LINE_SIZE, - socket_id); - if (iq->iq_mz == NULL) { - lio_dev_err(lio_dev, "Cannot allocate memory for instr queue %d\n", - iq_no); - return -1; - } - - iq->base_addr_dma = iq->iq_mz->iova; - iq->base_addr = (uint8_t *)iq->iq_mz->addr; - - iq->nb_desc = num_descs; - - /* Initialize a list to holds requests that have been posted to Octeon - * but has yet to be fetched by octeon - */ - iq->request_list = rte_zmalloc_socket("request_list", - sizeof(*iq->request_list) * - num_descs, - RTE_CACHE_LINE_SIZE, - socket_id); - if (iq->request_list == NULL) { - lio_dev_err(lio_dev, "Alloc failed for IQ[%d] nr free list\n", - iq_no); - lio_dma_zone_free(lio_dev, iq->iq_mz); - return -1; - } - - lio_dev_dbg(lio_dev, "IQ[%d]: base: %p basedma: %lx count: %d\n", - iq_no, iq->base_addr, (unsigned long)iq->base_addr_dma, - iq->nb_desc); - - iq->lio_dev = lio_dev; - iq->txpciq.txpciq64 = txpciq.txpciq64; - iq->fill_cnt = 0; - iq->host_write_index = 0; - iq->lio_read_index = 0; - iq->flush_index = 0; - - rte_atomic64_set(&iq->instr_pending, 0); - - /* Initialize the spinlock for this instruction queue */ - rte_spinlock_init(&iq->lock); - rte_spinlock_init(&iq->post_lock); - - rte_atomic64_clear(&iq->iq_flush_running); - - lio_dev->io_qmask.iq |= (1ULL << iq_no); - - /* Set the 32B/64B mode for each input queue */ - lio_dev->io_qmask.iq64B |= ((instr_type == 64) << iq_no); - iq->iqcmd_64B = (instr_type == 64); - - lio_dev->fn_list.setup_iq_regs(lio_dev, iq_no); - - return 0; -} - -int -lio_setup_instr_queue0(struct lio_device *lio_dev) -{ - union octeon_txpciq txpciq; - uint32_t num_descs = 0; - uint32_t iq_no = 0; - - num_descs = LIO_NUM_DEF_TX_DESCS_CFG(lio_dev); - - lio_dev->num_iqs = 0; - - lio_dev->instr_queue[0] = rte_zmalloc(NULL, - sizeof(struct lio_instr_queue), 0); - if (lio_dev->instr_queue[0] == NULL) - return -ENOMEM; - - lio_dev->instr_queue[0]->q_index = 0; - lio_dev->instr_queue[0]->app_ctx = (void *)(size_t)0; - txpciq.txpciq64 = 0; - txpciq.s.q_no = iq_no; - txpciq.s.pkind = lio_dev->pfvf_hsword.pkind; - txpciq.s.use_qpg = 0; - txpciq.s.qpg = 0; - if (lio_init_instr_queue(lio_dev, txpciq, num_descs, SOCKET_ID_ANY)) { - rte_free(lio_dev->instr_queue[0]); - lio_dev->instr_queue[0] = NULL; - return -1; - } - - lio_dev->num_iqs++; - - return 0; -} - -/** - * lio_delete_instr_queue() - * @param lio_dev - pointer to the lio device structure. - * @param iq_no - queue to be deleted. - * - * Called at driver unload time for each input queue. Deletes all - * allocated resources for the input queue. - */ -static void -lio_delete_instr_queue(struct lio_device *lio_dev, uint32_t iq_no) -{ - struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; - - rte_free(iq->request_list); - iq->request_list = NULL; - lio_dma_zone_free(lio_dev, iq->iq_mz); -} - -void -lio_free_instr_queue0(struct lio_device *lio_dev) -{ - lio_delete_instr_queue(lio_dev, 0); - rte_free(lio_dev->instr_queue[0]); - lio_dev->instr_queue[0] = NULL; - lio_dev->num_iqs--; -} - -/* Return 0 on success, -1 on failure */ -int -lio_setup_iq(struct lio_device *lio_dev, int q_index, - union octeon_txpciq txpciq, uint32_t num_descs, void *app_ctx, - unsigned int socket_id) -{ - uint32_t iq_no = (uint32_t)txpciq.s.q_no; - - lio_dev->instr_queue[iq_no] = rte_zmalloc_socket("ethdev TX queue", - sizeof(struct lio_instr_queue), - RTE_CACHE_LINE_SIZE, socket_id); - if (lio_dev->instr_queue[iq_no] == NULL) - return -1; - - lio_dev->instr_queue[iq_no]->q_index = q_index; - lio_dev->instr_queue[iq_no]->app_ctx = app_ctx; - - if (lio_init_instr_queue(lio_dev, txpciq, num_descs, socket_id)) { - rte_free(lio_dev->instr_queue[iq_no]); - lio_dev->instr_queue[iq_no] = NULL; - return -1; - } - - lio_dev->num_iqs++; - - return 0; -} - -int -lio_wait_for_instr_fetch(struct lio_device *lio_dev) -{ - int pending, instr_cnt; - int i, retry = 1000; - - do { - instr_cnt = 0; - - for (i = 0; i < LIO_MAX_INSTR_QUEUES(lio_dev); i++) { - if (!(lio_dev->io_qmask.iq & (1ULL << i))) - continue; - - if (lio_dev->instr_queue[i] == NULL) - break; - - pending = rte_atomic64_read( - &lio_dev->instr_queue[i]->instr_pending); - if (pending) - lio_flush_iq(lio_dev, lio_dev->instr_queue[i]); - - instr_cnt += pending; - } - - if (instr_cnt == 0) - break; - - rte_delay_ms(1); - - } while (retry-- && instr_cnt); - - return instr_cnt; -} - -static inline void -lio_ring_doorbell(struct lio_device *lio_dev, - struct lio_instr_queue *iq) -{ - if (rte_atomic64_read(&lio_dev->status) == LIO_DEV_RUNNING) { - rte_write32(iq->fill_cnt, iq->doorbell_reg); - /* make sure doorbell write goes through */ - rte_wmb(); - iq->fill_cnt = 0; - } -} - -static inline void -copy_cmd_into_iq(struct lio_instr_queue *iq, uint8_t *cmd) -{ - uint8_t *iqptr, cmdsize; - - cmdsize = ((iq->iqcmd_64B) ? 64 : 32); - iqptr = iq->base_addr + (cmdsize * iq->host_write_index); - - rte_memcpy(iqptr, cmd, cmdsize); -} - -static inline struct lio_iq_post_status -post_command2(struct lio_instr_queue *iq, uint8_t *cmd) -{ - struct lio_iq_post_status st; - - st.status = LIO_IQ_SEND_OK; - - /* This ensures that the read index does not wrap around to the same - * position if queue gets full before Octeon could fetch any instr. - */ - if (rte_atomic64_read(&iq->instr_pending) >= - (int32_t)(iq->nb_desc - 1)) { - st.status = LIO_IQ_SEND_FAILED; - st.index = -1; - return st; - } - - if (rte_atomic64_read(&iq->instr_pending) >= - (int32_t)(iq->nb_desc - 2)) - st.status = LIO_IQ_SEND_STOP; - - copy_cmd_into_iq(iq, cmd); - - /* "index" is returned, host_write_index is modified. */ - st.index = iq->host_write_index; - iq->host_write_index = lio_incr_index(iq->host_write_index, 1, - iq->nb_desc); - iq->fill_cnt++; - - /* Flush the command into memory. We need to be sure the data is in - * memory before indicating that the instruction is pending. - */ - rte_wmb(); - - rte_atomic64_inc(&iq->instr_pending); - - return st; -} - -static inline void -lio_add_to_request_list(struct lio_instr_queue *iq, - int idx, void *buf, int reqtype) -{ - iq->request_list[idx].buf = buf; - iq->request_list[idx].reqtype = reqtype; -} - -static inline void -lio_free_netsgbuf(void *buf) -{ - struct lio_buf_free_info *finfo = buf; - struct lio_device *lio_dev = finfo->lio_dev; - struct rte_mbuf *m = finfo->mbuf; - struct lio_gather *g = finfo->g; - uint8_t iq = finfo->iq_no; - - /* This will take care of multiple segments also */ - rte_pktmbuf_free(m); - - rte_spinlock_lock(&lio_dev->glist_lock[iq]); - STAILQ_INSERT_TAIL(&lio_dev->glist_head[iq], &g->list, entries); - rte_spinlock_unlock(&lio_dev->glist_lock[iq]); - rte_free(finfo); -} - -/* Can only run in process context */ -static int -lio_process_iq_request_list(struct lio_device *lio_dev, - struct lio_instr_queue *iq) -{ - struct octeon_instr_irh *irh = NULL; - uint32_t old = iq->flush_index; - struct lio_soft_command *sc; - uint32_t inst_count = 0; - int reqtype; - void *buf; - - while (old != iq->lio_read_index) { - reqtype = iq->request_list[old].reqtype; - buf = iq->request_list[old].buf; - - if (reqtype == LIO_REQTYPE_NONE) - goto skip_this; - - switch (reqtype) { - case LIO_REQTYPE_NORESP_NET: - rte_pktmbuf_free((struct rte_mbuf *)buf); - break; - case LIO_REQTYPE_NORESP_NET_SG: - lio_free_netsgbuf(buf); - break; - case LIO_REQTYPE_SOFT_COMMAND: - sc = buf; - irh = (struct octeon_instr_irh *)&sc->cmd.cmd3.irh; - if (irh->rflag) { - /* We're expecting a response from Octeon. - * It's up to lio_process_ordered_list() to - * process sc. Add sc to the ordered soft - * command response list because we expect - * a response from Octeon. - */ - rte_spinlock_lock(&lio_dev->response_list.lock); - rte_atomic64_inc( - &lio_dev->response_list.pending_req_count); - STAILQ_INSERT_TAIL( - &lio_dev->response_list.head, - &sc->node, entries); - rte_spinlock_unlock( - &lio_dev->response_list.lock); - } else { - if (sc->callback) { - /* This callback must not sleep */ - sc->callback(LIO_REQUEST_DONE, - sc->callback_arg); - } - } - break; - default: - lio_dev_err(lio_dev, - "Unknown reqtype: %d buf: %p at idx %d\n", - reqtype, buf, old); - } - - iq->request_list[old].buf = NULL; - iq->request_list[old].reqtype = 0; - -skip_this: - inst_count++; - old = lio_incr_index(old, 1, iq->nb_desc); - } - - iq->flush_index = old; - - return inst_count; -} - -static void -lio_update_read_index(struct lio_instr_queue *iq) -{ - uint32_t pkt_in_done = rte_read32(iq->inst_cnt_reg); - uint32_t last_done; - - last_done = pkt_in_done - iq->pkt_in_done; - iq->pkt_in_done = pkt_in_done; - - /* Add last_done and modulo with the IQ size to get new index */ - iq->lio_read_index = (iq->lio_read_index + - (uint32_t)(last_done & LIO_PKT_IN_DONE_CNT_MASK)) % - iq->nb_desc; -} - -int -lio_flush_iq(struct lio_device *lio_dev, struct lio_instr_queue *iq) -{ - uint32_t inst_processed = 0; - int tx_done = 1; - - if (rte_atomic64_test_and_set(&iq->iq_flush_running) == 0) - return tx_done; - - rte_spinlock_lock(&iq->lock); - - lio_update_read_index(iq); - - do { - /* Process any outstanding IQ packets. */ - if (iq->flush_index == iq->lio_read_index) - break; - - inst_processed = lio_process_iq_request_list(lio_dev, iq); - - if (inst_processed) { - rte_atomic64_sub(&iq->instr_pending, inst_processed); - iq->stats.instr_processed += inst_processed; - } - - inst_processed = 0; - - } while (1); - - rte_spinlock_unlock(&iq->lock); - - rte_atomic64_clear(&iq->iq_flush_running); - - return tx_done; -} - -static int -lio_send_command(struct lio_device *lio_dev, uint32_t iq_no, void *cmd, - void *buf, uint32_t datasize, uint32_t reqtype) -{ - struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; - struct lio_iq_post_status st; - - rte_spinlock_lock(&iq->post_lock); - - st = post_command2(iq, cmd); - - if (st.status != LIO_IQ_SEND_FAILED) { - lio_add_to_request_list(iq, st.index, buf, reqtype); - LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, bytes_sent, - datasize); - LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, instr_posted, 1); - - lio_ring_doorbell(lio_dev, iq); - } else { - LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, instr_dropped, 1); - } - - rte_spinlock_unlock(&iq->post_lock); - - return st.status; -} - -void -lio_prepare_soft_command(struct lio_device *lio_dev, - struct lio_soft_command *sc, uint8_t opcode, - uint8_t subcode, uint32_t irh_ossp, uint64_t ossp0, - uint64_t ossp1) -{ - struct octeon_instr_pki_ih3 *pki_ih3; - struct octeon_instr_ih3 *ih3; - struct octeon_instr_irh *irh; - struct octeon_instr_rdp *rdp; - - RTE_ASSERT(opcode <= 15); - RTE_ASSERT(subcode <= 127); - - ih3 = (struct octeon_instr_ih3 *)&sc->cmd.cmd3.ih3; - - ih3->pkind = lio_dev->instr_queue[sc->iq_no]->txpciq.s.pkind; - - pki_ih3 = (struct octeon_instr_pki_ih3 *)&sc->cmd.cmd3.pki_ih3; - - pki_ih3->w = 1; - pki_ih3->raw = 1; - pki_ih3->utag = 1; - pki_ih3->uqpg = lio_dev->instr_queue[sc->iq_no]->txpciq.s.use_qpg; - pki_ih3->utt = 1; - - pki_ih3->tag = LIO_CONTROL; - pki_ih3->tagtype = OCTEON_ATOMIC_TAG; - pki_ih3->qpg = lio_dev->instr_queue[sc->iq_no]->txpciq.s.qpg; - pki_ih3->pm = 0x7; - pki_ih3->sl = 8; - - if (sc->datasize) - ih3->dlengsz = sc->datasize; - - irh = (struct octeon_instr_irh *)&sc->cmd.cmd3.irh; - irh->opcode = opcode; - irh->subcode = subcode; - - /* opcode/subcode specific parameters (ossp) */ - irh->ossp = irh_ossp; - sc->cmd.cmd3.ossp[0] = ossp0; - sc->cmd.cmd3.ossp[1] = ossp1; - - if (sc->rdatasize) { - rdp = (struct octeon_instr_rdp *)&sc->cmd.cmd3.rdp; - rdp->pcie_port = lio_dev->pcie_port; - rdp->rlen = sc->rdatasize; - irh->rflag = 1; - /* PKI IH3 */ - ih3->fsz = OCTEON_SOFT_CMD_RESP_IH3; - } else { - irh->rflag = 0; - /* PKI IH3 */ - ih3->fsz = OCTEON_PCI_CMD_O3; - } -} - -int -lio_send_soft_command(struct lio_device *lio_dev, - struct lio_soft_command *sc) -{ - struct octeon_instr_ih3 *ih3; - struct octeon_instr_irh *irh; - uint32_t len = 0; - - ih3 = (struct octeon_instr_ih3 *)&sc->cmd.cmd3.ih3; - if (ih3->dlengsz) { - RTE_ASSERT(sc->dmadptr); - sc->cmd.cmd3.dptr = sc->dmadptr; - } - - irh = (struct octeon_instr_irh *)&sc->cmd.cmd3.irh; - if (irh->rflag) { - RTE_ASSERT(sc->dmarptr); - RTE_ASSERT(sc->status_word != NULL); - *sc->status_word = LIO_COMPLETION_WORD_INIT; - sc->cmd.cmd3.rptr = sc->dmarptr; - } - - len = (uint32_t)ih3->dlengsz; - - if (sc->wait_time) - sc->timeout = lio_uptime + sc->wait_time; - - return lio_send_command(lio_dev, sc->iq_no, &sc->cmd, sc, len, - LIO_REQTYPE_SOFT_COMMAND); -} - -int -lio_setup_sc_buffer_pool(struct lio_device *lio_dev) -{ - char sc_pool_name[RTE_MEMPOOL_NAMESIZE]; - uint16_t buf_size; - - buf_size = LIO_SOFT_COMMAND_BUFFER_SIZE + RTE_PKTMBUF_HEADROOM; - snprintf(sc_pool_name, sizeof(sc_pool_name), - "lio_sc_pool_%u", lio_dev->port_id); - lio_dev->sc_buf_pool = rte_pktmbuf_pool_create(sc_pool_name, - LIO_MAX_SOFT_COMMAND_BUFFERS, - 0, 0, buf_size, SOCKET_ID_ANY); - return 0; -} - -void -lio_free_sc_buffer_pool(struct lio_device *lio_dev) -{ - rte_mempool_free(lio_dev->sc_buf_pool); -} - -struct lio_soft_command * -lio_alloc_soft_command(struct lio_device *lio_dev, uint32_t datasize, - uint32_t rdatasize, uint32_t ctxsize) -{ - uint32_t offset = sizeof(struct lio_soft_command); - struct lio_soft_command *sc; - struct rte_mbuf *m; - uint64_t dma_addr; - - RTE_ASSERT((offset + datasize + rdatasize + ctxsize) <= - LIO_SOFT_COMMAND_BUFFER_SIZE); - - m = rte_pktmbuf_alloc(lio_dev->sc_buf_pool); - if (m == NULL) { - lio_dev_err(lio_dev, "Cannot allocate mbuf for sc\n"); - return NULL; - } - - /* set rte_mbuf data size and there is only 1 segment */ - m->pkt_len = LIO_SOFT_COMMAND_BUFFER_SIZE; - m->data_len = LIO_SOFT_COMMAND_BUFFER_SIZE; - - /* use rte_mbuf buffer for soft command */ - sc = rte_pktmbuf_mtod(m, struct lio_soft_command *); - memset(sc, 0, LIO_SOFT_COMMAND_BUFFER_SIZE); - sc->size = LIO_SOFT_COMMAND_BUFFER_SIZE; - sc->dma_addr = rte_mbuf_data_iova(m); - sc->mbuf = m; - - dma_addr = sc->dma_addr; - - if (ctxsize) { - sc->ctxptr = (uint8_t *)sc + offset; - sc->ctxsize = ctxsize; - } - - /* Start data at 128 byte boundary */ - offset = (offset + ctxsize + 127) & 0xffffff80; - - if (datasize) { - sc->virtdptr = (uint8_t *)sc + offset; - sc->dmadptr = dma_addr + offset; - sc->datasize = datasize; - } - - /* Start rdata at 128 byte boundary */ - offset = (offset + datasize + 127) & 0xffffff80; - - if (rdatasize) { - RTE_ASSERT(rdatasize >= 16); - sc->virtrptr = (uint8_t *)sc + offset; - sc->dmarptr = dma_addr + offset; - sc->rdatasize = rdatasize; - sc->status_word = (uint64_t *)((uint8_t *)(sc->virtrptr) + - rdatasize - 8); - } - - return sc; -} - -void -lio_free_soft_command(struct lio_soft_command *sc) -{ - rte_pktmbuf_free(sc->mbuf); -} - -void -lio_setup_response_list(struct lio_device *lio_dev) -{ - STAILQ_INIT(&lio_dev->response_list.head); - rte_spinlock_init(&lio_dev->response_list.lock); - rte_atomic64_set(&lio_dev->response_list.pending_req_count, 0); -} - -int -lio_process_ordered_list(struct lio_device *lio_dev) -{ - int resp_to_process = LIO_MAX_ORD_REQS_TO_PROCESS; - struct lio_response_list *ordered_sc_list; - struct lio_soft_command *sc; - int request_complete = 0; - uint64_t status64; - uint32_t status; - - ordered_sc_list = &lio_dev->response_list; - - do { - rte_spinlock_lock(&ordered_sc_list->lock); - - if (STAILQ_EMPTY(&ordered_sc_list->head)) { - /* ordered_sc_list is empty; there is - * nothing to process - */ - rte_spinlock_unlock(&ordered_sc_list->lock); - return -1; - } - - sc = LIO_STQUEUE_FIRST_ENTRY(&ordered_sc_list->head, - struct lio_soft_command, node); - - status = LIO_REQUEST_PENDING; - - /* check if octeon has finished DMA'ing a response - * to where rptr is pointing to - */ - status64 = *sc->status_word; - - if (status64 != LIO_COMPLETION_WORD_INIT) { - /* This logic ensures that all 64b have been written. - * 1. check byte 0 for non-FF - * 2. if non-FF, then swap result from BE to host order - * 3. check byte 7 (swapped to 0) for non-FF - * 4. if non-FF, use the low 32-bit status code - * 5. if either byte 0 or byte 7 is FF, don't use status - */ - if ((status64 & 0xff) != 0xff) { - lio_swap_8B_data(&status64, 1); - if (((status64 & 0xff) != 0xff)) { - /* retrieve 16-bit firmware status */ - status = (uint32_t)(status64 & - 0xffffULL); - if (status) { - status = - LIO_FIRMWARE_STATUS_CODE( - status); - } else { - /* i.e. no error */ - status = LIO_REQUEST_DONE; - } - } - } - } else if ((sc->timeout && lio_check_timeout(lio_uptime, - sc->timeout))) { - lio_dev_err(lio_dev, - "cmd failed, timeout (%ld, %ld)\n", - (long)lio_uptime, (long)sc->timeout); - status = LIO_REQUEST_TIMEOUT; - } - - if (status != LIO_REQUEST_PENDING) { - /* we have received a response or we have timed out. - * remove node from linked list - */ - STAILQ_REMOVE(&ordered_sc_list->head, - &sc->node, lio_stailq_node, entries); - rte_atomic64_dec( - &lio_dev->response_list.pending_req_count); - rte_spinlock_unlock(&ordered_sc_list->lock); - - if (sc->callback) - sc->callback(status, sc->callback_arg); - - request_complete++; - } else { - /* no response yet */ - request_complete = 0; - rte_spinlock_unlock(&ordered_sc_list->lock); - } - - /* If we hit the Max Ordered requests to process every loop, - * we quit and let this function be invoked the next time - * the poll thread runs to process the remaining requests. - * This function can take up the entire CPU if there is - * no upper limit to the requests processed. - */ - if (request_complete >= resp_to_process) - break; - } while (request_complete); - - return 0; -} - -static inline struct lio_stailq_node * -list_delete_first_node(struct lio_stailq_head *head) -{ - struct lio_stailq_node *node; - - if (STAILQ_EMPTY(head)) - node = NULL; - else - node = STAILQ_FIRST(head); - - if (node) - STAILQ_REMOVE(head, node, lio_stailq_node, entries); - - return node; -} - -void -lio_delete_sglist(struct lio_instr_queue *txq) -{ - struct lio_device *lio_dev = txq->lio_dev; - int iq_no = txq->q_index; - struct lio_gather *g; - - if (lio_dev->glist_head == NULL) - return; - - do { - g = (struct lio_gather *)list_delete_first_node( - &lio_dev->glist_head[iq_no]); - if (g) { - if (g->sg) - rte_free( - (void *)((unsigned long)g->sg - g->adjust)); - rte_free(g); - } - } while (g); -} - -/** - * \brief Setup gather lists - * @param lio per-network private data - */ -int -lio_setup_sglists(struct lio_device *lio_dev, int iq_no, - int fw_mapped_iq, int num_descs, unsigned int socket_id) -{ - struct lio_gather *g; - int i; - - rte_spinlock_init(&lio_dev->glist_lock[iq_no]); - - STAILQ_INIT(&lio_dev->glist_head[iq_no]); - - for (i = 0; i < num_descs; i++) { - g = rte_zmalloc_socket(NULL, sizeof(*g), RTE_CACHE_LINE_SIZE, - socket_id); - if (g == NULL) { - lio_dev_err(lio_dev, - "lio_gather memory allocation failed for qno %d\n", - iq_no); - break; - } - - g->sg_size = - ((ROUNDUP4(LIO_MAX_SG) >> 2) * LIO_SG_ENTRY_SIZE); - - g->sg = rte_zmalloc_socket(NULL, g->sg_size + 8, - RTE_CACHE_LINE_SIZE, socket_id); - if (g->sg == NULL) { - lio_dev_err(lio_dev, - "sg list memory allocation failed for qno %d\n", - iq_no); - rte_free(g); - break; - } - - /* The gather component should be aligned on 64-bit boundary */ - if (((unsigned long)g->sg) & 7) { - g->adjust = 8 - (((unsigned long)g->sg) & 7); - g->sg = - (struct lio_sg_entry *)((unsigned long)g->sg + - g->adjust); - } - - STAILQ_INSERT_TAIL(&lio_dev->glist_head[iq_no], &g->list, - entries); - } - - if (i != num_descs) { - lio_delete_sglist(lio_dev->instr_queue[fw_mapped_iq]); - return -ENOMEM; - } - - return 0; -} - -void -lio_delete_instruction_queue(struct lio_device *lio_dev, int iq_no) -{ - lio_delete_instr_queue(lio_dev, iq_no); - rte_free(lio_dev->instr_queue[iq_no]); - lio_dev->instr_queue[iq_no] = NULL; - lio_dev->num_iqs--; -} - -static inline uint32_t -lio_iq_get_available(struct lio_device *lio_dev, uint32_t q_no) -{ - return ((lio_dev->instr_queue[q_no]->nb_desc - 1) - - (uint32_t)rte_atomic64_read( - &lio_dev->instr_queue[q_no]->instr_pending)); -} - -static inline int -lio_iq_is_full(struct lio_device *lio_dev, uint32_t q_no) -{ - return ((uint32_t)rte_atomic64_read( - &lio_dev->instr_queue[q_no]->instr_pending) >= - (lio_dev->instr_queue[q_no]->nb_desc - 2)); -} - -static int -lio_dev_cleanup_iq(struct lio_device *lio_dev, int iq_no) -{ - struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; - uint32_t count = 10000; - - while ((lio_iq_get_available(lio_dev, iq_no) < LIO_FLUSH_WM(iq)) && - --count) - lio_flush_iq(lio_dev, iq); - - return count ? 0 : 1; -} - -static void -lio_ctrl_cmd_callback(uint32_t status __rte_unused, void *sc_ptr) -{ - struct lio_soft_command *sc = sc_ptr; - struct lio_dev_ctrl_cmd *ctrl_cmd; - struct lio_ctrl_pkt *ctrl_pkt; - - ctrl_pkt = (struct lio_ctrl_pkt *)sc->ctxptr; - ctrl_cmd = ctrl_pkt->ctrl_cmd; - ctrl_cmd->cond = 1; - - lio_free_soft_command(sc); -} - -static inline struct lio_soft_command * -lio_alloc_ctrl_pkt_sc(struct lio_device *lio_dev, - struct lio_ctrl_pkt *ctrl_pkt) -{ - struct lio_soft_command *sc = NULL; - uint32_t uddsize, datasize; - uint32_t rdatasize; - uint8_t *data; - - uddsize = (uint32_t)(ctrl_pkt->ncmd.s.more * 8); - - datasize = OCTEON_CMD_SIZE + uddsize; - rdatasize = (ctrl_pkt->wait_time) ? 16 : 0; - - sc = lio_alloc_soft_command(lio_dev, datasize, - rdatasize, sizeof(struct lio_ctrl_pkt)); - if (sc == NULL) - return NULL; - - rte_memcpy(sc->ctxptr, ctrl_pkt, sizeof(struct lio_ctrl_pkt)); - - data = (uint8_t *)sc->virtdptr; - - rte_memcpy(data, &ctrl_pkt->ncmd, OCTEON_CMD_SIZE); - - lio_swap_8B_data((uint64_t *)data, OCTEON_CMD_SIZE >> 3); - - if (uddsize) { - /* Endian-Swap for UDD should have been done by caller. */ - rte_memcpy(data + OCTEON_CMD_SIZE, ctrl_pkt->udd, uddsize); - } - - sc->iq_no = (uint32_t)ctrl_pkt->iq_no; - - lio_prepare_soft_command(lio_dev, sc, - LIO_OPCODE, LIO_OPCODE_CMD, - 0, 0, 0); - - sc->callback = lio_ctrl_cmd_callback; - sc->callback_arg = sc; - sc->wait_time = ctrl_pkt->wait_time; - - return sc; -} - -int -lio_send_ctrl_pkt(struct lio_device *lio_dev, struct lio_ctrl_pkt *ctrl_pkt) -{ - struct lio_soft_command *sc = NULL; - int retval; - - sc = lio_alloc_ctrl_pkt_sc(lio_dev, ctrl_pkt); - if (sc == NULL) { - lio_dev_err(lio_dev, "soft command allocation failed\n"); - return -1; - } - - retval = lio_send_soft_command(lio_dev, sc); - if (retval == LIO_IQ_SEND_FAILED) { - lio_free_soft_command(sc); - lio_dev_err(lio_dev, "Port: %d soft command: %d send failed status: %x\n", - lio_dev->port_id, ctrl_pkt->ncmd.s.cmd, retval); - return -1; - } - - return retval; -} - -/** Send data packet to the device - * @param lio_dev - lio device pointer - * @param ndata - control structure with queueing, and buffer information - * - * @returns IQ_FAILED if it failed to add to the input queue. IQ_STOP if it the - * queue should be stopped, and LIO_IQ_SEND_OK if it sent okay. - */ -static inline int -lio_send_data_pkt(struct lio_device *lio_dev, struct lio_data_pkt *ndata) -{ - return lio_send_command(lio_dev, ndata->q_no, &ndata->cmd, - ndata->buf, ndata->datasize, ndata->reqtype); -} - -uint16_t -lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts) -{ - struct lio_instr_queue *txq = tx_queue; - union lio_cmd_setup cmdsetup; - struct lio_device *lio_dev; - struct lio_iq_stats *stats; - struct lio_data_pkt ndata; - int i, processed = 0; - struct rte_mbuf *m; - uint32_t tag = 0; - int status = 0; - int iq_no; - - lio_dev = txq->lio_dev; - iq_no = txq->txpciq.s.q_no; - stats = &lio_dev->instr_queue[iq_no]->stats; - - if (!lio_dev->intf_open || !lio_dev->linfo.link.s.link_up) { - PMD_TX_LOG(lio_dev, ERR, "Transmit failed link_status : %d\n", - lio_dev->linfo.link.s.link_up); - goto xmit_failed; - } - - lio_dev_cleanup_iq(lio_dev, iq_no); - - for (i = 0; i < nb_pkts; i++) { - uint32_t pkt_len = 0; - - m = pkts[i]; - - /* Prepare the attributes for the data to be passed to BASE. */ - memset(&ndata, 0, sizeof(struct lio_data_pkt)); - - ndata.buf = m; - - ndata.q_no = iq_no; - if (lio_iq_is_full(lio_dev, ndata.q_no)) { - stats->tx_iq_busy++; - if (lio_dev_cleanup_iq(lio_dev, iq_no)) { - PMD_TX_LOG(lio_dev, ERR, - "Transmit failed iq:%d full\n", - ndata.q_no); - break; - } - } - - cmdsetup.cmd_setup64 = 0; - cmdsetup.s.iq_no = iq_no; - - /* check checksum offload flags to form cmd */ - if (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) - cmdsetup.s.ip_csum = 1; - - if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM) - cmdsetup.s.tnl_csum = 1; - else if ((m->ol_flags & RTE_MBUF_F_TX_TCP_CKSUM) || - (m->ol_flags & RTE_MBUF_F_TX_UDP_CKSUM)) - cmdsetup.s.transport_csum = 1; - - if (m->nb_segs == 1) { - pkt_len = rte_pktmbuf_data_len(m); - cmdsetup.s.u.datasize = pkt_len; - lio_prepare_pci_cmd(lio_dev, &ndata.cmd, - &cmdsetup, tag); - ndata.cmd.cmd3.dptr = rte_mbuf_data_iova(m); - ndata.reqtype = LIO_REQTYPE_NORESP_NET; - } else { - struct lio_buf_free_info *finfo; - struct lio_gather *g; - rte_iova_t phyaddr; - int i, frags; - - finfo = (struct lio_buf_free_info *)rte_malloc(NULL, - sizeof(*finfo), 0); - if (finfo == NULL) { - PMD_TX_LOG(lio_dev, ERR, - "free buffer alloc failed\n"); - goto xmit_failed; - } - - rte_spinlock_lock(&lio_dev->glist_lock[iq_no]); - g = (struct lio_gather *)list_delete_first_node( - &lio_dev->glist_head[iq_no]); - rte_spinlock_unlock(&lio_dev->glist_lock[iq_no]); - if (g == NULL) { - PMD_TX_LOG(lio_dev, ERR, - "Transmit scatter gather: glist null!\n"); - goto xmit_failed; - } - - cmdsetup.s.gather = 1; - cmdsetup.s.u.gatherptrs = m->nb_segs; - lio_prepare_pci_cmd(lio_dev, &ndata.cmd, - &cmdsetup, tag); - - memset(g->sg, 0, g->sg_size); - g->sg[0].ptr[0] = rte_mbuf_data_iova(m); - lio_add_sg_size(&g->sg[0], m->data_len, 0); - pkt_len = m->data_len; - finfo->mbuf = m; - - /* First seg taken care above */ - frags = m->nb_segs - 1; - i = 1; - m = m->next; - while (frags--) { - g->sg[(i >> 2)].ptr[(i & 3)] = - rte_mbuf_data_iova(m); - lio_add_sg_size(&g->sg[(i >> 2)], - m->data_len, (i & 3)); - pkt_len += m->data_len; - i++; - m = m->next; - } - - phyaddr = rte_mem_virt2iova(g->sg); - if (phyaddr == RTE_BAD_IOVA) { - PMD_TX_LOG(lio_dev, ERR, "bad phys addr\n"); - goto xmit_failed; - } - - ndata.cmd.cmd3.dptr = phyaddr; - ndata.reqtype = LIO_REQTYPE_NORESP_NET_SG; - - finfo->g = g; - finfo->lio_dev = lio_dev; - finfo->iq_no = (uint64_t)iq_no; - ndata.buf = finfo; - } - - ndata.datasize = pkt_len; - - status = lio_send_data_pkt(lio_dev, &ndata); - - if (unlikely(status == LIO_IQ_SEND_FAILED)) { - PMD_TX_LOG(lio_dev, ERR, "send failed\n"); - break; - } - - if (unlikely(status == LIO_IQ_SEND_STOP)) { - PMD_TX_LOG(lio_dev, DEBUG, "iq full\n"); - /* create space as iq is full */ - lio_dev_cleanup_iq(lio_dev, iq_no); - } - - stats->tx_done++; - stats->tx_tot_bytes += pkt_len; - processed++; - } - -xmit_failed: - stats->tx_dropped += (nb_pkts - processed); - - return processed; -} - -void -lio_dev_clear_queues(struct rte_eth_dev *eth_dev) -{ - struct lio_instr_queue *txq; - struct lio_droq *rxq; - uint16_t i; - - for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { - txq = eth_dev->data->tx_queues[i]; - if (txq != NULL) { - lio_dev_tx_queue_release(eth_dev, i); - eth_dev->data->tx_queues[i] = NULL; - } - } - - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq != NULL) { - lio_dev_rx_queue_release(eth_dev, i); - eth_dev->data->rx_queues[i] = NULL; - } - } -} diff --git a/dpdk/drivers/net/liquidio/lio_rxtx.h b/dpdk/drivers/net/liquidio/lio_rxtx.h deleted file mode 100644 index d2a45104f..000000000 --- a/dpdk/drivers/net/liquidio/lio_rxtx.h +++ /dev/null @@ -1,740 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_RXTX_H_ -#define _LIO_RXTX_H_ - -#include -#include - -#include -#include - -#include "lio_struct.h" - -#ifndef ROUNDUP4 -#define ROUNDUP4(val) (((val) + 3) & 0xfffffffc) -#endif - -#define LIO_STQUEUE_FIRST_ENTRY(ptr, type, elem) \ - (type *)((char *)((ptr)->stqh_first) - offsetof(type, elem)) - -#define lio_check_timeout(cur_time, chk_time) ((cur_time) > (chk_time)) - -#define lio_uptime \ - (size_t)(rte_get_timer_cycles() / rte_get_timer_hz()) - -/** Descriptor format. - * The descriptor ring is made of descriptors which have 2 64-bit values: - * -# Physical (bus) address of the data buffer. - * -# Physical (bus) address of a lio_droq_info structure. - * The device DMA's incoming packets and its information at the address - * given by these descriptor fields. - */ -struct lio_droq_desc { - /** The buffer pointer */ - uint64_t buffer_ptr; - - /** The Info pointer */ - uint64_t info_ptr; -}; - -#define LIO_DROQ_DESC_SIZE (sizeof(struct lio_droq_desc)) - -/** Information about packet DMA'ed by Octeon. - * The format of the information available at Info Pointer after Octeon - * has posted a packet. Not all descriptors have valid information. Only - * the Info field of the first descriptor for a packet has information - * about the packet. - */ -struct lio_droq_info { - /** The Output Receive Header. */ - union octeon_rh rh; - - /** The Length of the packet. */ - uint64_t length; -}; - -#define LIO_DROQ_INFO_SIZE (sizeof(struct lio_droq_info)) - -/** Pointer to data buffer. - * Driver keeps a pointer to the data buffer that it made available to - * the Octeon device. Since the descriptor ring keeps physical (bus) - * addresses, this field is required for the driver to keep track of - * the virtual address pointers. - */ -struct lio_recv_buffer { - /** Packet buffer, including meta data. */ - void *buffer; - - /** Data in the packet buffer. */ - uint8_t *data; - -}; - -#define LIO_DROQ_RECVBUF_SIZE (sizeof(struct lio_recv_buffer)) - -#define LIO_DROQ_SIZE (sizeof(struct lio_droq)) - -#define LIO_IQ_SEND_OK 0 -#define LIO_IQ_SEND_STOP 1 -#define LIO_IQ_SEND_FAILED -1 - -/* conditions */ -#define LIO_REQTYPE_NONE 0 -#define LIO_REQTYPE_NORESP_NET 1 -#define LIO_REQTYPE_NORESP_NET_SG 2 -#define LIO_REQTYPE_SOFT_COMMAND 3 - -struct lio_request_list { - uint32_t reqtype; - void *buf; -}; - -/*---------------------- INSTRUCTION FORMAT ----------------------------*/ - -struct lio_instr3_64B { - /** Pointer where the input data is available. */ - uint64_t dptr; - - /** Instruction Header. */ - uint64_t ih3; - - /** Instruction Header. */ - uint64_t pki_ih3; - - /** Input Request Header. */ - uint64_t irh; - - /** opcode/subcode specific parameters */ - uint64_t ossp[2]; - - /** Return Data Parameters */ - uint64_t rdp; - - /** Pointer where the response for a RAW mode packet will be written - * by Octeon. - */ - uint64_t rptr; - -}; - -union lio_instr_64B { - struct lio_instr3_64B cmd3; -}; - -/** The size of each buffer in soft command buffer pool */ -#define LIO_SOFT_COMMAND_BUFFER_SIZE 1536 - -/** Maximum number of buffers to allocate into soft command buffer pool */ -#define LIO_MAX_SOFT_COMMAND_BUFFERS 255 - -struct lio_soft_command { - /** Soft command buffer info. */ - struct lio_stailq_node node; - uint64_t dma_addr; - uint32_t size; - - /** Command and return status */ - union lio_instr_64B cmd; - -#define LIO_COMPLETION_WORD_INIT 0xffffffffffffffffULL - uint64_t *status_word; - - /** Data buffer info */ - void *virtdptr; - uint64_t dmadptr; - uint32_t datasize; - - /** Return buffer info */ - void *virtrptr; - uint64_t dmarptr; - uint32_t rdatasize; - - /** Context buffer info */ - void *ctxptr; - uint32_t ctxsize; - - /** Time out and callback */ - size_t wait_time; - size_t timeout; - uint32_t iq_no; - void (*callback)(uint32_t, void *); - void *callback_arg; - struct rte_mbuf *mbuf; -}; - -struct lio_iq_post_status { - int status; - int index; -}; - -/* wqe - * --------------- 0 - * | wqe word0-3 | - * --------------- 32 - * | PCI IH | - * --------------- 40 - * | RPTR | - * --------------- 48 - * | PCI IRH | - * --------------- 56 - * | OCTEON_CMD | - * --------------- 64 - * | Addtl 8-BData | - * | | - * --------------- - */ - -union octeon_cmd { - uint64_t cmd64; - - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t cmd : 5; - - uint64_t more : 6; /* How many udd words follow the command */ - - uint64_t reserved : 29; - - uint64_t param1 : 16; - - uint64_t param2 : 8; - -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - - uint64_t param2 : 8; - - uint64_t param1 : 16; - - uint64_t reserved : 29; - - uint64_t more : 6; - - uint64_t cmd : 5; - -#endif - } s; -}; - -#define OCTEON_CMD_SIZE (sizeof(union octeon_cmd)) - -/* Maximum number of 8-byte words can be - * sent in a NIC control message. - */ -#define LIO_MAX_NCTRL_UDD 32 - -/* Structure of control information passed by driver to the BASE - * layer when sending control commands to Octeon device software. - */ -struct lio_ctrl_pkt { - /** Command to be passed to the Octeon device software. */ - union octeon_cmd ncmd; - - /** Send buffer */ - void *data; - uint64_t dmadata; - - /** Response buffer */ - void *rdata; - uint64_t dmardata; - - /** Additional data that may be needed by some commands. */ - uint64_t udd[LIO_MAX_NCTRL_UDD]; - - /** Input queue to use to send this command. */ - uint64_t iq_no; - - /** Time to wait for Octeon software to respond to this control command. - * If wait_time is 0, BASE assumes no response is expected. - */ - size_t wait_time; - - struct lio_dev_ctrl_cmd *ctrl_cmd; -}; - -/** Structure of data information passed by driver to the BASE - * layer when forwarding data to Octeon device software. - */ -struct lio_data_pkt { - /** Pointer to information maintained by NIC module for this packet. The - * BASE layer passes this as-is to the driver. - */ - void *buf; - - /** Type of buffer passed in "buf" above. */ - uint32_t reqtype; - - /** Total data bytes to be transferred in this command. */ - uint32_t datasize; - - /** Command to be passed to the Octeon device software. */ - union lio_instr_64B cmd; - - /** Input queue to use to send this command. */ - uint32_t q_no; -}; - -/** Structure passed by driver to BASE layer to prepare a command to send - * network data to Octeon. - */ -union lio_cmd_setup { - struct { - uint32_t iq_no : 8; - uint32_t gather : 1; - uint32_t timestamp : 1; - uint32_t ip_csum : 1; - uint32_t transport_csum : 1; - uint32_t tnl_csum : 1; - uint32_t rsvd : 19; - - union { - uint32_t datasize; - uint32_t gatherptrs; - } u; - } s; - - uint64_t cmd_setup64; -}; - -/* Instruction Header */ -struct octeon_instr_ih3 { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - - /** Reserved3 */ - uint64_t reserved3 : 1; - - /** Gather indicator 1=gather*/ - uint64_t gather : 1; - - /** Data length OR no. of entries in gather list */ - uint64_t dlengsz : 14; - - /** Front Data size */ - uint64_t fsz : 6; - - /** Reserved2 */ - uint64_t reserved2 : 4; - - /** PKI port kind - PKIND */ - uint64_t pkind : 6; - - /** Reserved1 */ - uint64_t reserved1 : 32; - -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - /** Reserved1 */ - uint64_t reserved1 : 32; - - /** PKI port kind - PKIND */ - uint64_t pkind : 6; - - /** Reserved2 */ - uint64_t reserved2 : 4; - - /** Front Data size */ - uint64_t fsz : 6; - - /** Data length OR no. of entries in gather list */ - uint64_t dlengsz : 14; - - /** Gather indicator 1=gather*/ - uint64_t gather : 1; - - /** Reserved3 */ - uint64_t reserved3 : 1; - -#endif -}; - -/* PKI Instruction Header(PKI IH) */ -struct octeon_instr_pki_ih3 { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - - /** Wider bit */ - uint64_t w : 1; - - /** Raw mode indicator 1 = RAW */ - uint64_t raw : 1; - - /** Use Tag */ - uint64_t utag : 1; - - /** Use QPG */ - uint64_t uqpg : 1; - - /** Reserved2 */ - uint64_t reserved2 : 1; - - /** Parse Mode */ - uint64_t pm : 3; - - /** Skip Length */ - uint64_t sl : 8; - - /** Use Tag Type */ - uint64_t utt : 1; - - /** Tag type */ - uint64_t tagtype : 2; - - /** Reserved1 */ - uint64_t reserved1 : 2; - - /** QPG Value */ - uint64_t qpg : 11; - - /** Tag Value */ - uint64_t tag : 32; - -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - - /** Tag Value */ - uint64_t tag : 32; - - /** QPG Value */ - uint64_t qpg : 11; - - /** Reserved1 */ - uint64_t reserved1 : 2; - - /** Tag type */ - uint64_t tagtype : 2; - - /** Use Tag Type */ - uint64_t utt : 1; - - /** Skip Length */ - uint64_t sl : 8; - - /** Parse Mode */ - uint64_t pm : 3; - - /** Reserved2 */ - uint64_t reserved2 : 1; - - /** Use QPG */ - uint64_t uqpg : 1; - - /** Use Tag */ - uint64_t utag : 1; - - /** Raw mode indicator 1 = RAW */ - uint64_t raw : 1; - - /** Wider bit */ - uint64_t w : 1; -#endif -}; - -/** Input Request Header */ -struct octeon_instr_irh { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t opcode : 4; - uint64_t rflag : 1; - uint64_t subcode : 7; - uint64_t vlan : 12; - uint64_t priority : 3; - uint64_t reserved : 5; - uint64_t ossp : 32; /* opcode/subcode specific parameters */ -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - uint64_t ossp : 32; /* opcode/subcode specific parameters */ - uint64_t reserved : 5; - uint64_t priority : 3; - uint64_t vlan : 12; - uint64_t subcode : 7; - uint64_t rflag : 1; - uint64_t opcode : 4; -#endif -}; - -/* pkiih3 + irh + ossp[0] + ossp[1] + rdp + rptr = 40 bytes */ -#define OCTEON_SOFT_CMD_RESP_IH3 (40 + 8) -/* pki_h3 + irh + ossp[0] + ossp[1] = 32 bytes */ -#define OCTEON_PCI_CMD_O3 (24 + 8) - -/** Return Data Parameters */ -struct octeon_instr_rdp { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t reserved : 49; - uint64_t pcie_port : 3; - uint64_t rlen : 12; -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - uint64_t rlen : 12; - uint64_t pcie_port : 3; - uint64_t reserved : 49; -#endif -}; - -union octeon_packet_params { - uint32_t pkt_params32; - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint32_t reserved : 24; - uint32_t ip_csum : 1; /* Perform IP header checksum(s) */ - /* Perform Outer transport header checksum */ - uint32_t transport_csum : 1; - /* Find tunnel, and perform transport csum. */ - uint32_t tnl_csum : 1; - uint32_t tsflag : 1; /* Timestamp this packet */ - uint32_t ipsec_ops : 4; /* IPsec operation */ -#else - uint32_t ipsec_ops : 4; - uint32_t tsflag : 1; - uint32_t tnl_csum : 1; - uint32_t transport_csum : 1; - uint32_t ip_csum : 1; - uint32_t reserved : 7; -#endif - } s; -}; - -/** Utility function to prepare a 64B NIC instruction based on a setup command - * @param cmd - pointer to instruction to be filled in. - * @param setup - pointer to the setup structure - * @param q_no - which queue for back pressure - * - * Assumes the cmd instruction is pre-allocated, but no fields are filled in. - */ -static inline void -lio_prepare_pci_cmd(struct lio_device *lio_dev, - union lio_instr_64B *cmd, - union lio_cmd_setup *setup, - uint32_t tag) -{ - union octeon_packet_params packet_params; - struct octeon_instr_pki_ih3 *pki_ih3; - struct octeon_instr_irh *irh; - struct octeon_instr_ih3 *ih3; - int port; - - memset(cmd, 0, sizeof(union lio_instr_64B)); - - ih3 = (struct octeon_instr_ih3 *)&cmd->cmd3.ih3; - pki_ih3 = (struct octeon_instr_pki_ih3 *)&cmd->cmd3.pki_ih3; - - /* assume that rflag is cleared so therefore front data will only have - * irh and ossp[1] and ossp[2] for a total of 24 bytes - */ - ih3->pkind = lio_dev->instr_queue[setup->s.iq_no]->txpciq.s.pkind; - /* PKI IH */ - ih3->fsz = OCTEON_PCI_CMD_O3; - - if (!setup->s.gather) { - ih3->dlengsz = setup->s.u.datasize; - } else { - ih3->gather = 1; - ih3->dlengsz = setup->s.u.gatherptrs; - } - - pki_ih3->w = 1; - pki_ih3->raw = 0; - pki_ih3->utag = 0; - pki_ih3->utt = 1; - pki_ih3->uqpg = lio_dev->instr_queue[setup->s.iq_no]->txpciq.s.use_qpg; - - port = (int)lio_dev->instr_queue[setup->s.iq_no]->txpciq.s.port; - - if (tag) - pki_ih3->tag = tag; - else - pki_ih3->tag = LIO_DATA(port); - - pki_ih3->tagtype = OCTEON_ORDERED_TAG; - pki_ih3->qpg = lio_dev->instr_queue[setup->s.iq_no]->txpciq.s.qpg; - pki_ih3->pm = 0x0; /* parse from L2 */ - pki_ih3->sl = 32; /* sl will be sizeof(pki_ih3) + irh + ossp0 + ossp1*/ - - irh = (struct octeon_instr_irh *)&cmd->cmd3.irh; - - irh->opcode = LIO_OPCODE; - irh->subcode = LIO_OPCODE_NW_DATA; - - packet_params.pkt_params32 = 0; - packet_params.s.ip_csum = setup->s.ip_csum; - packet_params.s.transport_csum = setup->s.transport_csum; - packet_params.s.tnl_csum = setup->s.tnl_csum; - packet_params.s.tsflag = setup->s.timestamp; - - irh->ossp = packet_params.pkt_params32; -} - -int lio_setup_sc_buffer_pool(struct lio_device *lio_dev); -void lio_free_sc_buffer_pool(struct lio_device *lio_dev); - -struct lio_soft_command * -lio_alloc_soft_command(struct lio_device *lio_dev, - uint32_t datasize, uint32_t rdatasize, - uint32_t ctxsize); -void lio_prepare_soft_command(struct lio_device *lio_dev, - struct lio_soft_command *sc, - uint8_t opcode, uint8_t subcode, - uint32_t irh_ossp, uint64_t ossp0, - uint64_t ossp1); -int lio_send_soft_command(struct lio_device *lio_dev, - struct lio_soft_command *sc); -void lio_free_soft_command(struct lio_soft_command *sc); - -/** Send control packet to the device - * @param lio_dev - lio device pointer - * @param nctrl - control structure with command, timeout, and callback info - * - * @returns IQ_FAILED if it failed to add to the input queue. IQ_STOP if it the - * queue should be stopped, and LIO_IQ_SEND_OK if it sent okay. - */ -int lio_send_ctrl_pkt(struct lio_device *lio_dev, - struct lio_ctrl_pkt *ctrl_pkt); - -/** Maximum ordered requests to process in every invocation of - * lio_process_ordered_list(). The function will continue to process requests - * as long as it can find one that has finished processing. If it keeps - * finding requests that have completed, the function can run for ever. The - * value defined here sets an upper limit on the number of requests it can - * process before it returns control to the poll thread. - */ -#define LIO_MAX_ORD_REQS_TO_PROCESS 4096 - -/** Error codes used in Octeon Host-Core communication. - * - * 31 16 15 0 - * ---------------------------- - * | | | - * ---------------------------- - * Error codes are 32-bit wide. The upper 16-bits, called Major Error Number, - * are reserved to identify the group to which the error code belongs. The - * lower 16-bits, called Minor Error Number, carry the actual code. - * - * So error codes are (MAJOR NUMBER << 16)| MINOR_NUMBER. - */ -/** Status for a request. - * If the request is successfully queued, the driver will return - * a LIO_REQUEST_PENDING status. LIO_REQUEST_TIMEOUT is only returned by - * the driver if the response for request failed to arrive before a - * time-out period or if the request processing * got interrupted due to - * a signal respectively. - */ -enum { - /** A value of 0x00000000 indicates no error i.e. success */ - LIO_REQUEST_DONE = 0x00000000, - /** (Major number: 0x0000; Minor Number: 0x0001) */ - LIO_REQUEST_PENDING = 0x00000001, - LIO_REQUEST_TIMEOUT = 0x00000003, - -}; - -/*------ Error codes used by firmware (bits 15..0 set by firmware */ -#define LIO_FIRMWARE_MAJOR_ERROR_CODE 0x0001 -#define LIO_FIRMWARE_STATUS_CODE(status) \ - ((LIO_FIRMWARE_MAJOR_ERROR_CODE << 16) | (status)) - -/** Initialize the response lists. The number of response lists to create is - * given by count. - * @param lio_dev - the lio device structure. - */ -void lio_setup_response_list(struct lio_device *lio_dev); - -/** Check the status of first entry in the ordered list. If the instruction at - * that entry finished processing or has timed-out, the entry is cleaned. - * @param lio_dev - the lio device structure. - * @return 1 if the ordered list is empty, 0 otherwise. - */ -int lio_process_ordered_list(struct lio_device *lio_dev); - -#define LIO_INCR_INSTRQUEUE_PKT_COUNT(lio_dev, iq_no, field, count) \ - (((lio_dev)->instr_queue[iq_no]->stats.field) += count) - -static inline void -lio_swap_8B_data(uint64_t *data, uint32_t blocks) -{ - while (blocks) { - *data = rte_cpu_to_be_64(*data); - blocks--; - data++; - } -} - -static inline uint64_t -lio_map_ring(void *buf) -{ - rte_iova_t dma_addr; - - dma_addr = rte_mbuf_data_iova_default(((struct rte_mbuf *)buf)); - - return (uint64_t)dma_addr; -} - -static inline uint64_t -lio_map_ring_info(struct lio_droq *droq, uint32_t i) -{ - rte_iova_t dma_addr; - - dma_addr = droq->info_list_dma + (i * LIO_DROQ_INFO_SIZE); - - return (uint64_t)dma_addr; -} - -static inline int -lio_opcode_slow_path(union octeon_rh *rh) -{ - uint16_t subcode1, subcode2; - - subcode1 = LIO_OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode); - subcode2 = LIO_OPCODE_SUBCODE(LIO_OPCODE, LIO_OPCODE_NW_DATA); - - return subcode2 != subcode1; -} - -static inline void -lio_add_sg_size(struct lio_sg_entry *sg_entry, - uint16_t size, uint32_t pos) -{ -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - sg_entry->u.size[pos] = size; -#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - sg_entry->u.size[3 - pos] = size; -#endif -} - -/* Macro to increment index. - * Index is incremented by count; if the sum exceeds - * max, index is wrapped-around to the start. - */ -static inline uint32_t -lio_incr_index(uint32_t index, uint32_t count, uint32_t max) -{ - if ((index + count) >= max) - index = index + count - max; - else - index += count; - - return index; -} - -int lio_setup_droq(struct lio_device *lio_dev, int q_no, int num_descs, - int desc_size, struct rte_mempool *mpool, - unsigned int socket_id); -uint16_t lio_dev_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t budget); -void lio_delete_droq_queue(struct lio_device *lio_dev, int oq_no); - -void lio_delete_sglist(struct lio_instr_queue *txq); -int lio_setup_sglists(struct lio_device *lio_dev, int iq_no, - int fw_mapped_iq, int num_descs, unsigned int socket_id); -uint16_t lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, - uint16_t nb_pkts); -int lio_wait_for_instr_fetch(struct lio_device *lio_dev); -int lio_setup_iq(struct lio_device *lio_dev, int q_index, - union octeon_txpciq iq_no, uint32_t num_descs, void *app_ctx, - unsigned int socket_id); -int lio_flush_iq(struct lio_device *lio_dev, struct lio_instr_queue *iq); -void lio_delete_instruction_queue(struct lio_device *lio_dev, int iq_no); -/** Setup instruction queue zero for the device - * @param lio_dev which lio device to setup - * - * @return 0 if success. -1 if fails - */ -int lio_setup_instr_queue0(struct lio_device *lio_dev); -void lio_free_instr_queue0(struct lio_device *lio_dev); -void lio_dev_clear_queues(struct rte_eth_dev *eth_dev); -#endif /* _LIO_RXTX_H_ */ diff --git a/dpdk/drivers/net/liquidio/lio_struct.h b/dpdk/drivers/net/liquidio/lio_struct.h deleted file mode 100644 index 10270c560..000000000 --- a/dpdk/drivers/net/liquidio/lio_struct.h +++ /dev/null @@ -1,661 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Cavium, Inc - */ - -#ifndef _LIO_STRUCT_H_ -#define _LIO_STRUCT_H_ - -#include -#include -#include - -#include -#include - -#include "lio_hw_defs.h" - -struct lio_stailq_node { - STAILQ_ENTRY(lio_stailq_node) entries; -}; - -STAILQ_HEAD(lio_stailq_head, lio_stailq_node); - -struct lio_version { - uint16_t major; - uint16_t minor; - uint16_t micro; - uint16_t reserved; -}; - -/** Input Queue statistics. Each input queue has four stats fields. */ -struct lio_iq_stats { - uint64_t instr_posted; /**< Instructions posted to this queue. */ - uint64_t instr_processed; /**< Instructions processed in this queue. */ - uint64_t instr_dropped; /**< Instructions that could not be processed */ - uint64_t bytes_sent; /**< Bytes sent through this queue. */ - uint64_t tx_done; /**< Num of packets sent to network. */ - uint64_t tx_iq_busy; /**< Num of times this iq was found to be full. */ - uint64_t tx_dropped; /**< Num of pkts dropped due to xmitpath errors. */ - uint64_t tx_tot_bytes; /**< Total count of bytes sent to network. */ -}; - -/** Output Queue statistics. Each output queue has four stats fields. */ -struct lio_droq_stats { - /** Number of packets received in this queue. */ - uint64_t pkts_received; - - /** Bytes received by this queue. */ - uint64_t bytes_received; - - /** Packets dropped due to no memory available. */ - uint64_t dropped_nomem; - - /** Packets dropped due to large number of pkts to process. */ - uint64_t dropped_toomany; - - /** Number of packets sent to stack from this queue. */ - uint64_t rx_pkts_received; - - /** Number of Bytes sent to stack from this queue. */ - uint64_t rx_bytes_received; - - /** Num of Packets dropped due to receive path failures. */ - uint64_t rx_dropped; - - /** Num of vxlan packets received; */ - uint64_t rx_vxlan; - - /** Num of failures of rte_pktmbuf_alloc() */ - uint64_t rx_alloc_failure; - -}; - -/** The Descriptor Ring Output Queue structure. - * This structure has all the information required to implement a - * DROQ. - */ -struct lio_droq { - /** A spinlock to protect access to this ring. */ - rte_spinlock_t lock; - - uint32_t q_no; - - uint32_t pkt_count; - - struct lio_device *lio_dev; - - /** The 8B aligned descriptor ring starts at this address. */ - struct lio_droq_desc *desc_ring; - - /** Index in the ring where the driver should read the next packet */ - uint32_t read_idx; - - /** Index in the ring where Octeon will write the next packet */ - uint32_t write_idx; - - /** Index in the ring where the driver will refill the descriptor's - * buffer - */ - uint32_t refill_idx; - - /** Packets pending to be processed */ - rte_atomic64_t pkts_pending; - - /** Number of descriptors in this ring. */ - uint32_t nb_desc; - - /** The number of descriptors pending refill. */ - uint32_t refill_count; - - uint32_t refill_threshold; - - /** The 8B aligned info ptrs begin from this address. */ - struct lio_droq_info *info_list; - - /** The receive buffer list. This list has the virtual addresses of the - * buffers. - */ - struct lio_recv_buffer *recv_buf_list; - - /** The size of each buffer pointed by the buffer pointer. */ - uint32_t buffer_size; - - /** Pointer to the mapped packet credit register. - * Host writes number of info/buffer ptrs available to this register - */ - void *pkts_credit_reg; - - /** Pointer to the mapped packet sent register. - * Octeon writes the number of packets DMA'ed to host memory - * in this register. - */ - void *pkts_sent_reg; - - /** Statistics for this DROQ. */ - struct lio_droq_stats stats; - - /** DMA mapped address of the DROQ descriptor ring. */ - size_t desc_ring_dma; - - /** Info ptr list are allocated at this virtual address. */ - size_t info_base_addr; - - /** DMA mapped address of the info list */ - size_t info_list_dma; - - /** Allocated size of info list. */ - uint32_t info_alloc_size; - - /** Memory zone **/ - const struct rte_memzone *desc_ring_mz; - const struct rte_memzone *info_mz; - struct rte_mempool *mpool; -}; - -/** Receive Header */ -union octeon_rh { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t rh64; - struct { - uint64_t opcode : 4; - uint64_t subcode : 8; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t reserved : 17; - uint64_t ossp : 32; /** opcode/subcode specific parameters */ - } r; - struct { - uint64_t opcode : 4; - uint64_t subcode : 8; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t extra : 28; - uint64_t vlan : 12; - uint64_t priority : 3; - uint64_t csum_verified : 3; /** checksum verified. */ - uint64_t has_hwtstamp : 1; /** Has hardware timestamp.1 = yes.*/ - uint64_t encap_on : 1; - uint64_t has_hash : 1; /** Has hash (rth or rss). 1 = yes. */ - } r_dh; - struct { - uint64_t opcode : 4; - uint64_t subcode : 8; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t reserved : 8; - uint64_t extra : 25; - uint64_t gmxport : 16; - } r_nic_info; -#else - uint64_t rh64; - struct { - uint64_t ossp : 32; /** opcode/subcode specific parameters */ - uint64_t reserved : 17; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t subcode : 8; - uint64_t opcode : 4; - } r; - struct { - uint64_t has_hash : 1; /** Has hash (rth or rss). 1 = yes. */ - uint64_t encap_on : 1; - uint64_t has_hwtstamp : 1; /** 1 = has hwtstamp */ - uint64_t csum_verified : 3; /** checksum verified. */ - uint64_t priority : 3; - uint64_t vlan : 12; - uint64_t extra : 28; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t subcode : 8; - uint64_t opcode : 4; - } r_dh; - struct { - uint64_t gmxport : 16; - uint64_t extra : 25; - uint64_t reserved : 8; - uint64_t len : 3; /** additional 64-bit words */ - uint64_t subcode : 8; - uint64_t opcode : 4; - } r_nic_info; -#endif -}; - -#define OCTEON_RH_SIZE (sizeof(union octeon_rh)) - -/** The txpciq info passed to host from the firmware */ -union octeon_txpciq { - uint64_t txpciq64; - - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t q_no : 8; - uint64_t port : 8; - uint64_t pkind : 6; - uint64_t use_qpg : 1; - uint64_t qpg : 11; - uint64_t aura_num : 10; - uint64_t reserved : 20; -#else - uint64_t reserved : 20; - uint64_t aura_num : 10; - uint64_t qpg : 11; - uint64_t use_qpg : 1; - uint64_t pkind : 6; - uint64_t port : 8; - uint64_t q_no : 8; -#endif - } s; -}; - -/** The instruction (input) queue. - * The input queue is used to post raw (instruction) mode data or packet - * data to Octeon device from the host. Each input queue for - * a LIO device has one such structure to represent it. - */ -struct lio_instr_queue { - /** A spinlock to protect access to the input ring. */ - rte_spinlock_t lock; - - rte_spinlock_t post_lock; - - struct lio_device *lio_dev; - - uint32_t pkt_in_done; - - rte_atomic64_t iq_flush_running; - - /** Flag that indicates if the queue uses 64 byte commands. */ - uint32_t iqcmd_64B:1; - - /** Queue info. */ - union octeon_txpciq txpciq; - - uint32_t rsvd:17; - - uint32_t status:8; - - /** Number of descriptors in this ring. */ - uint32_t nb_desc; - - /** Index in input ring where the driver should write the next packet */ - uint32_t host_write_index; - - /** Index in input ring where Octeon is expected to read the next - * packet. - */ - uint32_t lio_read_index; - - /** This index aids in finding the window in the queue where Octeon - * has read the commands. - */ - uint32_t flush_index; - - /** This field keeps track of the instructions pending in this queue. */ - rte_atomic64_t instr_pending; - - /** Pointer to the Virtual Base addr of the input ring. */ - uint8_t *base_addr; - - struct lio_request_list *request_list; - - /** Octeon doorbell register for the ring. */ - void *doorbell_reg; - - /** Octeon instruction count register for this ring. */ - void *inst_cnt_reg; - - /** Number of instructions pending to be posted to Octeon. */ - uint32_t fill_cnt; - - /** Statistics for this input queue. */ - struct lio_iq_stats stats; - - /** DMA mapped base address of the input descriptor ring. */ - uint64_t base_addr_dma; - - /** Application context */ - void *app_ctx; - - /* network stack queue index */ - int q_index; - - /* Memory zone */ - const struct rte_memzone *iq_mz; -}; - -/** This structure is used by driver to store information required - * to free the mbuff when the packet has been fetched by Octeon. - * Bytes offset below assume worst-case of a 64-bit system. - */ -struct lio_buf_free_info { - /** Bytes 1-8. Pointer to network device private structure. */ - struct lio_device *lio_dev; - - /** Bytes 9-16. Pointer to mbuff. */ - struct rte_mbuf *mbuf; - - /** Bytes 17-24. Pointer to gather list. */ - struct lio_gather *g; - - /** Bytes 25-32. Physical address of mbuf->data or gather list. */ - uint64_t dptr; - - /** Bytes 33-47. Piggybacked soft command, if any */ - struct lio_soft_command *sc; - - /** Bytes 48-63. iq no */ - uint64_t iq_no; -}; - -/* The Scatter-Gather List Entry. The scatter or gather component used with - * input instruction has this format. - */ -struct lio_sg_entry { - /** The first 64 bit gives the size of data in each dptr. */ - union { - uint16_t size[4]; - uint64_t size64; - } u; - - /** The 4 dptr pointers for this entry. */ - uint64_t ptr[4]; -}; - -#define LIO_SG_ENTRY_SIZE (sizeof(struct lio_sg_entry)) - -/** Structure of a node in list of gather components maintained by - * driver for each network device. - */ -struct lio_gather { - /** List manipulation. Next and prev pointers. */ - struct lio_stailq_node list; - - /** Size of the gather component at sg in bytes. */ - int sg_size; - - /** Number of bytes that sg was adjusted to make it 8B-aligned. */ - int adjust; - - /** Gather component that can accommodate max sized fragment list - * received from the IP layer. - */ - struct lio_sg_entry *sg; -}; - -struct lio_rss_ctx { - uint16_t hash_key_size; - uint8_t hash_key[LIO_RSS_MAX_KEY_SZ]; - /* Ideally a factor of number of queues */ - uint8_t itable[LIO_RSS_MAX_TABLE_SZ]; - uint8_t itable_size; - uint8_t ip; - uint8_t tcp_hash; - uint8_t ipv6; - uint8_t ipv6_tcp_hash; - uint8_t ipv6_ex; - uint8_t ipv6_tcp_ex_hash; - uint8_t hash_disable; -}; - -struct lio_io_enable { - uint64_t iq; - uint64_t oq; - uint64_t iq64B; -}; - -struct lio_fn_list { - void (*setup_iq_regs)(struct lio_device *, uint32_t); - void (*setup_oq_regs)(struct lio_device *, uint32_t); - - int (*setup_mbox)(struct lio_device *); - void (*free_mbox)(struct lio_device *); - - int (*setup_device_regs)(struct lio_device *); - int (*enable_io_queues)(struct lio_device *); - void (*disable_io_queues)(struct lio_device *); -}; - -struct lio_pf_vf_hs_word { -#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN - /** PKIND value assigned for the DPI interface */ - uint64_t pkind : 8; - - /** OCTEON core clock multiplier */ - uint64_t core_tics_per_us : 16; - - /** OCTEON coprocessor clock multiplier */ - uint64_t coproc_tics_per_us : 16; - - /** app that currently running on OCTEON */ - uint64_t app_mode : 8; - - /** RESERVED */ - uint64_t reserved : 16; - -#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN - - /** RESERVED */ - uint64_t reserved : 16; - - /** app that currently running on OCTEON */ - uint64_t app_mode : 8; - - /** OCTEON coprocessor clock multiplier */ - uint64_t coproc_tics_per_us : 16; - - /** OCTEON core clock multiplier */ - uint64_t core_tics_per_us : 16; - - /** PKIND value assigned for the DPI interface */ - uint64_t pkind : 8; -#endif -}; - -struct lio_sriov_info { - /** Number of rings assigned to VF */ - uint32_t rings_per_vf; - - /** Number of VF devices enabled */ - uint32_t num_vfs; -}; - -/* Head of a response list */ -struct lio_response_list { - /** List structure to add delete pending entries to */ - struct lio_stailq_head head; - - /** A lock for this response list */ - rte_spinlock_t lock; - - rte_atomic64_t pending_req_count; -}; - -/* Structure to define the configuration attributes for each Input queue. */ -struct lio_iq_config { - /* Max number of IQs available */ - uint8_t max_iqs; - - /** Pending list size (usually set to the sum of the size of all Input - * queues) - */ - uint32_t pending_list_size; - - /** Command size - 32 or 64 bytes */ - uint32_t instr_type; -}; - -/* Structure to define the configuration attributes for each Output queue. */ -struct lio_oq_config { - /* Max number of OQs available */ - uint8_t max_oqs; - - /** If set, the Output queue uses info-pointer mode. (Default: 1 ) */ - uint32_t info_ptr; - - /** The number of buffers that were consumed during packet processing by - * the driver on this Output queue before the driver attempts to - * replenish the descriptor ring with new buffers. - */ - uint32_t refill_threshold; -}; - -/* Structure to define the configuration. */ -struct lio_config { - uint16_t card_type; - const char *card_name; - - /** Input Queue attributes. */ - struct lio_iq_config iq; - - /** Output Queue attributes. */ - struct lio_oq_config oq; - - int num_nic_ports; - - int num_def_tx_descs; - - /* Num of desc for rx rings */ - int num_def_rx_descs; - - int def_rx_buf_size; -}; - -/** Status of a RGMII Link on Octeon as seen by core driver. */ -union octeon_link_status { - uint64_t link_status64; - - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t duplex : 8; - uint64_t mtu : 16; - uint64_t speed : 16; - uint64_t link_up : 1; - uint64_t autoneg : 1; - uint64_t if_mode : 5; - uint64_t pause : 1; - uint64_t flashing : 1; - uint64_t reserved : 15; -#else - uint64_t reserved : 15; - uint64_t flashing : 1; - uint64_t pause : 1; - uint64_t if_mode : 5; - uint64_t autoneg : 1; - uint64_t link_up : 1; - uint64_t speed : 16; - uint64_t mtu : 16; - uint64_t duplex : 8; -#endif - } s; -}; - -/** The rxpciq info passed to host from the firmware */ -union octeon_rxpciq { - uint64_t rxpciq64; - - struct { -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t q_no : 8; - uint64_t reserved : 56; -#else - uint64_t reserved : 56; - uint64_t q_no : 8; -#endif - } s; -}; - -/** Information for a OCTEON ethernet interface shared between core & host. */ -struct octeon_link_info { - union octeon_link_status link; - uint64_t hw_addr; - -#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN - uint64_t gmxport : 16; - uint64_t macaddr_is_admin_assigned : 1; - uint64_t vlan_is_admin_assigned : 1; - uint64_t rsvd : 30; - uint64_t num_txpciq : 8; - uint64_t num_rxpciq : 8; -#else - uint64_t num_rxpciq : 8; - uint64_t num_txpciq : 8; - uint64_t rsvd : 30; - uint64_t vlan_is_admin_assigned : 1; - uint64_t macaddr_is_admin_assigned : 1; - uint64_t gmxport : 16; -#endif - - union octeon_txpciq txpciq[LIO_MAX_IOQS_PER_IF]; - union octeon_rxpciq rxpciq[LIO_MAX_IOQS_PER_IF]; -}; - -/* ----------------------- THE LIO DEVICE --------------------------- */ -/** The lio device. - * Each lio device has this structure to represent all its - * components. - */ -struct lio_device { - /** PCI device pointer */ - struct rte_pci_device *pci_dev; - - /** Octeon Chip type */ - uint16_t chip_id; - uint16_t pf_num; - uint16_t vf_num; - - /** This device's PCIe port used for traffic. */ - uint16_t pcie_port; - - /** The state of this device */ - rte_atomic64_t status; - - uint8_t intf_open; - - struct octeon_link_info linfo; - - uint8_t *hw_addr; - - struct lio_fn_list fn_list; - - uint32_t num_iqs; - - /** Guards each glist */ - rte_spinlock_t *glist_lock; - /** Array of gather component linked lists */ - struct lio_stailq_head *glist_head; - - /* The pool containing pre allocated buffers used for soft commands */ - struct rte_mempool *sc_buf_pool; - - /** The input instruction queues */ - struct lio_instr_queue *instr_queue[LIO_MAX_POSSIBLE_INSTR_QUEUES]; - - /** The singly-linked tail queues of instruction response */ - struct lio_response_list response_list; - - uint32_t num_oqs; - - /** The DROQ output queues */ - struct lio_droq *droq[LIO_MAX_POSSIBLE_OUTPUT_QUEUES]; - - struct lio_io_enable io_qmask; - - struct lio_sriov_info sriov_info; - - struct lio_pf_vf_hs_word pfvf_hsword; - - /** Mail Box details of each lio queue. */ - struct lio_mbox **mbox; - - char dev_string[LIO_DEVICE_NAME_LEN]; /* Device print string */ - - const struct lio_config *default_config; - - struct rte_eth_dev *eth_dev; - - uint64_t ifflags; - uint8_t max_rx_queues; - uint8_t max_tx_queues; - uint8_t nb_rx_queues; - uint8_t nb_tx_queues; - uint8_t port_configured; - struct lio_rss_ctx rss_state; - uint16_t port_id; - char firmware_version[LIO_FW_VERSION_LENGTH]; -}; -#endif /* _LIO_STRUCT_H_ */ diff --git a/dpdk/drivers/net/liquidio/meson.build b/dpdk/drivers/net/liquidio/meson.build deleted file mode 100644 index ebadbf3de..000000000 --- a/dpdk/drivers/net/liquidio/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2018 Intel Corporation - -if is_windows - build = false - reason = 'not supported on Windows' - subdir_done() -endif - -sources = files( - 'base/lio_23xx_vf.c', - 'base/lio_mbox.c', - 'lio_ethdev.c', - 'lio_rxtx.c', -) -includes += include_directories('base') diff --git a/dpdk/drivers/net/nfp/nfp_common.c b/dpdk/drivers/net/nfp/nfp_common.c deleted file mode 100644 index 33613bb2b..000000000 --- a/dpdk/drivers/net/nfp/nfp_common.c +++ /dev/null @@ -1,1445 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2014-2018 Netronome Systems, Inc. - * All rights reserved. - * - * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation. - */ - -/* - * vim:shiftwidth=8:noexpandtab - * - * @file dpdk/pmd/nfp_common.c - * - * Netronome vNIC DPDK Poll-Mode Driver: Common files - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nfpcore/nfp_cpp.h" -#include "nfpcore/nfp_nffw.h" -#include "nfpcore/nfp_hwinfo.h" -#include "nfpcore/nfp_mip.h" -#include "nfpcore/nfp_rtsym.h" -#include "nfpcore/nfp_nsp.h" - -#include "flower/nfp_flower_representor.h" - -#include "nfp_common.h" -#include "nfp_ctrl.h" -#include "nfp_rxtx.h" -#include "nfp_logs.h" -#include "nfp_cpp_bridge.h" - -#include -#include -#include -#include -#include -#include -#include - -static int -__nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t update) -{ - int cnt; - uint32_t new; - struct timespec wait; - - PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...", - hw->qcp_cfg); - - if (hw->qcp_cfg == NULL) - rte_panic("Bad configuration queue pointer\n"); - - nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1); - - wait.tv_sec = 0; - wait.tv_nsec = 1000000; - - PMD_DRV_LOG(DEBUG, "Polling for update ack..."); - - /* Poll update field, waiting for NFP to ack the config */ - for (cnt = 0; ; cnt++) { - new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE); - if (new == 0) - break; - if (new & NFP_NET_CFG_UPDATE_ERR) { - PMD_INIT_LOG(ERR, "Reconfig error: 0x%08x", new); - return -1; - } - if (cnt >= NFP_NET_POLL_TIMEOUT) { - PMD_INIT_LOG(ERR, "Reconfig timeout for 0x%08x after" - " %dms", update, cnt); - rte_panic("Exiting\n"); - } - nanosleep(&wait, 0); /* waiting for a 1ms */ - } - PMD_DRV_LOG(DEBUG, "Ack DONE"); - return 0; -} - -/* - * Reconfigure the NIC - * @nn: device to reconfigure - * @ctrl: The value for the ctrl field in the BAR config - * @update: The value for the update field in the BAR config - * - * Write the update word to the BAR and ping the reconfig queue. Then poll - * until the firmware has acknowledged the update by zeroing the update word. - */ -int -nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update) -{ - uint32_t err; - - PMD_DRV_LOG(DEBUG, "nfp_net_reconfig: ctrl=%08x update=%08x", - ctrl, update); - - rte_spinlock_lock(&hw->reconfig_lock); - - nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl); - nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update); - - rte_wmb(); - - err = __nfp_net_reconfig(hw, update); - - rte_spinlock_unlock(&hw->reconfig_lock); - - if (!err) - return 0; - - /* - * Reconfig errors imply situations where they can be handled. - * Otherwise, rte_panic is called inside __nfp_net_reconfig - */ - PMD_INIT_LOG(ERR, "Error nfp_net reconfig for ctrl: %x update: %x", - ctrl, update); - return -EIO; -} - -/* - * Configure an Ethernet device. This function must be invoked first - * before any other function in the Ethernet API. This function can - * also be re-invoked when a device is in the stopped state. - */ -int -nfp_net_configure(struct rte_eth_dev *dev) -{ - struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct rte_eth_txmode *txmode; - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* - * A DPDK app sends info about how many queues to use and how - * those queues need to be configured. This is used by the - * DPDK core and it makes sure no more queues than those - * advertised by the driver are requested. This function is - * called after that internal process - */ - - PMD_INIT_LOG(DEBUG, "Configure"); - - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - txmode = &dev_conf->txmode; - - if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) - rxmode->offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; - - /* Checking TX mode */ - if (txmode->mq_mode) { - PMD_INIT_LOG(INFO, "TX mq_mode DCB and VMDq not supported"); - return -EINVAL; - } - - /* Checking RX mode */ - if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS && - !(hw->cap & NFP_NET_CFG_CTRL_RSS_ANY)) { - PMD_INIT_LOG(INFO, "RSS not supported"); - return -EINVAL; - } - - /* Checking MTU set */ - if (rxmode->mtu > NFP_FRAME_SIZE_MAX) { - PMD_INIT_LOG(ERR, "MTU (%u) larger than NFP_FRAME_SIZE_MAX (%u) not supported", - rxmode->mtu, NFP_FRAME_SIZE_MAX); - return -ERANGE; - } - - return 0; -} - -void -nfp_net_enable_queues(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - uint64_t enabled_queues = 0; - int i; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* Enabling the required TX queues in the device */ - for (i = 0; i < dev->data->nb_tx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues); - - enabled_queues = 0; - - /* Enabling the required RX queues in the device */ - for (i = 0; i < dev->data->nb_rx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues); -} - -void -nfp_net_disable_queues(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - uint32_t new_ctrl, update = 0; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0); - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0); - - new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE; - update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | - NFP_NET_CFG_UPDATE_MSIX; - - if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) - new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG; - - /* If an error when reconfig we avoid to change hw state */ - if (nfp_net_reconfig(hw, new_ctrl, update) < 0) - return; - - hw->ctrl = new_ctrl; -} - -void -nfp_net_params_setup(struct nfp_net_hw *hw) -{ - nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu); - nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz); -} - -void -nfp_net_cfg_queue_setup(struct nfp_net_hw *hw) -{ - hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ; -} - -#define ETH_ADDR_LEN 6 - -void -nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src) -{ - int i; - - for (i = 0; i < ETH_ADDR_LEN; i++) - dst[i] = src[i]; -} - -void -nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac) -{ - uint32_t mac0 = *(uint32_t *)mac; - uint16_t mac1; - - nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR); - - mac += 4; - mac1 = *(uint16_t *)mac; - nn_writew(rte_cpu_to_be_16(mac1), - hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6); -} - -int -nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) -{ - struct nfp_net_hw *hw; - uint32_t update, new_ctrl; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) && - !(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR)) { - PMD_INIT_LOG(INFO, "MAC address unable to change when" - " port enabled"); - return -EBUSY; - } - - /* Writing new MAC to the specific port BAR address */ - nfp_net_write_mac(hw, (uint8_t *)mac_addr); - - /* Signal the NIC about the change */ - update = NFP_NET_CFG_UPDATE_MACADDR; - new_ctrl = hw->ctrl; - if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) && - (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR)) - new_ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR; - - if (nfp_net_reconfig(hw, new_ctrl, update) < 0) { - PMD_INIT_LOG(INFO, "MAC address update failed"); - return -EIO; - } - - hw->ctrl = new_ctrl; - - return 0; -} - -int -nfp_configure_rx_interrupt(struct rte_eth_dev *dev, - struct rte_intr_handle *intr_handle) -{ - struct nfp_net_hw *hw; - int i; - - if (rte_intr_vec_list_alloc(intr_handle, "intr_vec", - dev->data->nb_rx_queues)) { - PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues" - " intr_vec", dev->data->nb_rx_queues); - return -ENOMEM; - } - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { - PMD_INIT_LOG(INFO, "VF: enabling RX interrupt with UIO"); - /* UIO just supports one queue and no LSC*/ - nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(0), 0); - if (rte_intr_vec_list_index_set(intr_handle, 0, 0)) - return -1; - } else { - PMD_INIT_LOG(INFO, "VF: enabling RX interrupt with VFIO"); - for (i = 0; i < dev->data->nb_rx_queues; i++) { - /* - * The first msix vector is reserved for non - * efd interrupts - */ - nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(i), i + 1); - if (rte_intr_vec_list_index_set(intr_handle, i, - i + 1)) - return -1; - PMD_INIT_LOG(DEBUG, "intr_vec[%d]= %d", i, - rte_intr_vec_list_index_get(intr_handle, - i)); - } - } - - /* Avoiding TX interrupts */ - hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF; - return 0; -} - -uint32_t -nfp_check_offloads(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct rte_eth_txmode *txmode; - uint32_t ctrl = 0; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - txmode = &dev_conf->txmode; - - if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) { - if (hw->cap & NFP_NET_CFG_CTRL_RXCSUM) - ctrl |= NFP_NET_CFG_CTRL_RXCSUM; - } - - if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) { - if (hw->cap & NFP_NET_CFG_CTRL_RXVLAN) - ctrl |= NFP_NET_CFG_CTRL_RXVLAN; - } - - hw->mtu = dev->data->mtu; - - if (txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) - ctrl |= NFP_NET_CFG_CTRL_TXVLAN; - - /* L2 broadcast */ - if (hw->cap & NFP_NET_CFG_CTRL_L2BC) - ctrl |= NFP_NET_CFG_CTRL_L2BC; - - /* L2 multicast */ - if (hw->cap & NFP_NET_CFG_CTRL_L2MC) - ctrl |= NFP_NET_CFG_CTRL_L2MC; - - /* TX checksum offload */ - if (txmode->offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM || - txmode->offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM || - txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) - ctrl |= NFP_NET_CFG_CTRL_TXCSUM; - - /* LSO offload */ - if (txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO) { - if (hw->cap & NFP_NET_CFG_CTRL_LSO) - ctrl |= NFP_NET_CFG_CTRL_LSO; - else - ctrl |= NFP_NET_CFG_CTRL_LSO2; - } - - /* RX gather */ - if (txmode->offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) - ctrl |= NFP_NET_CFG_CTRL_GATHER; - - return ctrl; -} - -int -nfp_net_promisc_enable(struct rte_eth_dev *dev) -{ - uint32_t new_ctrl, update = 0; - struct nfp_net_hw *hw; - int ret; - struct nfp_flower_representor *repr; - - PMD_DRV_LOG(DEBUG, "Promiscuous mode enable"); - - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - } else { - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - } - - if (!(hw->cap & NFP_NET_CFG_CTRL_PROMISC)) { - PMD_INIT_LOG(INFO, "Promiscuous mode not supported"); - return -ENOTSUP; - } - - if (hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) { - PMD_DRV_LOG(INFO, "Promiscuous mode already enabled"); - return 0; - } - - new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC; - update = NFP_NET_CFG_UPDATE_GEN; - - /* - * DPDK sets promiscuous mode on just after this call assuming - * it can not fail ... - */ - ret = nfp_net_reconfig(hw, new_ctrl, update); - if (ret < 0) - return ret; - - hw->ctrl = new_ctrl; - - return 0; -} - -int -nfp_net_promisc_disable(struct rte_eth_dev *dev) -{ - uint32_t new_ctrl, update = 0; - struct nfp_net_hw *hw; - int ret; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { - PMD_DRV_LOG(INFO, "Promiscuous mode already disabled"); - return 0; - } - - new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC; - update = NFP_NET_CFG_UPDATE_GEN; - - /* - * DPDK sets promiscuous mode off just before this call - * assuming it can not fail ... - */ - ret = nfp_net_reconfig(hw, new_ctrl, update); - if (ret < 0) - return ret; - - hw->ctrl = new_ctrl; - - return 0; -} - -/* - * return 0 means link status changed, -1 means not changed - * - * Wait to complete is needed as it can take up to 9 seconds to get the Link - * status. - */ -int -nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) -{ - struct nfp_net_hw *hw; - struct rte_eth_link link; - uint32_t nn_link_status; - int ret; - - static const uint32_t ls_to_ethtool[] = { - [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_1G] = RTE_ETH_SPEED_NUM_1G, - [NFP_NET_CFG_STS_LINK_RATE_10G] = RTE_ETH_SPEED_NUM_10G, - [NFP_NET_CFG_STS_LINK_RATE_25G] = RTE_ETH_SPEED_NUM_25G, - [NFP_NET_CFG_STS_LINK_RATE_40G] = RTE_ETH_SPEED_NUM_40G, - [NFP_NET_CFG_STS_LINK_RATE_50G] = RTE_ETH_SPEED_NUM_50G, - [NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G, - }; - - PMD_DRV_LOG(DEBUG, "Link update"); - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - nn_link_status = nn_cfg_readl(hw, NFP_NET_CFG_STS); - - memset(&link, 0, sizeof(struct rte_eth_link)); - - if (nn_link_status & NFP_NET_CFG_STS_LINK) - link.link_status = RTE_ETH_LINK_UP; - - link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; - - if (nn_link_status >= RTE_DIM(ls_to_ethtool)) - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - else - link.link_speed = ls_to_ethtool[nn_link_status]; - - ret = rte_eth_linkstatus_set(dev, &link); - if (ret == 0) { - if (link.link_status) - PMD_DRV_LOG(INFO, "NIC Link is Up"); - else - PMD_DRV_LOG(INFO, "NIC Link is Down"); - } - return ret; -} - -int -nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) -{ - int i; - struct nfp_net_hw *hw; - struct rte_eth_stats nfp_dev_stats; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* RTE_ETHDEV_QUEUE_STAT_CNTRS default value is 16 */ - - memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); - - /* reading per RX ring stats */ - for (i = 0; i < dev->data->nb_rx_queues; i++) { - if (i == RTE_ETHDEV_QUEUE_STAT_CNTRS) - break; - - nfp_dev_stats.q_ipackets[i] = - nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i)); - - nfp_dev_stats.q_ipackets[i] -= - hw->eth_stats_base.q_ipackets[i]; - - nfp_dev_stats.q_ibytes[i] = - nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8); - - nfp_dev_stats.q_ibytes[i] -= - hw->eth_stats_base.q_ibytes[i]; - } - - /* reading per TX ring stats */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - if (i == RTE_ETHDEV_QUEUE_STAT_CNTRS) - break; - - nfp_dev_stats.q_opackets[i] = - nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i)); - - nfp_dev_stats.q_opackets[i] -= - hw->eth_stats_base.q_opackets[i]; - - nfp_dev_stats.q_obytes[i] = - nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8); - - nfp_dev_stats.q_obytes[i] -= - hw->eth_stats_base.q_obytes[i]; - } - - nfp_dev_stats.ipackets = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES); - - nfp_dev_stats.ipackets -= hw->eth_stats_base.ipackets; - - nfp_dev_stats.ibytes = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS); - - nfp_dev_stats.ibytes -= hw->eth_stats_base.ibytes; - - nfp_dev_stats.opackets = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES); - - nfp_dev_stats.opackets -= hw->eth_stats_base.opackets; - - nfp_dev_stats.obytes = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS); - - nfp_dev_stats.obytes -= hw->eth_stats_base.obytes; - - /* reading general device stats */ - nfp_dev_stats.ierrors = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS); - - nfp_dev_stats.ierrors -= hw->eth_stats_base.ierrors; - - nfp_dev_stats.oerrors = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS); - - nfp_dev_stats.oerrors -= hw->eth_stats_base.oerrors; - - /* RX ring mbuf allocation failures */ - nfp_dev_stats.rx_nombuf = dev->data->rx_mbuf_alloc_failed; - - nfp_dev_stats.imissed = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS); - - nfp_dev_stats.imissed -= hw->eth_stats_base.imissed; - - if (stats) { - memcpy(stats, &nfp_dev_stats, sizeof(*stats)); - return 0; - } - return -EINVAL; -} - -int -nfp_net_stats_reset(struct rte_eth_dev *dev) -{ - int i; - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* - * hw->eth_stats_base records the per counter starting point. - * Lets update it now - */ - - /* reading per RX ring stats */ - for (i = 0; i < dev->data->nb_rx_queues; i++) { - if (i == RTE_ETHDEV_QUEUE_STAT_CNTRS) - break; - - hw->eth_stats_base.q_ipackets[i] = - nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i)); - - hw->eth_stats_base.q_ibytes[i] = - nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8); - } - - /* reading per TX ring stats */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - if (i == RTE_ETHDEV_QUEUE_STAT_CNTRS) - break; - - hw->eth_stats_base.q_opackets[i] = - nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i)); - - hw->eth_stats_base.q_obytes[i] = - nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8); - } - - hw->eth_stats_base.ipackets = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES); - - hw->eth_stats_base.ibytes = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS); - - hw->eth_stats_base.opackets = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES); - - hw->eth_stats_base.obytes = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS); - - /* reading general device stats */ - hw->eth_stats_base.ierrors = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS); - - hw->eth_stats_base.oerrors = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS); - - /* RX ring mbuf allocation failures */ - dev->data->rx_mbuf_alloc_failed = 0; - - hw->eth_stats_base.imissed = - nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS); - - return 0; -} - -int -nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) -{ - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues; - dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues; - dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU; - /* - * The maximum rx packet length (max_rx_pktlen) is set to the - * maximum supported frame size that the NFP can handle. This - * includes layer 2 headers, CRC and other metadata that can - * optionally be used. - * The maximum layer 3 MTU (max_mtu) is read from hardware, - * which was set by the firmware loaded onto the card. - */ - dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX; - dev_info->max_mtu = hw->max_mtu; - dev_info->min_mtu = RTE_ETHER_MIN_MTU; - /* Next should change when PF support is implemented */ - dev_info->max_mac_addrs = 1; - - if (hw->cap & NFP_NET_CFG_CTRL_RXVLAN) - dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP; - - if (hw->cap & NFP_NET_CFG_CTRL_RXCSUM) - dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | - RTE_ETH_RX_OFFLOAD_UDP_CKSUM | - RTE_ETH_RX_OFFLOAD_TCP_CKSUM; - - if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN) - dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT; - - if (hw->cap & NFP_NET_CFG_CTRL_TXCSUM) - dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | - RTE_ETH_TX_OFFLOAD_UDP_CKSUM | - RTE_ETH_TX_OFFLOAD_TCP_CKSUM; - - if (hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) - dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO; - - if (hw->cap & NFP_NET_CFG_CTRL_GATHER) - dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS; - - dev_info->default_rxconf = (struct rte_eth_rxconf) { - .rx_thresh = { - .pthresh = DEFAULT_RX_PTHRESH, - .hthresh = DEFAULT_RX_HTHRESH, - .wthresh = DEFAULT_RX_WTHRESH, - }, - .rx_free_thresh = DEFAULT_RX_FREE_THRESH, - .rx_drop_en = 0, - }; - - dev_info->default_txconf = (struct rte_eth_txconf) { - .tx_thresh = { - .pthresh = DEFAULT_TX_PTHRESH, - .hthresh = DEFAULT_TX_HTHRESH, - .wthresh = DEFAULT_TX_WTHRESH, - }, - .tx_free_thresh = DEFAULT_TX_FREE_THRESH, - .tx_rs_thresh = DEFAULT_TX_RSBIT_THRESH, - }; - - dev_info->rx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = NFP_NET_MAX_RX_DESC, - .nb_min = NFP_NET_MIN_RX_DESC, - .nb_align = NFP_ALIGN_RING_DESC, - }; - - dev_info->tx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = NFP_NET_MAX_TX_DESC, - .nb_min = NFP_NET_MIN_TX_DESC, - .nb_align = NFP_ALIGN_RING_DESC, - .nb_seg_max = NFP_TX_MAX_SEG, - .nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG, - }; - - if (hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) { - dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH; - - dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 | - RTE_ETH_RSS_NONFRAG_IPV4_TCP | - RTE_ETH_RSS_NONFRAG_IPV4_UDP | - RTE_ETH_RSS_IPV6 | - RTE_ETH_RSS_NONFRAG_IPV6_TCP | - RTE_ETH_RSS_NONFRAG_IPV6_UDP; - - dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ; - dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ; - } - - dev_info->speed_capa = RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_10G | - RTE_ETH_LINK_SPEED_25G | RTE_ETH_LINK_SPEED_40G | - RTE_ETH_LINK_SPEED_50G | RTE_ETH_LINK_SPEED_100G; - - return 0; -} - -const uint32_t * -nfp_net_supported_ptypes_get(struct rte_eth_dev *dev) -{ - static const uint32_t ptypes[] = { - /* refers to nfp_net_set_hash() */ - RTE_PTYPE_INNER_L3_IPV4, - RTE_PTYPE_INNER_L3_IPV6, - RTE_PTYPE_INNER_L3_IPV6_EXT, - RTE_PTYPE_INNER_L4_MASK, - RTE_PTYPE_UNKNOWN - }; - - if (dev->rx_pkt_burst == nfp_net_recv_pkts) - return ptypes; - return NULL; -} - -int -nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) -{ - struct rte_pci_device *pci_dev; - struct nfp_net_hw *hw; - int base = 0; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - pci_dev = RTE_ETH_DEV_TO_PCI(dev); - - if (rte_intr_type_get(pci_dev->intr_handle) != - RTE_INTR_HANDLE_UIO) - base = 1; - - /* Make sure all updates are written before un-masking */ - rte_wmb(); - nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), - NFP_NET_CFG_ICR_UNMASKED); - return 0; -} - -int -nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) -{ - struct rte_pci_device *pci_dev; - struct nfp_net_hw *hw; - int base = 0; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - pci_dev = RTE_ETH_DEV_TO_PCI(dev); - - if (rte_intr_type_get(pci_dev->intr_handle) != - RTE_INTR_HANDLE_UIO) - base = 1; - - /* Make sure all updates are written before un-masking */ - rte_wmb(); - nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), 0x1); - return 0; -} - -static void -nfp_net_dev_link_status_print(struct rte_eth_dev *dev) -{ - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); - struct rte_eth_link link; - - rte_eth_linkstatus_get(dev, &link); - if (link.link_status) - PMD_DRV_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s", - dev->data->port_id, link.link_speed, - link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX - ? "full-duplex" : "half-duplex"); - else - PMD_DRV_LOG(INFO, " Port %d: Link Down", - dev->data->port_id); - - PMD_DRV_LOG(INFO, "PCI Address: " PCI_PRI_FMT, - pci_dev->addr.domain, pci_dev->addr.bus, - pci_dev->addr.devid, pci_dev->addr.function); -} - -/* Interrupt configuration and handling */ - -/* - * nfp_net_irq_unmask - Unmask an interrupt - * - * If MSI-X auto-masking is enabled clear the mask bit, otherwise - * clear the ICR for the entry. - */ -void -nfp_net_irq_unmask(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - struct rte_pci_device *pci_dev; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - pci_dev = RTE_ETH_DEV_TO_PCI(dev); - - if (hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) { - /* If MSI-X auto-masking is used, clear the entry */ - rte_wmb(); - rte_intr_ack(pci_dev->intr_handle); - } else { - /* Make sure all updates are written before un-masking */ - rte_wmb(); - nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX), - NFP_NET_CFG_ICR_UNMASKED); - } -} - -/* - * Interrupt handler which shall be registered for alarm callback for delayed - * handling specific interrupt to wait for the stable nic state. As the NIC - * interrupt state is not stable for nfp after link is just down, it needs - * to wait 4 seconds to get the stable status. - * - * @param handle Pointer to interrupt handle. - * @param param The address of parameter (struct rte_eth_dev *) - * - * @return void - */ -void -nfp_net_dev_interrupt_delayed_handler(void *param) -{ - struct rte_eth_dev *dev = (struct rte_eth_dev *)param; - - nfp_net_link_update(dev, 0); - rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); - - nfp_net_dev_link_status_print(dev); - - /* Unmasking */ - nfp_net_irq_unmask(dev); -} - -void -nfp_net_dev_interrupt_handler(void *param) -{ - int64_t timeout; - struct rte_eth_link link; - struct rte_eth_dev *dev = (struct rte_eth_dev *)param; - - PMD_DRV_LOG(DEBUG, "We got a LSC interrupt!!!"); - - rte_eth_linkstatus_get(dev, &link); - - nfp_net_link_update(dev, 0); - - /* likely to up */ - if (!link.link_status) { - /* handle it 1 sec later, wait it being stable */ - timeout = NFP_NET_LINK_UP_CHECK_TIMEOUT; - /* likely to down */ - } else { - /* handle it 4 sec later, wait it being stable */ - timeout = NFP_NET_LINK_DOWN_CHECK_TIMEOUT; - } - - if (rte_eal_alarm_set(timeout * 1000, - nfp_net_dev_interrupt_delayed_handler, - (void *)dev) < 0) { - PMD_INIT_LOG(ERR, "Error setting alarm"); - /* Unmasking */ - nfp_net_irq_unmask(dev); - } -} - -int -nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) -{ - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* mtu setting is forbidden if port is started */ - if (dev->data->dev_started) { - PMD_DRV_LOG(ERR, "port %d must be stopped before configuration", - dev->data->port_id); - return -EBUSY; - } - - /* MTU larger than current mbufsize not supported */ - if (mtu > hw->flbufsz) { - PMD_DRV_LOG(ERR, "MTU (%u) larger than current mbufsize (%u) not supported", - mtu, hw->flbufsz); - return -ERANGE; - } - - /* writing to configuration space */ - nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu); - - hw->mtu = mtu; - - return 0; -} - -int -nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask) -{ - uint32_t new_ctrl, update; - struct nfp_net_hw *hw; - struct rte_eth_conf *dev_conf; - int ret; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - dev_conf = &dev->data->dev_conf; - new_ctrl = hw->ctrl; - - /* - * Vlan stripping setting - * Enable or disable VLAN stripping - */ - if (mask & RTE_ETH_VLAN_STRIP_MASK) { - if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) - new_ctrl |= NFP_NET_CFG_CTRL_RXVLAN; - else - new_ctrl &= ~NFP_NET_CFG_CTRL_RXVLAN; - } - - if (new_ctrl == hw->ctrl) - return 0; - - update = NFP_NET_CFG_UPDATE_GEN; - - ret = nfp_net_reconfig(hw, new_ctrl, update); - if (!ret) - hw->ctrl = new_ctrl; - - return ret; -} - -static int -nfp_net_rss_reta_write(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size) -{ - uint32_t reta, mask; - int i, j; - int idx, shift; - struct nfp_net_hw *hw = - NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { - PMD_DRV_LOG(ERR, "The size of hash lookup table configured " - "(%d) doesn't match the number hardware can supported " - "(%d)", reta_size, NFP_NET_CFG_RSS_ITBL_SZ); - return -EINVAL; - } - - /* - * Update Redirection Table. There are 128 8bit-entries which can be - * manage as 32 32bit-entries - */ - for (i = 0; i < reta_size; i += 4) { - /* Handling 4 RSS entries per loop */ - idx = i / RTE_ETH_RETA_GROUP_SIZE; - shift = i % RTE_ETH_RETA_GROUP_SIZE; - mask = (uint8_t)((reta_conf[idx].mask >> shift) & 0xF); - - if (!mask) - continue; - - reta = 0; - /* If all 4 entries were set, don't need read RETA register */ - if (mask != 0xF) - reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i); - - for (j = 0; j < 4; j++) { - if (!(mask & (0x1 << j))) - continue; - if (mask != 0xF) - /* Clearing the entry bits */ - reta &= ~(0xFF << (8 * j)); - reta |= reta_conf[idx].reta[shift + j] << (8 * j); - } - nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, - reta); - } - return 0; -} - -/* Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device */ -int -nfp_net_reta_update(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size) -{ - struct nfp_net_hw *hw = - NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t update; - int ret; - - if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY)) - return -EINVAL; - - ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size); - if (ret != 0) - return ret; - - update = NFP_NET_CFG_UPDATE_RSS; - - if (nfp_net_reconfig(hw, hw->ctrl, update) < 0) - return -EIO; - - return 0; -} - - /* Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device. */ -int -nfp_net_reta_query(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size) -{ - uint8_t i, j, mask; - int idx, shift; - uint32_t reta; - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY)) - return -EINVAL; - - if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { - PMD_DRV_LOG(ERR, "The size of hash lookup table configured " - "(%d) doesn't match the number hardware can supported " - "(%d)", reta_size, NFP_NET_CFG_RSS_ITBL_SZ); - return -EINVAL; - } - - /* - * Reading Redirection Table. There are 128 8bit-entries which can be - * manage as 32 32bit-entries - */ - for (i = 0; i < reta_size; i += 4) { - /* Handling 4 RSS entries per loop */ - idx = i / RTE_ETH_RETA_GROUP_SIZE; - shift = i % RTE_ETH_RETA_GROUP_SIZE; - mask = (uint8_t)((reta_conf[idx].mask >> shift) & 0xF); - - if (!mask) - continue; - - reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + - shift); - for (j = 0; j < 4; j++) { - if (!(mask & (0x1 << j))) - continue; - reta_conf[idx].reta[shift + j] = - (uint8_t)((reta >> (8 * j)) & 0xF); - } - } - return 0; -} - -static int -nfp_net_rss_hash_write(struct rte_eth_dev *dev, - struct rte_eth_rss_conf *rss_conf) -{ - struct nfp_net_hw *hw; - uint64_t rss_hf; - uint32_t cfg_rss_ctrl = 0; - uint8_t key; - int i; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - /* Writing the key byte a byte */ - for (i = 0; i < rss_conf->rss_key_len; i++) { - memcpy(&key, &rss_conf->rss_key[i], 1); - nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key); - } - - rss_hf = rss_conf->rss_hf; - - if (rss_hf & RTE_ETH_RSS_IPV4) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV4; - - if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV4_TCP; - - if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV4_UDP; - - if (rss_hf & RTE_ETH_RSS_IPV6) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6; - - if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_TCP; - - if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP) - cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_UDP; - - cfg_rss_ctrl |= NFP_NET_CFG_RSS_MASK; - cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ; - - /* configuring where to apply the RSS hash */ - nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl); - - /* Writing the key size */ - nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len); - - return 0; -} - -int -nfp_net_rss_hash_update(struct rte_eth_dev *dev, - struct rte_eth_rss_conf *rss_conf) -{ - uint32_t update; - uint64_t rss_hf; - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - rss_hf = rss_conf->rss_hf; - - /* Checking if RSS is enabled */ - if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY)) { - if (rss_hf != 0) { /* Enable RSS? */ - PMD_DRV_LOG(ERR, "RSS unsupported"); - return -EINVAL; - } - return 0; /* Nothing to do */ - } - - if (rss_conf->rss_key_len > NFP_NET_CFG_RSS_KEY_SZ) { - PMD_DRV_LOG(ERR, "hash key too long"); - return -EINVAL; - } - - nfp_net_rss_hash_write(dev, rss_conf); - - update = NFP_NET_CFG_UPDATE_RSS; - - if (nfp_net_reconfig(hw, hw->ctrl, update) < 0) - return -EIO; - - return 0; -} - -int -nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, - struct rte_eth_rss_conf *rss_conf) -{ - uint64_t rss_hf; - uint32_t cfg_rss_ctrl; - uint8_t key; - int i; - struct nfp_net_hw *hw; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY)) - return -EINVAL; - - rss_hf = rss_conf->rss_hf; - cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL); - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) - rss_hf |= RTE_ETH_RSS_IPV4; - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4_TCP) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV4_TCP; - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV6_TCP) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV6_TCP; - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4_UDP) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV4_UDP; - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV6_UDP) - rss_hf |= RTE_ETH_RSS_NONFRAG_IPV6_UDP; - - if (cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV6) - rss_hf |= RTE_ETH_RSS_IPV6; - - /* Propagate current RSS hash functions to caller */ - rss_conf->rss_hf = rss_hf; - - /* Reading the key size */ - rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ); - - /* Reading the key byte a byte */ - for (i = 0; i < rss_conf->rss_key_len; i++) { - key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i); - memcpy(&rss_conf->rss_key[i], &key, 1); - } - - return 0; -} - -int -nfp_net_rss_config_default(struct rte_eth_dev *dev) -{ - struct rte_eth_conf *dev_conf; - struct rte_eth_rss_conf rss_conf; - struct rte_eth_rss_reta_entry64 nfp_reta_conf[2]; - uint16_t rx_queues = dev->data->nb_rx_queues; - uint16_t queue; - int i, j, ret; - - PMD_DRV_LOG(INFO, "setting default RSS conf for %u queues", - rx_queues); - - nfp_reta_conf[0].mask = ~0x0; - nfp_reta_conf[1].mask = ~0x0; - - queue = 0; - for (i = 0; i < 0x40; i += 8) { - for (j = i; j < (i + 8); j++) { - nfp_reta_conf[0].reta[j] = queue; - nfp_reta_conf[1].reta[j] = queue++; - queue %= rx_queues; - } - } - ret = nfp_net_rss_reta_write(dev, nfp_reta_conf, 0x80); - if (ret != 0) - return ret; - - dev_conf = &dev->data->dev_conf; - if (!dev_conf) { - PMD_DRV_LOG(INFO, "wrong rss conf"); - return -EINVAL; - } - rss_conf = dev_conf->rx_adv_conf.rss_conf; - - ret = nfp_net_rss_hash_write(dev, &rss_conf); - - return ret; -} - -void -nfp_net_stop_rx_queue(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_rxq *this_rx_q; - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } -} - -void -nfp_net_close_rx_queue(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_rxq *this_rx_q; - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - nfp_net_rx_queue_release(dev, i); - } -} - -void -nfp_net_stop_tx_queue(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_txq *this_tx_q; - - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } -} - -void -nfp_net_close_tx_queue(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_txq *this_tx_q; - - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - nfp_net_tx_queue_release(dev, i); - } -} - -int -nfp_net_set_vxlan_port(struct nfp_net_hw *hw, - size_t idx, - uint16_t port) -{ - int ret; - uint32_t i; - - if (idx >= NFP_NET_N_VXLAN_PORTS) { - PMD_DRV_LOG(ERR, "The idx value is out of range."); - return -ERANGE; - } - - hw->vxlan_ports[idx] = port; - - for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) { - nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port), - (hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]); - } - - rte_spinlock_lock(&hw->reconfig_lock); - - nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN); - rte_wmb(); - - ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN); - - rte_spinlock_unlock(&hw->reconfig_lock); - - return ret; -} - -RTE_LOG_REGISTER_SUFFIX(nfp_logtype_init, init, NOTICE); -RTE_LOG_REGISTER_SUFFIX(nfp_logtype_driver, driver, NOTICE); -RTE_LOG_REGISTER_SUFFIX(nfp_logtype_cpp, cpp, NOTICE); -/* - * The firmware with NFD3 can not handle DMA address requiring more - * than 40 bits - */ -int -nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name) -{ - if (NFD_CFG_CLASS_VER_of(hw->ver) == NFP_NET_CFG_VERSION_DP_NFD3 && - rte_mem_check_dma_mask(40) != 0) { - PMD_DRV_LOG(ERR, - "The device %s can't be used: restricted dma mask to 40 bits!", - name); - return -ENODEV; - } - - return 0; -} - -/* - * Local variables: - * c-file-style: "Linux" - * indent-tabs-mode: t - * End: - */ diff --git a/dpdk/drivers/net/nfp/nfp_common.h b/dpdk/drivers/net/nfp/nfp_common.h deleted file mode 100644 index 5b5c0aa7d..000000000 --- a/dpdk/drivers/net/nfp/nfp_common.h +++ /dev/null @@ -1,473 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2014-2018 Netronome Systems, Inc. - * All rights reserved. - */ - -/* - * vim:shiftwidth=8:noexpandtab - * - * @file dpdk/pmd/nfp_net_pmd.h - * - * Netronome NFP_NET PMD - */ - -#ifndef _NFP_COMMON_H_ -#define _NFP_COMMON_H_ - -#include "nfp_ctrl.h" - -#define NFP_NET_PMD_VERSION "0.1" -#define PCI_VENDOR_ID_NETRONOME 0x19ee -#define PCI_VENDOR_ID_CORIGINE 0x1da8 - -#define PCI_DEVICE_ID_NFP3800_PF_NIC 0x3800 -#define PCI_DEVICE_ID_NFP3800_VF_NIC 0x3803 -#define PCI_DEVICE_ID_NFP4000_PF_NIC 0x4000 -#define PCI_DEVICE_ID_NFP6000_PF_NIC 0x6000 -#define PCI_DEVICE_ID_NFP6000_VF_NIC 0x6003 /* Include NFP4000VF */ - -/* Forward declaration */ -struct nfp_net_adapter; - -#define NFP_TX_MAX_SEG UINT8_MAX -#define NFP_TX_MAX_MTU_SEG 8 - -/* Bar allocation */ -#define NFP_NET_CRTL_BAR 0 -#define NFP_NET_TX_BAR 2 -#define NFP_NET_RX_BAR 2 -#define NFP_QCP_QUEUE_AREA_SZ 0x80000 - -/* Macros for accessing the Queue Controller Peripheral 'CSRs' */ -#define NFP_QCP_QUEUE_OFF(_x) ((_x) * 0x800) -#define NFP_QCP_QUEUE_ADD_RPTR 0x0000 -#define NFP_QCP_QUEUE_ADD_WPTR 0x0004 -#define NFP_QCP_QUEUE_STS_LO 0x0008 -#define NFP_QCP_QUEUE_STS_LO_READPTR_mask (0x3ffff) -#define NFP_QCP_QUEUE_STS_HI 0x000c -#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask (0x3ffff) - -#define NFP_PCIE_QCP_NFP3800_OFFSET 0x400000 -#define NFP_PCIE_QCP_NFP6000_OFFSET 0x80000 -#define NFP_PCIE_QUEUE_NFP3800_MASK 0x1ff -#define NFP_PCIE_QUEUE_NFP6000_MASK 0xff -#define NFP_PCIE_QCP_PF_OFFSET 0x0 -#define NFP_PCIE_QCP_VF_OFFSET 0x0 - -/* The offset of the queue controller queues in the PCIe Target */ -#define NFP_PCIE_QUEUE(_offset, _q, _mask) \ - ((_offset) + (NFP_QCP_QUEUE_ADDR_SZ * ((_q) & (_mask)))) - -/* Interrupt definitions */ -#define NFP_NET_IRQ_LSC_IDX 0 - -/* Default values for RX/TX configuration */ -#define DEFAULT_RX_FREE_THRESH 32 -#define DEFAULT_RX_PTHRESH 8 -#define DEFAULT_RX_HTHRESH 8 -#define DEFAULT_RX_WTHRESH 0 - -#define DEFAULT_TX_RS_THRESH 32 -#define DEFAULT_TX_FREE_THRESH 32 -#define DEFAULT_TX_PTHRESH 32 -#define DEFAULT_TX_HTHRESH 0 -#define DEFAULT_TX_WTHRESH 0 -#define DEFAULT_TX_RSBIT_THRESH 32 - -/* Alignment for dma zones */ -#define NFP_MEMZONE_ALIGN 128 - -/* - * This is used by the reconfig protocol. It sets the maximum time waiting in - * milliseconds before a reconfig timeout happens. - */ -#define NFP_NET_POLL_TIMEOUT 5000 - -#define NFP_QCP_QUEUE_ADDR_SZ (0x800) - -#define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */ -#define NFP_NET_LINK_UP_CHECK_TIMEOUT 1000 /* ms */ - -/* Version number helper defines */ -#define NFD_CFG_CLASS_VER_msk 0xff -#define NFD_CFG_CLASS_VER_shf 24 -#define NFD_CFG_CLASS_VER(x) (((x) & 0xff) << 24) -#define NFD_CFG_CLASS_VER_of(x) (((x) >> 24) & 0xff) -#define NFD_CFG_CLASS_TYPE_msk 0xff -#define NFD_CFG_CLASS_TYPE_shf 16 -#define NFD_CFG_CLASS_TYPE(x) (((x) & 0xff) << 16) -#define NFD_CFG_CLASS_TYPE_of(x) (((x) >> 16) & 0xff) -#define NFD_CFG_MAJOR_VERSION_msk 0xff -#define NFD_CFG_MAJOR_VERSION_shf 8 -#define NFD_CFG_MAJOR_VERSION(x) (((x) & 0xff) << 8) -#define NFD_CFG_MAJOR_VERSION_of(x) (((x) >> 8) & 0xff) -#define NFD_CFG_MINOR_VERSION_msk 0xff -#define NFD_CFG_MINOR_VERSION_shf 0 -#define NFD_CFG_MINOR_VERSION(x) (((x) & 0xff) << 0) -#define NFD_CFG_MINOR_VERSION_of(x) (((x) >> 0) & 0xff) - -/* Number of supported physical ports */ -#define NFP_MAX_PHYPORTS 12 - -/* Maximum supported NFP frame size (MTU + layer 2 headers) */ -#define NFP_FRAME_SIZE_MAX 10048 -#define DEFAULT_FLBUF_SIZE 9216 - -#include -#include - -/* Firmware application ID's */ -enum nfp_app_fw_id { - NFP_APP_FW_CORE_NIC = 0x1, - NFP_APP_FW_FLOWER_NIC = 0x3, -}; - -/* nfp_qcp_ptr - Read or Write Pointer of a queue */ -enum nfp_qcp_ptr { - NFP_QCP_READ_PTR = 0, - NFP_QCP_WRITE_PTR -}; - -struct nfp_pf_dev { - /* Backpointer to associated pci device */ - struct rte_pci_device *pci_dev; - - enum nfp_app_fw_id app_fw_id; - - /* Pointer to the app running on the PF */ - void *app_fw_priv; - - /* The eth table reported by firmware */ - struct nfp_eth_table *nfp_eth_table; - - /* Current values for control */ - uint32_t ctrl; - - uint8_t *ctrl_bar; - uint8_t *tx_bar; - uint8_t *rx_bar; - - uint8_t *qcp_cfg; - rte_spinlock_t reconfig_lock; - - uint16_t flbufsz; - uint16_t device_id; - uint16_t vendor_id; - uint16_t subsystem_device_id; - uint16_t subsystem_vendor_id; -#if defined(DSTQ_SELECTION) -#if DSTQ_SELECTION - uint16_t device_function; -#endif -#endif - - struct nfp_cpp *cpp; - struct nfp_cpp_area *ctrl_area; - struct nfp_cpp_area *hwqueues_area; - struct nfp_cpp_area *msix_area; - - uint8_t *hw_queues; - - union eth_table_entry *eth_table; - - struct nfp_hwinfo *hwinfo; - struct nfp_rtsym_table *sym_tbl; - - /* service id of cpp bridge service */ - uint32_t cpp_bridge_id; -}; - -struct nfp_app_fw_nic { - /* Backpointer to the PF device */ - struct nfp_pf_dev *pf_dev; - - /* - * Array of physical ports belonging to the this CoreNIC app - * This is really a list of vNIC's. One for each physical port - */ - struct nfp_net_hw *ports[NFP_MAX_PHYPORTS]; - - bool multiport; - uint8_t total_phyports; -}; - -struct nfp_net_hw { - /* Backpointer to the PF this port belongs to */ - struct nfp_pf_dev *pf_dev; - - /* Backpointer to the eth_dev of this port*/ - struct rte_eth_dev *eth_dev; - - /* Info from the firmware */ - uint32_t ver; - uint32_t cap; - uint32_t max_mtu; - uint32_t mtu; - uint32_t rx_offset; - - /* Current values for control */ - uint32_t ctrl; - - uint8_t *ctrl_bar; - uint8_t *tx_bar; - uint8_t *rx_bar; - - int stride_rx; - int stride_tx; - - uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS]; - uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS]; - - uint8_t *qcp_cfg; - rte_spinlock_t reconfig_lock; - - uint32_t max_tx_queues; - uint32_t max_rx_queues; - uint16_t flbufsz; - uint16_t device_id; - uint16_t vendor_id; - uint16_t subsystem_device_id; - uint16_t subsystem_vendor_id; -#if defined(DSTQ_SELECTION) -#if DSTQ_SELECTION - uint16_t device_function; -#endif -#endif - - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - - /* Records starting point for counters */ - struct rte_eth_stats eth_stats_base; - - struct nfp_cpp *cpp; - struct nfp_cpp_area *ctrl_area; - struct nfp_cpp_area *hwqueues_area; - struct nfp_cpp_area *msix_area; - - uint8_t *hw_queues; - /* Sequential physical port number */ - uint8_t idx; - /* Internal port number as seen from NFP */ - uint8_t nfp_idx; - - union eth_table_entry *eth_table; -}; - -struct nfp_net_adapter { - struct nfp_net_hw hw; -}; - -static inline uint8_t nn_readb(volatile const void *addr) -{ - return rte_read8(addr); -} - -static inline void nn_writeb(uint8_t val, volatile void *addr) -{ - rte_write8(val, addr); -} - -static inline uint32_t nn_readl(volatile const void *addr) -{ - return rte_read32(addr); -} - -static inline void nn_writel(uint32_t val, volatile void *addr) -{ - rte_write32(val, addr); -} - -static inline void nn_writew(uint16_t val, volatile void *addr) -{ - rte_write16(val, addr); -} - -static inline uint64_t nn_readq(volatile void *addr) -{ - const volatile uint32_t *p = addr; - uint32_t low, high; - - high = nn_readl((volatile const void *)(p + 1)); - low = nn_readl((volatile const void *)p); - - return low + ((uint64_t)high << 32); -} - -static inline void nn_writeq(uint64_t val, volatile void *addr) -{ - nn_writel(val >> 32, (volatile char *)addr + 4); - nn_writel(val, addr); -} - -/* - * Functions to read/write from/to Config BAR - * Performs any endian conversion necessary. - */ -static inline uint8_t -nn_cfg_readb(struct nfp_net_hw *hw, int off) -{ - return nn_readb(hw->ctrl_bar + off); -} - -static inline void -nn_cfg_writeb(struct nfp_net_hw *hw, int off, uint8_t val) -{ - nn_writeb(val, hw->ctrl_bar + off); -} - -static inline uint32_t -nn_cfg_readl(struct nfp_net_hw *hw, int off) -{ - return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off)); -} - -static inline void -nn_cfg_writel(struct nfp_net_hw *hw, int off, uint32_t val) -{ - nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off); -} - -static inline uint64_t -nn_cfg_readq(struct nfp_net_hw *hw, int off) -{ - return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off)); -} - -static inline void -nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val) -{ - nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off); -} - -/* - * nfp_qcp_ptr_add - Add the value to the selected pointer of a queue - * @q: Base address for queue structure - * @ptr: Add to the Read or Write pointer - * @val: Value to add to the queue pointer - */ -static inline void -nfp_qcp_ptr_add(uint8_t *q, enum nfp_qcp_ptr ptr, uint32_t val) -{ - uint32_t off; - - if (ptr == NFP_QCP_READ_PTR) - off = NFP_QCP_QUEUE_ADD_RPTR; - else - off = NFP_QCP_QUEUE_ADD_WPTR; - - nn_writel(rte_cpu_to_le_32(val), q + off); -} - -/* - * nfp_qcp_read - Read the current Read/Write pointer value for a queue - * @q: Base address for queue structure - * @ptr: Read or Write pointer - */ -static inline uint32_t -nfp_qcp_read(uint8_t *q, enum nfp_qcp_ptr ptr) -{ - uint32_t off; - uint32_t val; - - if (ptr == NFP_QCP_READ_PTR) - off = NFP_QCP_QUEUE_STS_LO; - else - off = NFP_QCP_QUEUE_STS_HI; - - val = rte_cpu_to_le_32(nn_readl(q + off)); - - if (ptr == NFP_QCP_READ_PTR) - return val & NFP_QCP_QUEUE_STS_LO_READPTR_mask; - else - return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask; -} - -static inline uint32_t -nfp_pci_queue(struct rte_pci_device *pdev, uint16_t queue) -{ - switch (pdev->id.device_id) { - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_PF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP6000_MASK); - case PCI_DEVICE_ID_NFP3800_VF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_VF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP3800_MASK); - case PCI_DEVICE_ID_NFP6000_VF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_VF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP6000_MASK); - default: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_PF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP3800_MASK); - } -} - -/* Prototypes for common NFP functions */ -int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update); -int nfp_net_configure(struct rte_eth_dev *dev); -void nfp_net_enable_queues(struct rte_eth_dev *dev); -void nfp_net_disable_queues(struct rte_eth_dev *dev); -void nfp_net_params_setup(struct nfp_net_hw *hw); -void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src); -void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac); -int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr); -int nfp_configure_rx_interrupt(struct rte_eth_dev *dev, - struct rte_intr_handle *intr_handle); -uint32_t nfp_check_offloads(struct rte_eth_dev *dev); -int nfp_net_promisc_enable(struct rte_eth_dev *dev); -int nfp_net_promisc_disable(struct rte_eth_dev *dev); -int nfp_net_link_update(struct rte_eth_dev *dev, - __rte_unused int wait_to_complete); -int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); -int nfp_net_stats_reset(struct rte_eth_dev *dev); -int nfp_net_infos_get(struct rte_eth_dev *dev, - struct rte_eth_dev_info *dev_info); -const uint32_t *nfp_net_supported_ptypes_get(struct rte_eth_dev *dev); -int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id); -int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id); -void nfp_net_params_setup(struct nfp_net_hw *hw); -void nfp_net_cfg_queue_setup(struct nfp_net_hw *hw); -void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src); -void nfp_net_dev_interrupt_handler(void *param); -void nfp_net_dev_interrupt_delayed_handler(void *param); -int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); -int nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask); -int nfp_net_reta_update(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size); -int nfp_net_reta_query(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size); -int nfp_net_rss_hash_update(struct rte_eth_dev *dev, - struct rte_eth_rss_conf *rss_conf); -int nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, - struct rte_eth_rss_conf *rss_conf); -int nfp_net_rss_config_default(struct rte_eth_dev *dev); -void nfp_net_stop_rx_queue(struct rte_eth_dev *dev); -void nfp_net_close_rx_queue(struct rte_eth_dev *dev); -void nfp_net_stop_tx_queue(struct rte_eth_dev *dev); -void nfp_net_close_tx_queue(struct rte_eth_dev *dev); -int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port); -int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); -void nfp_net_irq_unmask(struct rte_eth_dev *dev); -void nfp_pf_uninit(struct nfp_pf_dev *pf_dev); - -#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ - (&((struct nfp_net_adapter *)adapter)->hw) - -#define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\ - (((struct nfp_net_hw *)dev_priv)->pf_dev) - -#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ - ((struct nfp_app_fw_nic *)app_fw_priv) - -#define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\ - ((struct nfp_app_fw_flower *)app_fw_priv) - -#endif /* _NFP_COMMON_H_ */ -/* - * Local variables: - * c-file-style: "Linux" - * indent-tabs-mode: t - * End: - */ diff --git a/dpdk/drivers/net/nfp/nfp_ctrl.h b/dpdk/drivers/net/nfp/nfp_ctrl.h deleted file mode 100644 index 372d53746..000000000 --- a/dpdk/drivers/net/nfp/nfp_ctrl.h +++ /dev/null @@ -1,329 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2014, 2015 Netronome Systems, Inc. - * All rights reserved. - */ - -/* - * vim:shiftwidth=8:noexpandtab - * - * Netronome network device driver: Control BAR layout - */ -#ifndef _NFP_CTRL_H_ -#define _NFP_CTRL_H_ - -/* - * Configuration BAR size. - * - * The configuration BAR is 8K in size, but on the NFP6000, due to - * THB-350, 32k needs to be reserved. - */ -#ifdef __NFP_IS_6000 -#define NFP_NET_CFG_BAR_SZ (32 * 1024) -#else -#define NFP_NET_CFG_BAR_SZ (8 * 1024) -#endif - -/* Offset in Freelist buffer where packet starts on RX */ -#define NFP_NET_RX_OFFSET 32 - -/* working with metadata api (NFD version > 3.0) */ -#define NFP_NET_META_FIELD_SIZE 4 -#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1) - -/* Prepend field types */ -#define NFP_NET_META_HASH 1 /* next field carries hash type */ - -/* Hash type pre-pended when a RSS hash was computed */ -#define NFP_NET_RSS_NONE 0 -#define NFP_NET_RSS_IPV4 1 -#define NFP_NET_RSS_IPV6 2 -#define NFP_NET_RSS_IPV6_EX 3 -#define NFP_NET_RSS_IPV4_TCP 4 -#define NFP_NET_RSS_IPV6_TCP 5 -#define NFP_NET_RSS_IPV6_EX_TCP 6 -#define NFP_NET_RSS_IPV4_UDP 7 -#define NFP_NET_RSS_IPV6_UDP 8 -#define NFP_NET_RSS_IPV6_EX_UDP 9 - -/* - * @NFP_NET_TXR_MAX: Maximum number of TX rings - * @NFP_NET_TXR_MASK: Mask for TX rings - * @NFP_NET_RXR_MAX: Maximum number of RX rings - * @NFP_NET_RXR_MASK: Mask for RX rings - */ -#define NFP_NET_TXR_MAX 64 -#define NFP_NET_TXR_MASK (NFP_NET_TXR_MAX - 1) -#define NFP_NET_RXR_MAX 64 -#define NFP_NET_RXR_MASK (NFP_NET_RXR_MAX - 1) - -/* - * Read/Write config words (0x0000 - 0x002c) - * @NFP_NET_CFG_CTRL: Global control - * @NFP_NET_CFG_UPDATE: Indicate which fields are updated - * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings - * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings - * @NFP_NET_CFG_MTU: Set MTU size - * @NFP_NET_CFG_FLBUFSZ: Set freelist buffer size (must be larger than MTU) - * @NFP_NET_CFG_EXN: MSI-X table entry for exceptions - * @NFP_NET_CFG_LSC: MSI-X table entry for link state changes - * @NFP_NET_CFG_MACADDR: MAC address - * - * TODO: - * - define Error details in UPDATE - */ -#define NFP_NET_CFG_CTRL 0x0000 -#define NFP_NET_CFG_CTRL_ENABLE (0x1 << 0) /* Global enable */ -#define NFP_NET_CFG_CTRL_PROMISC (0x1 << 1) /* Enable Promisc mode */ -#define NFP_NET_CFG_CTRL_L2BC (0x1 << 2) /* Allow L2 Broadcast */ -#define NFP_NET_CFG_CTRL_L2MC (0x1 << 3) /* Allow L2 Multicast */ -#define NFP_NET_CFG_CTRL_RXCSUM (0x1 << 4) /* Enable RX Checksum */ -#define NFP_NET_CFG_CTRL_TXCSUM (0x1 << 5) /* Enable TX Checksum */ -#define NFP_NET_CFG_CTRL_RXVLAN (0x1 << 6) /* Enable VLAN strip */ -#define NFP_NET_CFG_CTRL_TXVLAN (0x1 << 7) /* Enable VLAN insert */ -#define NFP_NET_CFG_CTRL_SCATTER (0x1 << 8) /* Scatter DMA */ -#define NFP_NET_CFG_CTRL_GATHER (0x1 << 9) /* Gather DMA */ -#define NFP_NET_CFG_CTRL_LSO (0x1 << 10) /* LSO/TSO */ -#define NFP_NET_CFG_CTRL_RINGCFG (0x1 << 16) /* Ring runtime changes */ -#define NFP_NET_CFG_CTRL_RSS (0x1 << 17) /* RSS */ -#define NFP_NET_CFG_CTRL_IRQMOD (0x1 << 18) /* Interrupt moderation */ -#define NFP_NET_CFG_CTRL_RINGPRIO (0x1 << 19) /* Ring priorities */ -#define NFP_NET_CFG_CTRL_MSIXAUTO (0x1 << 20) /* MSI-X auto-masking */ -#define NFP_NET_CFG_CTRL_TXRWB (0x1 << 21) /* Write-back of TX ring*/ -#define NFP_NET_CFG_CTRL_L2SWITCH (0x1 << 22) /* L2 Switch */ -#define NFP_NET_CFG_CTRL_L2SWITCH_LOCAL (0x1 << 23) /* Switch to local */ -#define NFP_NET_CFG_CTRL_VXLAN (0x1 << 24) /* Enable VXLAN */ -#define NFP_NET_CFG_CTRL_NVGRE (0x1 << 25) /* Enable NVGRE */ -#define NFP_NET_CFG_CTRL_MSIX_TX_OFF (0x1 << 26) /* Disable MSIX for TX */ -#define NFP_NET_CFG_CTRL_LSO2 (0x1 << 28) /* LSO/TSO (version 2) */ -#define NFP_NET_CFG_CTRL_RSS2 (0x1 << 29) /* RSS (version 2) */ -#define NFP_NET_CFG_CTRL_LIVE_ADDR (0x1U << 31)/* live MAC addr change */ -#define NFP_NET_CFG_UPDATE 0x0004 -#define NFP_NET_CFG_UPDATE_GEN (0x1 << 0) /* General update */ -#define NFP_NET_CFG_UPDATE_RING (0x1 << 1) /* Ring config change */ -#define NFP_NET_CFG_UPDATE_RSS (0x1 << 2) /* RSS config change */ -#define NFP_NET_CFG_UPDATE_TXRPRIO (0x1 << 3) /* TX Ring prio change */ -#define NFP_NET_CFG_UPDATE_RXRPRIO (0x1 << 4) /* RX Ring prio change */ -#define NFP_NET_CFG_UPDATE_MSIX (0x1 << 5) /* MSI-X change */ -#define NFP_NET_CFG_UPDATE_L2SWITCH (0x1 << 6) /* Switch changes */ -#define NFP_NET_CFG_UPDATE_RESET (0x1 << 7) /* Update due to FLR */ -#define NFP_NET_CFG_UPDATE_IRQMOD (0x1 << 8) /* IRQ mod change */ -#define NFP_NET_CFG_UPDATE_VXLAN (0x1 << 9) /* VXLAN port change */ -#define NFP_NET_CFG_UPDATE_MACADDR (0x1 << 11) /* MAC address change */ -#define NFP_NET_CFG_UPDATE_ERR (0x1U << 31) /* A error occurred */ -#define NFP_NET_CFG_TXRS_ENABLE 0x0008 -#define NFP_NET_CFG_RXRS_ENABLE 0x0010 -#define NFP_NET_CFG_MTU 0x0018 -#define NFP_NET_CFG_FLBUFSZ 0x001c -#define NFP_NET_CFG_EXN 0x001f -#define NFP_NET_CFG_LSC 0x0020 -#define NFP_NET_CFG_MACADDR 0x0024 - -#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2) -#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2) - -/* - * Read-only words (0x0030 - 0x0050): - * @NFP_NET_CFG_VERSION: Firmware version number - * @NFP_NET_CFG_STS: Status - * @NFP_NET_CFG_CAP: Capabilities (same bits as @NFP_NET_CFG_CTRL) - * @NFP_NET_MAX_TXRINGS: Maximum number of TX rings - * @NFP_NET_MAX_RXRINGS: Maximum number of RX rings - * @NFP_NET_MAX_MTU: Maximum support MTU - * @NFP_NET_CFG_START_TXQ: Start Queue Control Queue to use for TX (PF only) - * @NFP_NET_CFG_START_RXQ: Start Queue Control Queue to use for RX (PF only) - * - * TODO: - * - define more STS bits - */ -#define NFP_NET_CFG_VERSION 0x0030 -#define NFP_NET_CFG_VERSION_DP_NFD3 0 -#define NFP_NET_CFG_VERSION_DP_NFDK 1 -#define NFP_NET_CFG_VERSION_RESERVED_MASK (0xff << 24) -#define NFP_NET_CFG_VERSION_CLASS_MASK (0xff << 16) -#define NFP_NET_CFG_VERSION_CLASS(x) (((x) & 0xff) << 16) -#define NFP_NET_CFG_VERSION_CLASS_GENERIC 0 -#define NFP_NET_CFG_VERSION_MAJOR_MASK (0xff << 8) -#define NFP_NET_CFG_VERSION_MAJOR(x) (((x) & 0xff) << 8) -#define NFP_NET_CFG_VERSION_MINOR_MASK (0xff << 0) -#define NFP_NET_CFG_VERSION_MINOR(x) (((x) & 0xff) << 0) -#define NFP_NET_CFG_STS 0x0034 -#define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down */ -/* Link rate */ -#define NFP_NET_CFG_STS_LINK_RATE_SHIFT 1 -#define NFP_NET_CFG_STS_LINK_RATE_MASK 0xF -#define NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED 0 -#define NFP_NET_CFG_STS_LINK_RATE_UNKNOWN 1 -#define NFP_NET_CFG_STS_LINK_RATE_1G 2 -#define NFP_NET_CFG_STS_LINK_RATE_10G 3 -#define NFP_NET_CFG_STS_LINK_RATE_25G 4 -#define NFP_NET_CFG_STS_LINK_RATE_40G 5 -#define NFP_NET_CFG_STS_LINK_RATE_50G 6 -#define NFP_NET_CFG_STS_LINK_RATE_100G 7 -#define NFP_NET_CFG_CAP 0x0038 -#define NFP_NET_CFG_MAX_TXRINGS 0x003c -#define NFP_NET_CFG_MAX_RXRINGS 0x0040 -#define NFP_NET_CFG_MAX_MTU 0x0044 -/* Next two words are being used by VFs for solving THB350 issue */ -#define NFP_NET_CFG_START_TXQ 0x0048 -#define NFP_NET_CFG_START_RXQ 0x004c - -/* - * NFP-3200 workaround (0x0050 - 0x0058) - * @NFP_NET_CFG_SPARE_ADDR: DMA address for ME code to use (e.g. YDS-155 fix) - */ -#define NFP_NET_CFG_SPARE_ADDR 0x0050 -/** - * NFP6000/NFP4000 - Prepend configuration - */ -#define NFP_NET_CFG_RX_OFFSET 0x0050 -#define NFP_NET_CFG_RX_OFFSET_DYNAMIC 0 /* Prepend mode */ - -/** - * Reuse spare address to contain the offset from the start of - * the host buffer where the first byte of the received frame - * will land. Any metadata will come prior to that offset. If the - * value in this field is 0, it means that that the metadata will - * always land starting at the first byte of the host buffer and - * packet data will immediately follow the metadata. As always, - * the RX descriptor indicates the presence or absence of metadata - * along with the length thereof. - */ -#define NFP_NET_CFG_RX_OFFSET_ADDR 0x0050 - -#define NFP_NET_CFG_VXLAN_PORT 0x0060 -#define NFP_NET_CFG_VXLAN_SZ 0x0008 - -/* Offload definitions */ -#define NFP_NET_N_VXLAN_PORTS (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t)) - -/** - * 64B reserved for future use (0x0080 - 0x00c0) - */ -#define NFP_NET_CFG_RESERVED 0x0080 -#define NFP_NET_CFG_RESERVED_SZ 0x0040 - -/* - * RSS configuration (0x0100 - 0x01ac): - * Used only when NFP_NET_CFG_CTRL_RSS is enabled - * @NFP_NET_CFG_RSS_CFG: RSS configuration word - * @NFP_NET_CFG_RSS_KEY: RSS "secret" key - * @NFP_NET_CFG_RSS_ITBL: RSS indirection table - */ -#define NFP_NET_CFG_RSS_BASE 0x0100 -#define NFP_NET_CFG_RSS_CTRL NFP_NET_CFG_RSS_BASE -#define NFP_NET_CFG_RSS_MASK (0x7f) -#define NFP_NET_CFG_RSS_MASK_of(_x) ((_x) & 0x7f) -#define NFP_NET_CFG_RSS_IPV4 (1 << 8) /* RSS for IPv4 */ -#define NFP_NET_CFG_RSS_IPV6 (1 << 9) /* RSS for IPv6 */ -#define NFP_NET_CFG_RSS_IPV4_TCP (1 << 10) /* RSS for IPv4/TCP */ -#define NFP_NET_CFG_RSS_IPV4_UDP (1 << 11) /* RSS for IPv4/UDP */ -#define NFP_NET_CFG_RSS_IPV6_TCP (1 << 12) /* RSS for IPv6/TCP */ -#define NFP_NET_CFG_RSS_IPV6_UDP (1 << 13) /* RSS for IPv6/UDP */ -#define NFP_NET_CFG_RSS_TOEPLITZ (1 << 24) /* Use Toeplitz hash */ -#define NFP_NET_CFG_RSS_KEY (NFP_NET_CFG_RSS_BASE + 0x4) -#define NFP_NET_CFG_RSS_KEY_SZ 0x28 -#define NFP_NET_CFG_RSS_ITBL (NFP_NET_CFG_RSS_BASE + 0x4 + \ - NFP_NET_CFG_RSS_KEY_SZ) -#define NFP_NET_CFG_RSS_ITBL_SZ 0x80 - -/* - * TX ring configuration (0x200 - 0x800) - * @NFP_NET_CFG_TXR_BASE: Base offset for TX ring configuration - * @NFP_NET_CFG_TXR_ADDR: Per TX ring DMA address (8B entries) - * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries) - * @NFP_NET_CFG_TXR_SZ: Per TX ring ring size (1B entries) - * @NFP_NET_CFG_TXR_VEC: Per TX ring MSI-X table entry (1B entries) - * @NFP_NET_CFG_TXR_PRIO: Per TX ring priority (1B entries) - * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries) - */ -#define NFP_NET_CFG_TXR_BASE 0x0200 -#define NFP_NET_CFG_TXR_ADDR(_x) (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8)) -#define NFP_NET_CFG_TXR_WB_ADDR(_x) (NFP_NET_CFG_TXR_BASE + 0x200 + \ - ((_x) * 0x8)) -#define NFP_NET_CFG_TXR_SZ(_x) (NFP_NET_CFG_TXR_BASE + 0x400 + (_x)) -#define NFP_NET_CFG_TXR_VEC(_x) (NFP_NET_CFG_TXR_BASE + 0x440 + (_x)) -#define NFP_NET_CFG_TXR_PRIO(_x) (NFP_NET_CFG_TXR_BASE + 0x480 + (_x)) -#define NFP_NET_CFG_TXR_IRQ_MOD(_x) (NFP_NET_CFG_TXR_BASE + 0x500 + \ - ((_x) * 0x4)) - -/* - * RX ring configuration (0x0800 - 0x0c00) - * @NFP_NET_CFG_RXR_BASE: Base offset for RX ring configuration - * @NFP_NET_CFG_RXR_ADDR: Per TX ring DMA address (8B entries) - * @NFP_NET_CFG_RXR_SZ: Per TX ring ring size (1B entries) - * @NFP_NET_CFG_RXR_VEC: Per TX ring MSI-X table entry (1B entries) - * @NFP_NET_CFG_RXR_PRIO: Per TX ring priority (1B entries) - * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries) - */ -#define NFP_NET_CFG_RXR_BASE 0x0800 -#define NFP_NET_CFG_RXR_ADDR(_x) (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8)) -#define NFP_NET_CFG_RXR_SZ(_x) (NFP_NET_CFG_RXR_BASE + 0x200 + (_x)) -#define NFP_NET_CFG_RXR_VEC(_x) (NFP_NET_CFG_RXR_BASE + 0x240 + (_x)) -#define NFP_NET_CFG_RXR_PRIO(_x) (NFP_NET_CFG_RXR_BASE + 0x280 + (_x)) -#define NFP_NET_CFG_RXR_IRQ_MOD(_x) (NFP_NET_CFG_RXR_BASE + 0x300 + \ - ((_x) * 0x4)) - -/* - * Interrupt Control/Cause registers (0x0c00 - 0x0d00) - * These registers are only used when MSI-X auto-masking is not - * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set). The array is index - * by MSI-X entry and are 1B in size. If an entry is zero, the - * corresponding entry is enabled. If the FW generates an interrupt, - * it writes a cause into the corresponding field. This also masks - * the MSI-X entry and the host driver must clear the register to - * re-enable the interrupt. - */ -#define NFP_NET_CFG_ICR_BASE 0x0c00 -#define NFP_NET_CFG_ICR(_x) (NFP_NET_CFG_ICR_BASE + (_x)) -#define NFP_NET_CFG_ICR_UNMASKED 0x0 -#define NFP_NET_CFG_ICR_RXTX 0x1 -#define NFP_NET_CFG_ICR_LSC 0x2 - -/* - * General device stats (0x0d00 - 0x0d90) - * all counters are 64bit. - */ -#define NFP_NET_CFG_STATS_BASE 0x0d00 -#define NFP_NET_CFG_STATS_RX_DISCARDS (NFP_NET_CFG_STATS_BASE + 0x00) -#define NFP_NET_CFG_STATS_RX_ERRORS (NFP_NET_CFG_STATS_BASE + 0x08) -#define NFP_NET_CFG_STATS_RX_OCTETS (NFP_NET_CFG_STATS_BASE + 0x10) -#define NFP_NET_CFG_STATS_RX_UC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x18) -#define NFP_NET_CFG_STATS_RX_MC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x20) -#define NFP_NET_CFG_STATS_RX_BC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x28) -#define NFP_NET_CFG_STATS_RX_FRAMES (NFP_NET_CFG_STATS_BASE + 0x30) -#define NFP_NET_CFG_STATS_RX_MC_FRAMES (NFP_NET_CFG_STATS_BASE + 0x38) -#define NFP_NET_CFG_STATS_RX_BC_FRAMES (NFP_NET_CFG_STATS_BASE + 0x40) - -#define NFP_NET_CFG_STATS_TX_DISCARDS (NFP_NET_CFG_STATS_BASE + 0x48) -#define NFP_NET_CFG_STATS_TX_ERRORS (NFP_NET_CFG_STATS_BASE + 0x50) -#define NFP_NET_CFG_STATS_TX_OCTETS (NFP_NET_CFG_STATS_BASE + 0x58) -#define NFP_NET_CFG_STATS_TX_UC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x60) -#define NFP_NET_CFG_STATS_TX_MC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x68) -#define NFP_NET_CFG_STATS_TX_BC_OCTETS (NFP_NET_CFG_STATS_BASE + 0x70) -#define NFP_NET_CFG_STATS_TX_FRAMES (NFP_NET_CFG_STATS_BASE + 0x78) -#define NFP_NET_CFG_STATS_TX_MC_FRAMES (NFP_NET_CFG_STATS_BASE + 0x80) -#define NFP_NET_CFG_STATS_TX_BC_FRAMES (NFP_NET_CFG_STATS_BASE + 0x88) - -/* - * Per ring stats (0x1000 - 0x1800) - * options, 64bit per entry - * @NFP_NET_CFG_TXR_STATS: TX ring statistics (Packet and Byte count) - * @NFP_NET_CFG_RXR_STATS: RX ring statistics (Packet and Byte count) - */ -#define NFP_NET_CFG_TXR_STATS_BASE 0x1000 -#define NFP_NET_CFG_TXR_STATS(_x) (NFP_NET_CFG_TXR_STATS_BASE + \ - ((_x) * 0x10)) -#define NFP_NET_CFG_RXR_STATS_BASE 0x1400 -#define NFP_NET_CFG_RXR_STATS(_x) (NFP_NET_CFG_RXR_STATS_BASE + \ - ((_x) * 0x10)) - -/* PF multiport offset */ -#define NFP_PF_CSR_SLICE_SIZE (32 * 1024) - -#endif /* _NFP_CTRL_H_ */ -/* - * Local variables: - * c-file-style: "Linux" - * indent-tabs-mode: t - * End: - */ diff --git a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h b/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h deleted file mode 100644 index 538f882bf..000000000 --- a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h +++ /dev/null @@ -1,725 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Netronome Systems, Inc. - * All rights reserved. - */ - -#ifndef __NFP_CPPAT_H__ -#define __NFP_CPPAT_H__ - -#include "nfp_platform.h" -#include "nfp_resid.h" - -/* This file contains helpers for creating CPP commands - * - * All magic NFP-6xxx IMB 'mode' numbers here are from: - * Databook (1 August 2013) - * - System Overview and Connectivity - * -- Internal Connectivity - * --- Distributed Switch Fabric - Command Push/Pull (DSF-CPP) Bus - * ---- CPP addressing - * ----- Table 3.6. CPP Address Translation Mode Commands - */ - -#define _NIC_NFP6000_MU_LOCALITY_DIRECT 2 - -static inline int -_nfp6000_decode_basic(uint64_t addr, int *dest_island, int cpp_tgt, int mode, - int addr40, int isld1, int isld0); - -static uint64_t -_nic_mask64(int msb, int lsb, int at0) -{ - uint64_t v; - int w = msb - lsb + 1; - - if (w == 64) - return ~(uint64_t)0; - - if ((lsb + w) > 64) - return 0; - - v = (UINT64_C(1) << w) - 1; - - if (at0) - return v; - - return v << lsb; -} - -/* For VQDR, we may not modify the Channel bits, which might overlap - * with the Index bit. When it does, we need to ensure that isld0 == isld1. - */ -static inline int -_nfp6000_encode_basic(uint64_t *addr, int dest_island, int cpp_tgt, int mode, - int addr40, int isld1, int isld0) -{ - uint64_t _u64; - int iid_lsb, idx_lsb; - int i, v = 0; - int isld[2]; - - isld[0] = isld0; - isld[1] = isld1; - - switch (cpp_tgt) { - case NFP6000_CPPTGT_MU: - /* This function doesn't handle MU */ - return NFP_ERRNO(EINVAL); - case NFP6000_CPPTGT_CTXPB: - /* This function doesn't handle CTXPB */ - return NFP_ERRNO(EINVAL); - default: - break; - } - - switch (mode) { - case 0: - if (cpp_tgt == NFP6000_CPPTGT_VQDR && !addr40) { - /* - * In this specific mode we'd rather not modify the - * address but we can verify if the existing contents - * will point to a valid island. - */ - i = _nfp6000_decode_basic(*addr, &v, cpp_tgt, mode, - addr40, isld1, - isld0); - if (i != 0) - /* Full Island ID and channel bits overlap */ - return i; - - /* - * If dest_island is invalid, the current address won't - * go where expected. - */ - if (dest_island != -1 && dest_island != v) - return NFP_ERRNO(EINVAL); - - /* If dest_island was -1, we don't care */ - return 0; - } - - iid_lsb = (addr40) ? 34 : 26; - - /* <39:34> or <31:26> */ - _u64 = _nic_mask64((iid_lsb + 5), iid_lsb, 0); - *addr &= ~_u64; - *addr |= (((uint64_t)dest_island) << iid_lsb) & _u64; - return 0; - case 1: - if (cpp_tgt == NFP6000_CPPTGT_VQDR && !addr40) { - i = _nfp6000_decode_basic(*addr, &v, cpp_tgt, mode, - addr40, isld1, isld0); - if (i != 0) - /* Full Island ID and channel bits overlap */ - return i; - - /* - * If dest_island is invalid, the current address won't - * go where expected. - */ - if (dest_island != -1 && dest_island != v) - return NFP_ERRNO(EINVAL); - - /* If dest_island was -1, we don't care */ - return 0; - } - - idx_lsb = (addr40) ? 39 : 31; - if (dest_island == isld0) { - /* Only need to clear the Index bit */ - *addr &= ~_nic_mask64(idx_lsb, idx_lsb, 0); - return 0; - } - - if (dest_island == isld1) { - /* Only need to set the Index bit */ - *addr |= (UINT64_C(1) << idx_lsb); - return 0; - } - - return NFP_ERRNO(ENODEV); - case 2: - if (cpp_tgt == NFP6000_CPPTGT_VQDR && !addr40) { - /* iid<0> = addr<30> = channel<0> */ - /* channel<1> = addr<31> = Index */ - - /* - * Special case where we allow channel bits to be set - * before hand and with them select an island. - * So we need to confirm that it's at least plausible. - */ - i = _nfp6000_decode_basic(*addr, &v, cpp_tgt, mode, - addr40, isld1, isld0); - if (i != 0) - /* Full Island ID and channel bits overlap */ - return i; - - /* - * If dest_island is invalid, the current address won't - * go where expected. - */ - if (dest_island != -1 && dest_island != v) - return NFP_ERRNO(EINVAL); - - /* If dest_island was -1, we don't care */ - return 0; - } - - /* - * Make sure we compare against isldN values by clearing the - * LSB. This is what the silicon does. - **/ - isld[0] &= ~1; - isld[1] &= ~1; - - idx_lsb = (addr40) ? 39 : 31; - iid_lsb = idx_lsb - 1; - - /* - * Try each option, take first one that fits. Not sure if we - * would want to do some smarter searching and prefer 0 or non-0 - * island IDs. - */ - - for (i = 0; i < 2; i++) { - for (v = 0; v < 2; v++) { - if (dest_island != (isld[i] | v)) - continue; - *addr &= ~_nic_mask64(idx_lsb, iid_lsb, 0); - *addr |= (((uint64_t)i) << idx_lsb); - *addr |= (((uint64_t)v) << iid_lsb); - return 0; - } - } - - return NFP_ERRNO(ENODEV); - case 3: - if (cpp_tgt == NFP6000_CPPTGT_VQDR && !addr40) { - /* - * iid<0> = addr<29> = data - * iid<1> = addr<30> = channel<0> - * channel<1> = addr<31> = Index - */ - i = _nfp6000_decode_basic(*addr, &v, cpp_tgt, mode, - addr40, isld1, isld0); - if (i != 0) - /* Full Island ID and channel bits overlap */ - return i; - - if (dest_island != -1 && dest_island != v) - return NFP_ERRNO(EINVAL); - - /* If dest_island was -1, we don't care */ - return 0; - } - - isld[0] &= ~3; - isld[1] &= ~3; - - idx_lsb = (addr40) ? 39 : 31; - iid_lsb = idx_lsb - 2; - - for (i = 0; i < 2; i++) { - for (v = 0; v < 4; v++) { - if (dest_island != (isld[i] | v)) - continue; - *addr &= ~_nic_mask64(idx_lsb, iid_lsb, 0); - *addr |= (((uint64_t)i) << idx_lsb); - *addr |= (((uint64_t)v) << iid_lsb); - return 0; - } - } - return NFP_ERRNO(ENODEV); - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_decode_basic(uint64_t addr, int *dest_island, int cpp_tgt, int mode, - int addr40, int isld1, int isld0) -{ - int iid_lsb, idx_lsb; - - switch (cpp_tgt) { - case NFP6000_CPPTGT_MU: - /* This function doesn't handle MU */ - return NFP_ERRNO(EINVAL); - case NFP6000_CPPTGT_CTXPB: - /* This function doesn't handle CTXPB */ - return NFP_ERRNO(EINVAL); - default: - break; - } - - switch (mode) { - case 0: - /* - * For VQDR, in this mode for 32-bit addressing it would be - * islands 0, 16, 32 and 48 depending on channel and upper - * address bits. Since those are not all valid islands, most - * decode cases would result in bad island IDs, but we do them - * anyway since this is decoding an address that is already - * assumed to be used as-is to get to sram. - */ - iid_lsb = (addr40) ? 34 : 26; - *dest_island = (int)(addr >> iid_lsb) & 0x3F; - return 0; - case 1: - /* - * For VQDR 32-bit, this would decode as: - * Channel 0: island#0 - * Channel 1: island#0 - * Channel 2: island#1 - * Channel 3: island#1 - * - * That would be valid as long as both islands have VQDR. - * Let's allow this. - */ - - idx_lsb = (addr40) ? 39 : 31; - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1; - else - *dest_island = isld0; - - return 0; - case 2: - /* - * For VQDR 32-bit: - * Channel 0: (island#0 | 0) - * Channel 1: (island#0 | 1) - * Channel 2: (island#1 | 0) - * Channel 3: (island#1 | 1) - * - * Make sure we compare against isldN values by clearing the - * LSB. This is what the silicon does. - */ - isld0 &= ~1; - isld1 &= ~1; - - idx_lsb = (addr40) ? 39 : 31; - iid_lsb = idx_lsb - 1; - - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1 | (int)((addr >> iid_lsb) & 1); - else - *dest_island = isld0 | (int)((addr >> iid_lsb) & 1); - - return 0; - case 3: - /* - * In this mode the data address starts to affect the island ID - * so rather not allow it. In some really specific case one - * could use this to send the upper half of the VQDR channel to - * another MU, but this is getting very specific. However, as - * above for mode 0, this is the decoder and the caller should - * validate the resulting IID. This blindly does what the - * silicon would do. - */ - - isld0 &= ~3; - isld1 &= ~3; - - idx_lsb = (addr40) ? 39 : 31; - iid_lsb = idx_lsb - 2; - - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1 | (int)((addr >> iid_lsb) & 3); - else - *dest_island = isld0 | (int)((addr >> iid_lsb) & 3); - - return 0; - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_cppat_mu_locality_lsb(int mode, int addr40) -{ - switch (mode) { - case 0: - case 1: - case 2: - case 3: - return (addr40) ? 38 : 30; - default: - break; - } - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_encode_mu(uint64_t *addr, int dest_island, int mode, int addr40, - int isld1, int isld0) -{ - uint64_t _u64; - int iid_lsb, idx_lsb, locality_lsb; - int i, v; - int isld[2]; - int da; - - isld[0] = isld0; - isld[1] = isld1; - locality_lsb = _nfp6000_cppat_mu_locality_lsb(mode, addr40); - - if (locality_lsb < 0) - return NFP_ERRNO(EINVAL); - - if (((*addr >> locality_lsb) & 3) == _NIC_NFP6000_MU_LOCALITY_DIRECT) - da = 1; - else - da = 0; - - switch (mode) { - case 0: - iid_lsb = (addr40) ? 32 : 24; - _u64 = _nic_mask64((iid_lsb + 5), iid_lsb, 0); - *addr &= ~_u64; - *addr |= (((uint64_t)dest_island) << iid_lsb) & _u64; - return 0; - case 1: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - _u64 = _nic_mask64((iid_lsb + 5), iid_lsb, 0); - *addr &= ~_u64; - *addr |= (((uint64_t)dest_island) << iid_lsb) & _u64; - return 0; - } - - idx_lsb = (addr40) ? 37 : 29; - if (dest_island == isld0) { - *addr &= ~_nic_mask64(idx_lsb, idx_lsb, 0); - return 0; - } - - if (dest_island == isld1) { - *addr |= (UINT64_C(1) << idx_lsb); - return 0; - } - - return NFP_ERRNO(ENODEV); - case 2: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - _u64 = _nic_mask64((iid_lsb + 5), iid_lsb, 0); - *addr &= ~_u64; - *addr |= (((uint64_t)dest_island) << iid_lsb) & _u64; - return 0; - } - - /* - * Make sure we compare against isldN values by clearing the - * LSB. This is what the silicon does. - */ - isld[0] &= ~1; - isld[1] &= ~1; - - idx_lsb = (addr40) ? 37 : 29; - iid_lsb = idx_lsb - 1; - - /* - * Try each option, take first one that fits. Not sure if we - * would want to do some smarter searching and prefer 0 or - * non-0 island IDs. - */ - - for (i = 0; i < 2; i++) { - for (v = 0; v < 2; v++) { - if (dest_island != (isld[i] | v)) - continue; - *addr &= ~_nic_mask64(idx_lsb, iid_lsb, 0); - *addr |= (((uint64_t)i) << idx_lsb); - *addr |= (((uint64_t)v) << iid_lsb); - return 0; - } - } - return NFP_ERRNO(ENODEV); - case 3: - /* - * Only the EMU will use 40 bit addressing. Silently set the - * direct locality bit for everyone else. The SDK toolchain - * uses dest_island <= 0 to test for atypical address encodings - * to support access to local-island CTM with a 32-but address - * (high-locality is effectively ignored and just used for - * routing to island #0). - */ - if (dest_island > 0 && - (dest_island < 24 || dest_island > 26)) { - *addr |= ((uint64_t)_NIC_NFP6000_MU_LOCALITY_DIRECT) - << locality_lsb; - da = 1; - } - - if (da) { - iid_lsb = (addr40) ? 32 : 24; - _u64 = _nic_mask64((iid_lsb + 5), iid_lsb, 0); - *addr &= ~_u64; - *addr |= (((uint64_t)dest_island) << iid_lsb) & _u64; - return 0; - } - - isld[0] &= ~3; - isld[1] &= ~3; - - idx_lsb = (addr40) ? 37 : 29; - iid_lsb = idx_lsb - 2; - - for (i = 0; i < 2; i++) { - for (v = 0; v < 4; v++) { - if (dest_island != (isld[i] | v)) - continue; - *addr &= ~_nic_mask64(idx_lsb, iid_lsb, 0); - *addr |= (((uint64_t)i) << idx_lsb); - *addr |= (((uint64_t)v) << iid_lsb); - return 0; - } - } - - return NFP_ERRNO(ENODEV); - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_decode_mu(uint64_t addr, int *dest_island, int mode, int addr40, - int isld1, int isld0) -{ - int iid_lsb, idx_lsb, locality_lsb; - int da; - - locality_lsb = _nfp6000_cppat_mu_locality_lsb(mode, addr40); - - if (((addr >> locality_lsb) & 3) == _NIC_NFP6000_MU_LOCALITY_DIRECT) - da = 1; - else - da = 0; - - switch (mode) { - case 0: - iid_lsb = (addr40) ? 32 : 24; - *dest_island = (int)(addr >> iid_lsb) & 0x3F; - return 0; - case 1: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *dest_island = (int)(addr >> iid_lsb) & 0x3F; - return 0; - } - - idx_lsb = (addr40) ? 37 : 29; - - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1; - else - *dest_island = isld0; - - return 0; - case 2: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *dest_island = (int)(addr >> iid_lsb) & 0x3F; - return 0; - } - /* - * Make sure we compare against isldN values by clearing the - * LSB. This is what the silicon does. - */ - isld0 &= ~1; - isld1 &= ~1; - - idx_lsb = (addr40) ? 37 : 29; - iid_lsb = idx_lsb - 1; - - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1 | (int)((addr >> iid_lsb) & 1); - else - *dest_island = isld0 | (int)((addr >> iid_lsb) & 1); - - return 0; - case 3: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *dest_island = (int)(addr >> iid_lsb) & 0x3F; - return 0; - } - - isld0 &= ~3; - isld1 &= ~3; - - idx_lsb = (addr40) ? 37 : 29; - iid_lsb = idx_lsb - 2; - - if (addr & _nic_mask64(idx_lsb, idx_lsb, 0)) - *dest_island = isld1 | (int)((addr >> iid_lsb) & 3); - else - *dest_island = isld0 | (int)((addr >> iid_lsb) & 3); - - return 0; - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_cppat_addr_encode(uint64_t *addr, int dest_island, int cpp_tgt, - int mode, int addr40, int isld1, int isld0) -{ - switch (cpp_tgt) { - case NFP6000_CPPTGT_NBI: - case NFP6000_CPPTGT_VQDR: - case NFP6000_CPPTGT_ILA: - case NFP6000_CPPTGT_PCIE: - case NFP6000_CPPTGT_ARM: - case NFP6000_CPPTGT_CRYPTO: - case NFP6000_CPPTGT_CLS: - return _nfp6000_encode_basic(addr, dest_island, cpp_tgt, mode, - addr40, isld1, isld0); - - case NFP6000_CPPTGT_MU: - return _nfp6000_encode_mu(addr, dest_island, mode, addr40, - isld1, isld0); - - case NFP6000_CPPTGT_CTXPB: - if (mode != 1 || addr40 != 0) - return NFP_ERRNO(EINVAL); - - *addr &= ~_nic_mask64(29, 24, 0); - *addr |= (((uint64_t)dest_island) << 24) & - _nic_mask64(29, 24, 0); - return 0; - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -static inline int -_nfp6000_cppat_addr_decode(uint64_t addr, int *dest_island, int cpp_tgt, - int mode, int addr40, int isld1, int isld0) -{ - switch (cpp_tgt) { - case NFP6000_CPPTGT_NBI: - case NFP6000_CPPTGT_VQDR: - case NFP6000_CPPTGT_ILA: - case NFP6000_CPPTGT_PCIE: - case NFP6000_CPPTGT_ARM: - case NFP6000_CPPTGT_CRYPTO: - case NFP6000_CPPTGT_CLS: - return _nfp6000_decode_basic(addr, dest_island, cpp_tgt, mode, - addr40, isld1, isld0); - - case NFP6000_CPPTGT_MU: - return _nfp6000_decode_mu(addr, dest_island, mode, addr40, - isld1, isld0); - - case NFP6000_CPPTGT_CTXPB: - if (mode != 1 || addr40 != 0) - return -EINVAL; - *dest_island = (int)(addr >> 24) & 0x3F; - return 0; - default: - break; - } - - return -EINVAL; -} - -static inline int -_nfp6000_cppat_addr_iid_clear(uint64_t *addr, int cpp_tgt, int mode, int addr40) -{ - int iid_lsb, locality_lsb, da; - - switch (cpp_tgt) { - case NFP6000_CPPTGT_NBI: - case NFP6000_CPPTGT_VQDR: - case NFP6000_CPPTGT_ILA: - case NFP6000_CPPTGT_PCIE: - case NFP6000_CPPTGT_ARM: - case NFP6000_CPPTGT_CRYPTO: - case NFP6000_CPPTGT_CLS: - switch (mode) { - case 0: - iid_lsb = (addr40) ? 34 : 26; - *addr &= ~(UINT64_C(0x3F) << iid_lsb); - return 0; - case 1: - iid_lsb = (addr40) ? 39 : 31; - *addr &= ~_nic_mask64(iid_lsb, iid_lsb, 0); - return 0; - case 2: - iid_lsb = (addr40) ? 38 : 30; - *addr &= ~_nic_mask64(iid_lsb + 1, iid_lsb, 0); - return 0; - case 3: - iid_lsb = (addr40) ? 37 : 29; - *addr &= ~_nic_mask64(iid_lsb + 2, iid_lsb, 0); - return 0; - default: - break; - } - case NFP6000_CPPTGT_MU: - locality_lsb = _nfp6000_cppat_mu_locality_lsb(mode, addr40); - da = (((*addr >> locality_lsb) & 3) == - _NIC_NFP6000_MU_LOCALITY_DIRECT); - switch (mode) { - case 0: - iid_lsb = (addr40) ? 32 : 24; - *addr &= ~(UINT64_C(0x3F) << iid_lsb); - return 0; - case 1: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *addr &= ~(UINT64_C(0x3F) << iid_lsb); - return 0; - } - iid_lsb = (addr40) ? 37 : 29; - *addr &= ~_nic_mask64(iid_lsb, iid_lsb, 0); - return 0; - case 2: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *addr &= ~(UINT64_C(0x3F) << iid_lsb); - return 0; - } - - iid_lsb = (addr40) ? 36 : 28; - *addr &= ~_nic_mask64(iid_lsb + 1, iid_lsb, 0); - return 0; - case 3: - if (da) { - iid_lsb = (addr40) ? 32 : 24; - *addr &= ~(UINT64_C(0x3F) << iid_lsb); - return 0; - } - - iid_lsb = (addr40) ? 35 : 27; - *addr &= ~_nic_mask64(iid_lsb + 2, iid_lsb, 0); - return 0; - default: - break; - } - case NFP6000_CPPTGT_CTXPB: - if (mode != 1 || addr40 != 0) - return 0; - *addr &= ~(UINT64_C(0x3F) << 24); - return 0; - default: - break; - } - - return NFP_ERRNO(EINVAL); -} - -#endif /* __NFP_CPPAT_H__ */ diff --git a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h deleted file mode 100644 index 7b64e2d32..000000000 --- a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Netronome Systems, Inc. - * All rights reserved. - */ - -#ifndef __NFP_PLATFORM_H__ -#define __NFP_PLATFORM_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef BIT_ULL -#define BIT(x) (1 << (x)) -#define BIT_ULL(x) (1ULL << (x)) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) RTE_DIM(x) -#endif - -#define NFP_ERRNO(err) (errno = (err), -1) -#define NFP_ERRNO_RET(err, ret) (errno = (err), (ret)) -#define NFP_NOERR(errv) (errno) -#define NFP_ERRPTR(err) (errno = (err), NULL) -#define NFP_PTRERR(errv) (errno) - -#endif /* __NFP_PLATFORM_H__ */ diff --git a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h b/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h deleted file mode 100644 index 394a7628e..000000000 --- a/dpdk/drivers/net/nfp/nfpcore/nfp-common/nfp_resid.h +++ /dev/null @@ -1,592 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Netronome Systems, Inc. - * All rights reserved. - */ - -#ifndef __NFP_RESID_H__ -#define __NFP_RESID_H__ - -#if (!defined(_NFP_RESID_NO_C_FUNC) && \ - (defined(__NFP_TOOL_NFCC) || defined(__NFP_TOOL_NFAS))) -#define _NFP_RESID_NO_C_FUNC -#endif - -#ifndef _NFP_RESID_NO_C_FUNC -#include "nfp_platform.h" -#endif - -/* - * NFP Chip Architectures - * - * These are semi-arbitrary values to indicate an NFP architecture. - * They serve as a software view of a group of chip families, not necessarily a - * direct mapping to actual hardware design. - */ -#define NFP_CHIP_ARCH_YD 1 -#define NFP_CHIP_ARCH_TH 2 - -/* - * NFP Chip Families. - * - * These are not enums, because they need to be microcode compatible. - * They are also not maskable. - * - * Note: The NFP-4xxx family is handled as NFP-6xxx in most software - * components. - * - */ -#define NFP_CHIP_FAMILY_NFP6000 0x6000 /* ARCH_TH */ - -/* NFP Microengine/Flow Processing Core Versions */ -#define NFP_CHIP_ME_VERSION_2_7 0x0207 -#define NFP_CHIP_ME_VERSION_2_8 0x0208 -#define NFP_CHIP_ME_VERSION_2_9 0x0209 - -/* NFP Chip Base Revisions. Minor stepping can just be added to these */ -#define NFP_CHIP_REVISION_A0 0x00 -#define NFP_CHIP_REVISION_B0 0x10 -#define NFP_CHIP_REVISION_C0 0x20 -#define NFP_CHIP_REVISION_PF 0xff /* Maximum possible revision */ - -/* CPP Targets for each chip architecture */ -#define NFP6000_CPPTGT_NBI 1 -#define NFP6000_CPPTGT_VQDR 2 -#define NFP6000_CPPTGT_ILA 6 -#define NFP6000_CPPTGT_MU 7 -#define NFP6000_CPPTGT_PCIE 9 -#define NFP6000_CPPTGT_ARM 10 -#define NFP6000_CPPTGT_CRYPTO 12 -#define NFP6000_CPPTGT_CTXPB 14 -#define NFP6000_CPPTGT_CLS 15 - -/* - * Wildcard indicating a CPP read or write action - * - * The action used will be either read or write depending on whether a read or - * write instruction/call is performed on the NFP_CPP_ID. It is recommended that - * the RW action is used even if all actions to be performed on a NFP_CPP_ID are - * known to be only reads or writes. Doing so will in many cases save NFP CPP - * internal software resources. - */ -#define NFP_CPP_ACTION_RW 32 - -#define NFP_CPP_TARGET_ID_MASK 0x1f - -/* - * NFP_CPP_ID - pack target, token, and action into a CPP ID. - * - * Create a 32-bit CPP identifier representing the access to be made. - * These identifiers are used as parameters to other NFP CPP functions. Some - * CPP devices may allow wildcard identifiers to be specified. - * - * @param[in] target NFP CPP target id - * @param[in] action NFP CPP action id - * @param[in] token NFP CPP token id - * @return NFP CPP ID - */ -#define NFP_CPP_ID(target, action, token) \ - ((((target) & 0x7f) << 24) | (((token) & 0xff) << 16) | \ - (((action) & 0xff) << 8)) - -#define NFP_CPP_ISLAND_ID(target, action, token, island) \ - ((((target) & 0x7f) << 24) | (((token) & 0xff) << 16) | \ - (((action) & 0xff) << 8) | (((island) & 0xff) << 0)) - -#ifndef _NFP_RESID_NO_C_FUNC - -/** - * Return the NFP CPP target of a NFP CPP ID - * @param[in] id NFP CPP ID - * @return NFP CPP target - */ -static inline uint8_t -NFP_CPP_ID_TARGET_of(uint32_t id) -{ - return (id >> 24) & NFP_CPP_TARGET_ID_MASK; -} - -/* - * Return the NFP CPP token of a NFP CPP ID - * @param[in] id NFP CPP ID - * @return NFP CPP token - */ -static inline uint8_t -NFP_CPP_ID_TOKEN_of(uint32_t id) -{ - return (id >> 16) & 0xff; -} - -/* - * Return the NFP CPP action of a NFP CPP ID - * @param[in] id NFP CPP ID - * @return NFP CPP action - */ -static inline uint8_t -NFP_CPP_ID_ACTION_of(uint32_t id) -{ - return (id >> 8) & 0xff; -} - -/* - * Return the NFP CPP action of a NFP CPP ID - * @param[in] id NFP CPP ID - * @return NFP CPP action - */ -static inline uint8_t -NFP_CPP_ID_ISLAND_of(uint32_t id) -{ - return (id) & 0xff; -} - -#endif /* _NFP_RESID_NO_C_FUNC */ - -/* - * Check if @p chip_family is an ARCH_TH chip. - * @param chip_family One of NFP_CHIP_FAMILY_* - */ -#define NFP_FAMILY_IS_ARCH_TH(chip_family) \ - ((int)(chip_family) == (int)NFP_CHIP_FAMILY_NFP6000) - -/* - * Get the NFP_CHIP_ARCH_* of @p chip_family. - * @param chip_family One of NFP_CHIP_FAMILY_* - */ -#define NFP_FAMILY_ARCH(x) \ - (__extension__ ({ \ - typeof(x) _x = (x); \ - (NFP_FAMILY_IS_ARCH_TH(_x) ? NFP_CHIP_ARCH_TH : \ - NFP_FAMILY_IS_ARCH_YD(_x) ? NFP_CHIP_ARCH_YD : -1) \ - })) - -/* - * Check if @p chip_family is an NFP-6xxx chip. - * @param chip_family One of NFP_CHIP_FAMILY_* - */ -#define NFP_FAMILY_IS_NFP6000(chip_family) \ - ((int)(chip_family) == (int)NFP_CHIP_FAMILY_NFP6000) - -/* - * Make microengine ID for NFP-6xxx. - * @param island_id Island ID. - * @param menum ME number, 0 based, within island. - * - * NOTE: menum should really be unsigned - MSC compiler throws error (not - * warning) if a clause is always true i.e. menum >= 0 if cluster_num is type - * unsigned int hence the cast of the menum to an int in that particular clause - */ -#define NFP6000_MEID(a, b) \ - (__extension__ ({ \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - (((((int)(_a) & 0x3F) == (int)(_a)) && \ - (((int)(_b) >= 0) && ((int)(_b) < 12))) ? \ - (int)(((_a) << 4) | ((_b) + 4)) : -1) \ - })) - -/* - * Do a general sanity check on the ME ID. - * The check is on the highest possible island ID for the chip family and the - * microengine number must be a master ID. - * @param meid ME ID as created by NFP6000_MEID - */ -#define NFP6000_MEID_IS_VALID(meid) \ - (__extension__ ({ \ - typeof(meid) _a = (meid); \ - ((((_a) >> 4) < 64) && (((_a) >> 4) >= 0) && \ - (((_a) & 0xF) >= 4)) \ - })) - -/* - * Extract island ID from ME ID. - * @param meid ME ID as created by NFP6000_MEID - */ -#define NFP6000_MEID_ISLAND_of(meid) (((meid) >> 4) & 0x3F) - -/* - * Extract microengine number (0 based) from ME ID. - * @param meid ME ID as created by NFP6000_MEID - */ -#define NFP6000_MEID_MENUM_of(meid) (((meid) & 0xF) - 4) - -/* - * Extract microengine group number (0 based) from ME ID. - * The group is two code-sharing microengines, so group 0 refers to MEs 0,1, - * group 1 refers to MEs 2,3 etc. - * @param meid ME ID as created by NFP6000_MEID - */ -#define NFP6000_MEID_MEGRP_of(meid) (NFP6000_MEID_MENUM_of(meid) >> 1) - -#ifndef _NFP_RESID_NO_C_FUNC - -/* - * Convert a string to an ME ID. - * - * @param s A string of format iX.meY - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the ME ID part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return ME ID on success, -1 on error. - */ -int nfp6000_idstr2meid(const char *s, const char **endptr); - -/* - * Extract island ID from string. - * - * Example: - * char *c; - * int val = nfp6000_idstr2island("i32.me5", &c); - * // val == 32, c == "me5" - * val = nfp6000_idstr2island("i32", &c); - * // val == 32, c == "" - * - * @param s A string of format "iX.anything" or "iX" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the island part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the island ID, -1 on error. - */ -int nfp6000_idstr2island(const char *s, const char **endptr); - -/* - * Extract microengine number from string. - * - * Example: - * char *c; - * int menum = nfp6000_idstr2menum("me5.anything", &c); - * // menum == 5, c == "anything" - * menum = nfp6000_idstr2menum("me5", &c); - * // menum == 5, c == "" - * - * @param s A string of format "meX.anything" or "meX" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the ME number part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the ME number, -1 on error. - */ -int nfp6000_idstr2menum(const char *s, const char **endptr); - -/* - * Extract context number from string. - * - * Example: - * char *c; - * int val = nfp6000_idstr2ctxnum("ctx5.anything", &c); - * // val == 5, c == "anything" - * val = nfp6000_idstr2ctxnum("ctx5", &c); - * // val == 5, c == "" - * - * @param s A string of format "ctxN.anything" or "ctxN" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the context number part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the context number, -1 on error. - */ -int nfp6000_idstr2ctxnum(const char *s, const char **endptr); - -/* - * Extract microengine group number from string. - * - * Example: - * char *c; - * int val = nfp6000_idstr2megrp("tg2.anything", &c); - * // val == 2, c == "anything" - * val = nfp6000_idstr2megrp("tg5", &c); - * // val == 2, c == "" - * - * @param s A string of format "tgX.anything" or "tgX" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the ME group part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the ME group number, -1 on error. - */ -int nfp6000_idstr2megrp(const char *s, const char **endptr); - -/* - * Create ME ID string of format "iX[.meY]". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param meid Microengine ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_meid2str(char *s, int meid); - -/* - * Create ME ID string of format "name[.meY]" or "iX[.meY]". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param meid Microengine ID. - * @return Pointer to "s" on success, NULL on error. - * - * Similar to nfp6000_meid2str() except use an alias instead of "iX" - * if one exists for the island. - */ -const char *nfp6000_meid2altstr(char *s, int meid); - -/* - * Create string of format "iX". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param island_id Island ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_island2str(char *s, int island_id); - -/* - * Create string of format "name", an island alias. - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param island_id Island ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_island2altstr(char *s, int island_id); - -/* - * Create string of format "meY". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param menum Microengine number within island. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_menum2str(char *s, int menum); - -/* - * Create string of format "ctxY". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param ctxnum Context number within microengine. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_ctxnum2str(char *s, int ctxnum); - -/* - * Create string of format "tgY". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param megrp Microengine group number within cluster. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp6000_megrp2str(char *s, int megrp); - -/* - * Convert a string to an ME ID. - * - * @param chip_family Chip family ID - * @param s A string of format iX.meY (or clX.meY) - * @param endptr If non-NULL, *endptr will point to the trailing - * string after the ME ID part of the string, which - * is either an empty string or the first character - * after the separating period. - * @return ME ID on success, -1 on error. - */ -int nfp_idstr2meid(int chip_family, const char *s, const char **endptr); - -/* - * Extract island ID from string. - * - * Example: - * char *c; - * int val = nfp_idstr2island(chip, "i32.me5", &c); - * // val == 32, c == "me5" - * val = nfp_idstr2island(chip, "i32", &c); - * // val == 32, c == "" - * - * @param chip_family Chip family ID - * @param s A string of format "iX.anything" or "iX" - * @param endptr If non-NULL, *endptr will point to the trailing - * string after the ME ID part of the string, which - * is either an empty string or the first character - * after the separating period. - * @return The island ID on succes, -1 on error. - */ -int nfp_idstr2island(int chip_family, const char *s, const char **endptr); - -/* - * Extract microengine number from string. - * - * Example: - * char *c; - * int menum = nfp_idstr2menum("me5.anything", &c); - * // menum == 5, c == "anything" - * menum = nfp_idstr2menum("me5", &c); - * // menum == 5, c == "" - * - * @param chip_family Chip family ID - * @param s A string of format "meX.anything" or "meX" - * @param endptr If non-NULL, *endptr will point to the trailing - * string after the ME ID part of the string, which - * is either an empty string or the first character - * after the separating period. - * @return The ME number on succes, -1 on error. - */ -int nfp_idstr2menum(int chip_family, const char *s, const char **endptr); - -/* - * Extract context number from string. - * - * Example: - * char *c; - * int val = nfp_idstr2ctxnum("ctx5.anything", &c); - * // val == 5, c == "anything" - * val = nfp_idstr2ctxnum("ctx5", &c); - * // val == 5, c == "" - * - * @param s A string of format "ctxN.anything" or "ctxN" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the context number part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the context number, -1 on error. - */ -int nfp_idstr2ctxnum(int chip_family, const char *s, const char **endptr); - -/* - * Extract microengine group number from string. - * - * Example: - * char *c; - * int val = nfp_idstr2megrp("tg2.anything", &c); - * // val == 2, c == "anything" - * val = nfp_idstr2megrp("tg5", &c); - * // val == 5, c == "" - * - * @param s A string of format "tgX.anything" or "tgX" - * @param endptr If non-NULL, *endptr will point to the trailing string - * after the ME group part of the string, which is either - * an empty string or the first character after the separating - * period. - * @return If successful, the ME group number, -1 on error. - */ -int nfp_idstr2megrp(int chip_family, const char *s, const char **endptr); - -/* - * Create ME ID string of format "iX[.meY]". - * - * @param chip_family Chip family ID - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param meid Microengine ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_meid2str(int chip_family, char *s, int meid); - -/* - * Create ME ID string of format "name[.meY]" or "iX[.meY]". - * - * @param chip_family Chip family ID - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param meid Microengine ID. - * @return Pointer to "s" on success, NULL on error. - * - * Similar to nfp_meid2str() except use an alias instead of "iX" - * if one exists for the island. - */ -const char *nfp_meid2altstr(int chip_family, char *s, int meid); - -/* - * Create string of format "iX". - * - * @param chip_family Chip family ID - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param island_id Island ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_island2str(int chip_family, char *s, int island_id); - -/* - * Create string of format "name", an island alias. - * - * @param chip_family Chip family ID - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param island_id Island ID. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_island2altstr(int chip_family, char *s, int island_id); - -/* - * Create string of format "meY". - * - * @param chip_family Chip family ID - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param menum Microengine number within island. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_menum2str(int chip_family, char *s, int menum); - -/* - * Create string of format "ctxY". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param ctxnum Context number within microengine. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_ctxnum2str(int chip_family, char *s, int ctxnum); - -/* - * Create string of format "tgY". - * - * @param s Pointer to char buffer of size NFP_MEID_STR_SZ. - * The resulting string is output here. - * @param megrp Microengine group number within cluster. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_megrp2str(int chip_family, char *s, int megrp); - -/* - * Convert a two character string to revision number. - * - * Revision integer is 0x00 for A0, 0x11 for B1 etc. - * - * @param s Two character string. - * @return Revision number, -1 on error - */ -int nfp_idstr2rev(const char *s); - -/* - * Create string from revision number. - * - * String will be upper case. - * - * @param s Pointer to char buffer with size of at least 3 - * for 2 characters and string terminator. - * @param rev Revision number. - * @return Pointer to "s" on success, NULL on error. - */ -const char *nfp_rev2str(char *s, int rev); - -/* - * Get the NFP CPP address from a string - * - * String is in the format [island@]target[:[action:[token:]]address] - * - * @param chip_family Chip family ID - * @param tid Pointer to string to parse - * @param cpp_idp Pointer to CPP ID - * @param cpp_addrp Pointer to CPP address - * @return 0 on success, or -1 and errno - */ -int nfp_str2cpp(int chip_family, - const char *tid, - uint32_t *cpp_idp, - uint64_t *cpp_addrp); - - -#endif /* _NFP_RESID_NO_C_FUNC */ - -#endif /* __NFP_RESID_H__ */ diff --git a/dpdk/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/dpdk/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c deleted file mode 100644 index e59731549..000000000 --- a/dpdk/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ /dev/null @@ -1,897 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Netronome Systems, Inc. - * All rights reserved. - */ - -/* - * nfp_cpp_pcie_ops.c - * Authors: Vinayak Tammineedi - * - * Multiplexes the NFP BARs between NFP internal resources and - * implements the PCIe specific interface for generic CPP bus access. - * - * The BARs are managed and allocated if they are available. - * The generic CPP bus abstraction builds upon this BAR interface. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "nfp_cpp.h" -#include "nfp_target.h" -#include "nfp6000/nfp6000.h" - -#define NFP_PCIE_BAR(_pf) (0x30000 + ((_pf) & 7) * 0xc0) - -#define NFP_PCIE_BAR_PCIE2CPP_ACTION_BASEADDRESS(_x) (((_x) & 0x1f) << 16) -#define NFP_PCIE_BAR_PCIE2CPP_BASEADDRESS(_x) (((_x) & 0xffff) << 0) -#define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT(_x) (((_x) & 0x3) << 27) -#define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_32BIT 0 -#define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_64BIT 1 -#define NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_0BYTE 3 -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE(_x) (((_x) & 0x7) << 29) -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_OF(_x) (((_x) >> 29) & 0x7) -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_FIXED 0 -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_BULK 1 -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_TARGET 2 -#define NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_GENERAL 3 -#define NFP_PCIE_BAR_PCIE2CPP_TARGET_BASEADDRESS(_x) (((_x) & 0xf) << 23) -#define NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(_x) (((_x) & 0x3) << 21) - -/* - * Minimal size of the PCIe cfg memory we depend on being mapped, - * queue controller and DMA controller don't have to be covered. - */ -#define NFP_PCI_MIN_MAP_SIZE 0x080000 - -#define NFP_PCIE_P2C_FIXED_SIZE(bar) (1 << (bar)->bitsize) -#define NFP_PCIE_P2C_BULK_SIZE(bar) (1 << (bar)->bitsize) -#define NFP_PCIE_P2C_GENERAL_TARGET_OFFSET(bar, x) ((x) << ((bar)->bitsize - 2)) -#define NFP_PCIE_P2C_GENERAL_TOKEN_OFFSET(bar, x) ((x) << ((bar)->bitsize - 4)) -#define NFP_PCIE_P2C_GENERAL_SIZE(bar) (1 << ((bar)->bitsize - 4)) - -#define NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(id, bar, slot) \ - (NFP_PCIE_BAR(id) + ((bar) * 8 + (slot)) * 4) - -#define NFP_PCIE_CPP_BAR_PCIETOCPPEXPBAR(bar, slot) \ - (((bar) * 8 + (slot)) * 4) - -/* - * Define to enable a bit more verbose debug output. - * Set to 1 to enable a bit more verbose debug output. - */ -struct nfp_pcie_user; -struct nfp6000_area_priv; - -/* - * struct nfp_bar - describes BAR configuration and usage - * @nfp: backlink to owner - * @barcfg: cached contents of BAR config CSR - * @base: the BAR's base CPP offset - * @mask: mask for the BAR aperture (read only) - * @bitsize: bitsize of BAR aperture (read only) - * @index: index of the BAR - * @lock: lock to specify if bar is in use - * @refcnt: number of current users - * @iomem: mapped IO memory - */ -#define NFP_BAR_MIN 1 -#define NFP_BAR_MID 5 -#define NFP_BAR_MAX 7 - -struct nfp_bar { - struct nfp_pcie_user *nfp; - uint32_t barcfg; - uint64_t base; /* CPP address base */ - uint64_t mask; /* Bit mask of the bar */ - uint32_t bitsize; /* Bit size of the bar */ - int index; - int lock; - - char *csr; - char *iomem; -}; - -#define BUSDEV_SZ 13 -struct nfp_pcie_user { - struct nfp_bar bar[NFP_BAR_MAX]; - - int device; - int lock; - int secondary_lock; - char busdev[BUSDEV_SZ]; - int barsz; - int dev_id; - char *cfg; -}; - -static uint32_t -nfp_bar_maptype(struct nfp_bar *bar) -{ - return NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_OF(bar->barcfg); -} - -#define TARGET_WIDTH_32 4 -#define TARGET_WIDTH_64 8 - -static int -nfp_compute_bar(const struct nfp_bar *bar, uint32_t *bar_config, - uint64_t *bar_base, int tgt, int act, int tok, - uint64_t offset, size_t size, int width) -{ - uint32_t bitsize; - uint32_t newcfg; - uint64_t mask; - - if (tgt >= 16) - return -EINVAL; - - switch (width) { - case 8: - newcfg = - NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT - (NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_64BIT); - break; - case 4: - newcfg = - NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT - (NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_32BIT); - break; - case 0: - newcfg = - NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT - (NFP_PCIE_BAR_PCIE2CPP_LENGTHSELECT_0BYTE); - break; - default: - return -EINVAL; - } - - if (act != NFP_CPP_ACTION_RW && act != 0) { - /* Fixed CPP mapping with specific action */ - mask = ~(NFP_PCIE_P2C_FIXED_SIZE(bar) - 1); - - newcfg |= - NFP_PCIE_BAR_PCIE2CPP_MAPTYPE - (NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_FIXED); - newcfg |= NFP_PCIE_BAR_PCIE2CPP_TARGET_BASEADDRESS(tgt); - newcfg |= NFP_PCIE_BAR_PCIE2CPP_ACTION_BASEADDRESS(act); - newcfg |= NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(tok); - - if ((offset & mask) != ((offset + size - 1) & mask)) { - printf("BAR%d: Won't use for Fixed mapping\n", - bar->index); - printf("\t<%#llx,%#llx>, action=%d\n", - (unsigned long long)offset, - (unsigned long long)(offset + size), act); - printf("\tBAR too small (0x%llx).\n", - (unsigned long long)mask); - return -EINVAL; - } - offset &= mask; - -#ifdef DEBUG - printf("BAR%d: Created Fixed mapping\n", bar->index); - printf("\t%d:%d:%d:0x%#llx-0x%#llx>\n", tgt, act, tok, - (unsigned long long)offset, - (unsigned long long)(offset + mask)); -#endif - - bitsize = 40 - 16; - } else { - mask = ~(NFP_PCIE_P2C_BULK_SIZE(bar) - 1); - - /* Bulk mapping */ - newcfg |= - NFP_PCIE_BAR_PCIE2CPP_MAPTYPE - (NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_BULK); - - newcfg |= NFP_PCIE_BAR_PCIE2CPP_TARGET_BASEADDRESS(tgt); - newcfg |= NFP_PCIE_BAR_PCIE2CPP_TOKEN_BASEADDRESS(tok); - - if ((offset & mask) != ((offset + size - 1) & mask)) { - printf("BAR%d: Won't use for bulk mapping\n", - bar->index); - printf("\t<%#llx,%#llx>\n", (unsigned long long)offset, - (unsigned long long)(offset + size)); - printf("\ttarget=%d, token=%d\n", tgt, tok); - printf("\tBAR too small (%#llx) - (%#llx != %#llx).\n", - (unsigned long long)mask, - (unsigned long long)(offset & mask), - (unsigned long long)(offset + size - 1) & mask); - - return -EINVAL; - } - - offset &= mask; - -#ifdef DEBUG - printf("BAR%d: Created bulk mapping %d:x:%d:%#llx-%#llx\n", - bar->index, tgt, tok, (unsigned long long)offset, - (unsigned long long)(offset + ~mask)); -#endif - - bitsize = 40 - 21; - } - - if (bar->bitsize < bitsize) { - printf("BAR%d: Too small for %d:%d:%d\n", bar->index, tgt, tok, - act); - return -EINVAL; - } - - newcfg |= offset >> bitsize; - - if (bar_base) - *bar_base = offset; - - if (bar_config) - *bar_config = newcfg; - - return 0; -} - -static int -nfp_bar_write(struct nfp_pcie_user *nfp, struct nfp_bar *bar, - uint32_t newcfg) -{ - int base, slot; - - base = bar->index >> 3; - slot = bar->index & 7; - - if (!nfp->cfg) - return (-ENOMEM); - - bar->csr = nfp->cfg + - NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(nfp->dev_id, base, slot); - - *(uint32_t *)(bar->csr) = newcfg; - - bar->barcfg = newcfg; -#ifdef DEBUG - printf("BAR%d: updated to 0x%08x\n", bar->index, newcfg); -#endif - - return 0; -} - -static int -nfp_reconfigure_bar(struct nfp_pcie_user *nfp, struct nfp_bar *bar, int tgt, - int act, int tok, uint64_t offset, size_t size, int width) -{ - uint64_t newbase; - uint32_t newcfg; - int err; - - err = nfp_compute_bar(bar, &newcfg, &newbase, tgt, act, tok, offset, - size, width); - if (err) - return err; - - bar->base = newbase; - - return nfp_bar_write(nfp, bar, newcfg); -} - -/* - * Map all PCI bars. We assume that the BAR with the PCIe config block is - * already mapped. - * - * BAR0.0: Reserved for General Mapping (for MSI-X access to PCIe SRAM) - * - * Halving PCItoCPPBars for primary and secondary processes. - * For CoreNIC firmware: - * NFP PMD just requires two fixed slots, one for configuration BAR, - * and another for accessing the hw queues. Another slot is needed - * for setting the link up or down. Secondary processes do not need - * to map the first two slots again, but it requires one slot for - * accessing the link, even if it is not likely the secondary process - * starting the port. This implies a limit of secondary processes - * supported. Due to this requirement and future extensions requiring - * new slots per process, only one secondary process is supported by - * now. - * For Flower firmware: - * NFP PMD need another fixed slots, used as the configureation BAR - * for ctrl vNIC. - */ -static int -nfp_enable_bars(struct nfp_pcie_user *nfp) -{ - struct nfp_bar *bar; - int x, start, end; - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = NFP_BAR_MID; - end = NFP_BAR_MIN; - } else { - start = NFP_BAR_MAX; - end = NFP_BAR_MID; - } - for (x = start; x > end; x--) { - bar = &nfp->bar[x - 1]; - bar->barcfg = 0; - bar->nfp = nfp; - bar->index = x; - bar->mask = (1 << (nfp->barsz - 3)) - 1; - bar->bitsize = nfp->barsz - 3; - bar->base = 0; - bar->iomem = NULL; - bar->lock = 0; - bar->csr = nfp->cfg + NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(nfp->dev_id, - bar->index >> 3, bar->index & 7); - bar->iomem = nfp->cfg + (bar->index << bar->bitsize); - } - return 0; -} - -static struct nfp_bar * -nfp_alloc_bar(struct nfp_pcie_user *nfp) -{ - struct nfp_bar *bar; - int x, start, end; - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = NFP_BAR_MID; - end = NFP_BAR_MIN; - } else { - start = NFP_BAR_MAX; - end = NFP_BAR_MID; - } - for (x = start; x > end; x--) { - bar = &nfp->bar[x - 1]; - if (!bar->lock) { - bar->lock = 1; - return bar; - } - } - return NULL; -} - -static void -nfp_disable_bars(struct nfp_pcie_user *nfp) -{ - struct nfp_bar *bar; - int x, start, end; - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = NFP_BAR_MID; - end = NFP_BAR_MIN; - } else { - start = NFP_BAR_MAX; - end = NFP_BAR_MID; - } - - for (x = start; x > end; x--) { - bar = &nfp->bar[x - 1]; - if (bar->iomem) { - bar->iomem = NULL; - bar->lock = 0; - } - } -} - -/* - * Generic CPP bus access interface. - */ - -struct nfp6000_area_priv { - struct nfp_bar *bar; - uint32_t bar_offset; - - uint32_t target; - uint32_t action; - uint32_t token; - uint64_t offset; - struct { - int read; - int write; - int bar; - } width; - size_t size; - char *iomem; -}; - -static int -nfp6000_area_init(struct nfp_cpp_area *area, uint32_t dest, - unsigned long long address, unsigned long size) -{ - struct nfp_pcie_user *nfp = nfp_cpp_priv(nfp_cpp_area_cpp(area)); - struct nfp6000_area_priv *priv = nfp_cpp_area_priv(area); - uint32_t target = NFP_CPP_ID_TARGET_of(dest); - uint32_t action = NFP_CPP_ID_ACTION_of(dest); - uint32_t token = NFP_CPP_ID_TOKEN_of(dest); - int pp, ret = 0; - - pp = nfp6000_target_pushpull(NFP_CPP_ID(target, action, token), - address); - if (pp < 0) - return pp; - - priv->width.read = PUSH_WIDTH(pp); - priv->width.write = PULL_WIDTH(pp); - - if (priv->width.read > 0 && - priv->width.write > 0 && priv->width.read != priv->width.write) - return -EINVAL; - - if (priv->width.read > 0) - priv->width.bar = priv->width.read; - else - priv->width.bar = priv->width.write; - - priv->bar = nfp_alloc_bar(nfp); - if (priv->bar == NULL) - return -ENOMEM; - - priv->target = target; - priv->action = action; - priv->token = token; - priv->offset = address; - priv->size = size; - - ret = nfp_reconfigure_bar(nfp, priv->bar, priv->target, priv->action, - priv->token, priv->offset, priv->size, - priv->width.bar); - - return ret; -} - -static int -nfp6000_area_acquire(struct nfp_cpp_area *area) -{ - struct nfp6000_area_priv *priv = nfp_cpp_area_priv(area); - - /* Calculate offset into BAR. */ - if (nfp_bar_maptype(priv->bar) == - NFP_PCIE_BAR_PCIE2CPP_MAPTYPE_GENERAL) { - priv->bar_offset = priv->offset & - (NFP_PCIE_P2C_GENERAL_SIZE(priv->bar) - 1); - priv->bar_offset += - NFP_PCIE_P2C_GENERAL_TARGET_OFFSET(priv->bar, - priv->target); - priv->bar_offset += - NFP_PCIE_P2C_GENERAL_TOKEN_OFFSET(priv->bar, priv->token); - } else { - priv->bar_offset = priv->offset & priv->bar->mask; - } - - /* Must have been too big. Sub-allocate. */ - if (!priv->bar->iomem) - return (-ENOMEM); - - priv->iomem = priv->bar->iomem + priv->bar_offset; - - return 0; -} - -static void * -nfp6000_area_mapped(struct nfp_cpp_area *area) -{ - struct nfp6000_area_priv *area_priv = nfp_cpp_area_priv(area); - - if (!area_priv->iomem) - return NULL; - - return area_priv->iomem; -} - -static void -nfp6000_area_release(struct nfp_cpp_area *area) -{ - struct nfp6000_area_priv *priv = nfp_cpp_area_priv(area); - priv->bar->lock = 0; - priv->bar = NULL; - priv->iomem = NULL; -} - -static void * -nfp6000_area_iomem(struct nfp_cpp_area *area) -{ - struct nfp6000_area_priv *priv = nfp_cpp_area_priv(area); - return priv->iomem; -} - -static int -nfp6000_area_read(struct nfp_cpp_area *area, void *kernel_vaddr, - unsigned long offset, unsigned int length) -{ - uint64_t *wrptr64 = kernel_vaddr; - const volatile uint64_t *rdptr64; - struct nfp6000_area_priv *priv; - uint32_t *wrptr32 = kernel_vaddr; - const volatile uint32_t *rdptr32; - int width; - unsigned int n; - bool is_64; - - priv = nfp_cpp_area_priv(area); - rdptr64 = (uint64_t *)(priv->iomem + offset); - rdptr32 = (uint32_t *)(priv->iomem + offset); - - if (offset + length > priv->size) - return -EFAULT; - - width = priv->width.read; - - if (width <= 0) - return -EINVAL; - - /* Unaligned? Translate to an explicit access */ - if ((priv->offset + offset) & (width - 1)) { - printf("aread_read unaligned!!!\n"); - return -EINVAL; - } - - is_64 = width == TARGET_WIDTH_64; - - /* MU reads via a PCIe2CPP BAR supports 32bit (and other) lengths */ - if (priv->target == (NFP_CPP_TARGET_ID_MASK & NFP_CPP_TARGET_MU) && - priv->action == NFP_CPP_ACTION_RW) { - is_64 = false; - } - - if (is_64) { - if (offset % sizeof(uint64_t) != 0 || - length % sizeof(uint64_t) != 0) - return -EINVAL; - } else { - if (offset % sizeof(uint32_t) != 0 || - length % sizeof(uint32_t) != 0) - return -EINVAL; - } - - if (!priv->bar) - return -EFAULT; - - if (is_64) - for (n = 0; n < length; n += sizeof(uint64_t)) { - *wrptr64 = *rdptr64; - wrptr64++; - rdptr64++; - } - else - for (n = 0; n < length; n += sizeof(uint32_t)) { - *wrptr32 = *rdptr32; - wrptr32++; - rdptr32++; - } - - return n; -} - -static int -nfp6000_area_write(struct nfp_cpp_area *area, const void *kernel_vaddr, - unsigned long offset, unsigned int length) -{ - const uint64_t *rdptr64 = kernel_vaddr; - uint64_t *wrptr64; - const uint32_t *rdptr32 = kernel_vaddr; - struct nfp6000_area_priv *priv; - uint32_t *wrptr32; - int width; - unsigned int n; - bool is_64; - - priv = nfp_cpp_area_priv(area); - wrptr64 = (uint64_t *)(priv->iomem + offset); - wrptr32 = (uint32_t *)(priv->iomem + offset); - - if (offset + length > priv->size) - return -EFAULT; - - width = priv->width.write; - - if (width <= 0) - return -EINVAL; - - /* Unaligned? Translate to an explicit access */ - if ((priv->offset + offset) & (width - 1)) - return -EINVAL; - - is_64 = width == TARGET_WIDTH_64; - - /* MU writes via a PCIe2CPP BAR supports 32bit (and other) lengths */ - if (priv->target == (NFP_CPP_TARGET_ID_MASK & NFP_CPP_TARGET_MU) && - priv->action == NFP_CPP_ACTION_RW) - is_64 = false; - - if (is_64) { - if (offset % sizeof(uint64_t) != 0 || - length % sizeof(uint64_t) != 0) - return -EINVAL; - } else { - if (offset % sizeof(uint32_t) != 0 || - length % sizeof(uint32_t) != 0) - return -EINVAL; - } - - if (!priv->bar) - return -EFAULT; - - if (is_64) - for (n = 0; n < length; n += sizeof(uint64_t)) { - *wrptr64 = *rdptr64; - wrptr64++; - rdptr64++; - } - else - for (n = 0; n < length; n += sizeof(uint32_t)) { - *wrptr32 = *rdptr32; - wrptr32++; - rdptr32++; - } - - return n; -} - -#define PCI_DEVICES "/sys/bus/pci/devices" - -static int -nfp_acquire_process_lock(struct nfp_pcie_user *desc) -{ - int rc; - struct flock lock; - char lockname[30]; - - memset(&lock, 0, sizeof(lock)); - - snprintf(lockname, sizeof(lockname), "/var/lock/nfp_%s", desc->busdev); - desc->lock = open(lockname, O_RDWR | O_CREAT, 0666); - if (desc->lock < 0) - return desc->lock; - - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - rc = -1; - while (rc != 0) { - rc = fcntl(desc->lock, F_SETLKW, &lock); - if (rc < 0) { - if (errno != EAGAIN && errno != EACCES) { - close(desc->lock); - return rc; - } - } - } - - return 0; -} - -static int -nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc) -{ - int rc; - struct flock lock; - const char *lockname = "/.lock_nfp_secondary"; - char *home_path; - char *lockfile; - - memset(&lock, 0, sizeof(lock)); - - /* - * Using user's home directory. Note this can be called in a DPDK app - * being executed as non-root. This is not the case for the previous - * function nfp_acquire_process_lock which is invoked only when UIO - * driver is used because that implies root user. - */ - home_path = getenv("HOME"); - lockfile = calloc(strlen(home_path) + strlen(lockname) + 1, - sizeof(char)); - - if (!lockfile) - return -ENOMEM; - - strcat(lockfile, home_path); - strcat(lockfile, "/.lock_nfp_secondary"); - desc->secondary_lock = open(lockfile, O_RDWR | O_CREAT | O_NONBLOCK, - 0666); - if (desc->secondary_lock < 0) { - RTE_LOG(ERR, PMD, "NFP lock for secondary process failed\n"); - free(lockfile); - return desc->secondary_lock; - } - - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - rc = fcntl(desc->secondary_lock, F_SETLK, &lock); - if (rc < 0) { - RTE_LOG(ERR, PMD, "NFP lock for secondary process failed\n"); - close(desc->secondary_lock); - } - - free(lockfile); - return rc; -} - -static int -nfp6000_set_model(struct rte_pci_device *dev, struct nfp_cpp *cpp) -{ - uint32_t model; - - if (rte_pci_read_config(dev, &model, 4, 0x2e) < 0) { - printf("nfp set model failed\n"); - return -1; - } - - model = model << 16; - nfp_cpp_model_set(cpp, model); - - return 0; -} - -static int -nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp) -{ - uint16_t interface; - - if (rte_pci_read_config(dev, &interface, 2, 0x154) < 0) { - printf("nfp set interface failed\n"); - return -1; - } - - nfp_cpp_interface_set(cpp, interface); - - return 0; -} - -static int -nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp) -{ - uint16_t tmp; - uint8_t serial[6]; - int serial_len = 6; - off_t pos; - - pos = rte_pci_find_ext_capability(dev, RTE_PCI_EXT_CAP_ID_DSN); - if (pos <= 0) { - printf("PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\n"); - return -1; - } else { - pos += 6; - } - - if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) { - printf("nfp set serial failed\n"); - return -1; - } - - serial[4] = (uint8_t)((tmp >> 8) & 0xff); - serial[5] = (uint8_t)(tmp & 0xff); - - pos += 2; - if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) { - printf("nfp set serial failed\n"); - return -1; - } - - serial[2] = (uint8_t)((tmp >> 8) & 0xff); - serial[3] = (uint8_t)(tmp & 0xff); - - pos += 2; - if (rte_pci_read_config(dev, &tmp, 2, pos) < 0) { - printf("nfp set serial failed\n"); - return -1; - } - - serial[0] = (uint8_t)((tmp >> 8) & 0xff); - serial[1] = (uint8_t)(tmp & 0xff); - - nfp_cpp_serial_set(cpp, serial, serial_len); - - return 0; -} - -static int -nfp6000_set_barsz(struct rte_pci_device *dev, struct nfp_pcie_user *desc) -{ - unsigned long tmp; - int i = 0; - - tmp = dev->mem_resource[0].len; - - while (tmp >>= 1) - i++; - - desc->barsz = i; - return 0; -} - -static int -nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev) -{ - int ret = 0; - struct nfp_pcie_user *desc; - - desc = malloc(sizeof(*desc)); - if (!desc) - return -1; - - - memset(desc->busdev, 0, BUSDEV_SZ); - strlcpy(desc->busdev, dev->device.name, sizeof(desc->busdev)); - - if (rte_eal_process_type() == RTE_PROC_PRIMARY && - cpp->driver_lock_needed) { - ret = nfp_acquire_process_lock(desc); - if (ret) - goto error; - } - - /* Just support for one secondary process */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - ret = nfp_acquire_secondary_process_lock(desc); - if (ret) - goto error; - } - - if (nfp6000_set_model(dev, cpp) < 0) - goto error; - if (nfp6000_set_interface(dev, cpp) < 0) - goto error; - if (nfp6000_set_serial(dev, cpp) < 0) - goto error; - if (nfp6000_set_barsz(dev, desc) < 0) - goto error; - - desc->cfg = (char *)dev->mem_resource[0].addr; - desc->dev_id = dev->addr.function & 0x7; - - nfp_enable_bars(desc); - - nfp_cpp_priv_set(cpp, desc); - - return 0; - -error: - free(desc); - return -1; -} - -static void -nfp6000_free(struct nfp_cpp *cpp) -{ - struct nfp_pcie_user *desc = nfp_cpp_priv(cpp); - - nfp_disable_bars(desc); - if (cpp->driver_lock_needed) - close(desc->lock); - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - close(desc->secondary_lock); - close(desc->device); - free(desc); -} - -static const struct nfp_cpp_operations nfp6000_pcie_ops = { - .init = nfp6000_init, - .free = nfp6000_free, - - .area_priv_size = sizeof(struct nfp6000_area_priv), - .area_init = nfp6000_area_init, - .area_acquire = nfp6000_area_acquire, - .area_release = nfp6000_area_release, - .area_mapped = nfp6000_area_mapped, - .area_read = nfp6000_area_read, - .area_write = nfp6000_area_write, - .area_iomem = nfp6000_area_iomem, -}; - -const struct -nfp_cpp_operations *nfp_cpp_transport_operations(void) -{ - return &nfp6000_pcie_ops; -} diff --git a/dpdk/drivers/net/tap/tap_bpf_program.c b/dpdk/drivers/net/tap/tap_bpf_program.c deleted file mode 100644 index d9bb65831..000000000 --- a/dpdk/drivers/net/tap/tap_bpf_program.c +++ /dev/null @@ -1,253 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 - * Copyright 2017 Mellanox Technologies, Ltd - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tap_rss.h" - -/** Create IPv4 address */ -#define IPv4(a, b, c, d) ((__u32)(((a) & 0xff) << 24) | \ - (((b) & 0xff) << 16) | \ - (((c) & 0xff) << 8) | \ - ((d) & 0xff)) - -#define PORT(a, b) ((__u16)(((a) & 0xff) << 8) | \ - ((b) & 0xff)) - -/* - * The queue number is offset by a unique QUEUE_OFFSET, to distinguish - * packets that have gone through this rule (skb->cb[1] != 0) from others. - */ -#define QUEUE_OFFSET 0x7cafe800 -#define PIN_GLOBAL_NS 2 - -#define KEY_IDX 0 -#define BPF_MAP_ID_KEY 1 - -struct vlan_hdr { - __be16 proto; - __be16 tci; -}; - -struct bpf_elf_map __attribute__((section("maps"), used)) -map_keys = { - .type = BPF_MAP_TYPE_HASH, - .id = BPF_MAP_ID_KEY, - .size_key = sizeof(__u32), - .size_value = sizeof(struct rss_key), - .max_elem = 256, - .pinning = PIN_GLOBAL_NS, -}; - -__section("cls_q") int -match_q(struct __sk_buff *skb) -{ - __u32 queue = skb->cb[1]; - volatile __u32 q = 0xdeadbeef; - __u32 match_queue = QUEUE_OFFSET + q; - - /* printt("match_q$i() queue = %d\n", queue); */ - - if (queue != match_queue) - return TC_ACT_OK; - - /* queue match */ - skb->cb[1] = 0; - return TC_ACT_UNSPEC; -} - - -struct ipv4_l3_l4_tuple { - __u32 src_addr; - __u32 dst_addr; - __u16 dport; - __u16 sport; -} __rte_packed; - -struct ipv6_l3_l4_tuple { - __u8 src_addr[16]; - __u8 dst_addr[16]; - __u16 dport; - __u16 sport; -} __rte_packed; - -static const __u8 def_rss_key[TAP_RSS_HASH_KEY_SIZE] = { - 0xd1, 0x81, 0xc6, 0x2c, - 0xf7, 0xf4, 0xdb, 0x5b, - 0x19, 0x83, 0xa2, 0xfc, - 0x94, 0x3e, 0x1a, 0xdb, - 0xd9, 0x38, 0x9e, 0x6b, - 0xd1, 0x03, 0x9c, 0x2c, - 0xa7, 0x44, 0x99, 0xad, - 0x59, 0x3d, 0x56, 0xd9, - 0xf3, 0x25, 0x3c, 0x06, - 0x2a, 0xdc, 0x1f, 0xfc, -}; - -static __u32 __attribute__((always_inline)) -rte_softrss_be(const __u32 *input_tuple, const uint8_t *rss_key, - __u8 input_len) -{ - __u32 i, j, hash = 0; -#pragma unroll - for (j = 0; j < input_len; j++) { -#pragma unroll - for (i = 0; i < 32; i++) { - if (input_tuple[j] & (1U << (31 - i))) { - hash ^= ((const __u32 *)def_rss_key)[j] << i | - (__u32)((uint64_t) - (((const __u32 *)def_rss_key)[j + 1]) - >> (32 - i)); - } - } - } - return hash; -} - -static int __attribute__((always_inline)) -rss_l3_l4(struct __sk_buff *skb) -{ - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; - __u16 proto = (__u16)skb->protocol; - __u32 key_idx = 0xdeadbeef; - __u32 hash; - struct rss_key *rsskey; - __u64 off = ETH_HLEN; - int j; - __u8 *key = 0; - __u32 len; - __u32 queue = 0; - bool mf = 0; - __u16 frag_off = 0; - - rsskey = map_lookup_elem(&map_keys, &key_idx); - if (!rsskey) { - printt("hash(): rss key is not configured\n"); - return TC_ACT_OK; - } - key = (__u8 *)rsskey->key; - - /* Get correct proto for 802.1ad */ - if (skb->vlan_present && skb->vlan_proto == htons(ETH_P_8021AD)) { - if (data + ETH_ALEN * 2 + sizeof(struct vlan_hdr) + - sizeof(proto) > data_end) - return TC_ACT_OK; - proto = *(__u16 *)(data + ETH_ALEN * 2 + - sizeof(struct vlan_hdr)); - off += sizeof(struct vlan_hdr); - } - - if (proto == htons(ETH_P_IP)) { - if (data + off + sizeof(struct iphdr) + sizeof(__u32) - > data_end) - return TC_ACT_OK; - - __u8 *src_dst_addr = data + off + offsetof(struct iphdr, saddr); - __u8 *frag_off_addr = data + off + offsetof(struct iphdr, frag_off); - __u8 *prot_addr = data + off + offsetof(struct iphdr, protocol); - __u8 *src_dst_port = data + off + sizeof(struct iphdr); - struct ipv4_l3_l4_tuple v4_tuple = { - .src_addr = IPv4(*(src_dst_addr + 0), - *(src_dst_addr + 1), - *(src_dst_addr + 2), - *(src_dst_addr + 3)), - .dst_addr = IPv4(*(src_dst_addr + 4), - *(src_dst_addr + 5), - *(src_dst_addr + 6), - *(src_dst_addr + 7)), - .sport = 0, - .dport = 0, - }; - /** Fetch the L4-payer port numbers only in-case of TCP/UDP - ** and also if the packet is not fragmented. Since fragmented - ** chunks do not have L4 TCP/UDP header. - **/ - if (*prot_addr == IPPROTO_UDP || *prot_addr == IPPROTO_TCP) { - frag_off = PORT(*(frag_off_addr + 0), - *(frag_off_addr + 1)); - mf = frag_off & 0x2000; - frag_off = frag_off & 0x1fff; - if (mf == 0 && frag_off == 0) { - v4_tuple.sport = PORT(*(src_dst_port + 0), - *(src_dst_port + 1)); - v4_tuple.dport = PORT(*(src_dst_port + 2), - *(src_dst_port + 3)); - } - } - __u8 input_len = sizeof(v4_tuple) / sizeof(__u32); - if (rsskey->hash_fields & (1 << HASH_FIELD_IPV4_L3)) - input_len--; - hash = rte_softrss_be((__u32 *)&v4_tuple, key, 3); - } else if (proto == htons(ETH_P_IPV6)) { - if (data + off + sizeof(struct ipv6hdr) + - sizeof(__u32) > data_end) - return TC_ACT_OK; - __u8 *src_dst_addr = data + off + - offsetof(struct ipv6hdr, saddr); - __u8 *src_dst_port = data + off + - sizeof(struct ipv6hdr); - __u8 *next_hdr = data + off + - offsetof(struct ipv6hdr, nexthdr); - - struct ipv6_l3_l4_tuple v6_tuple; - for (j = 0; j < 4; j++) - *((uint32_t *)&v6_tuple.src_addr + j) = - __builtin_bswap32(*((uint32_t *) - src_dst_addr + j)); - for (j = 0; j < 4; j++) - *((uint32_t *)&v6_tuple.dst_addr + j) = - __builtin_bswap32(*((uint32_t *) - src_dst_addr + 4 + j)); - - /** Fetch the L4 header port-numbers only if next-header - * is TCP/UDP **/ - if (*next_hdr == IPPROTO_UDP || *next_hdr == IPPROTO_TCP) { - v6_tuple.sport = PORT(*(src_dst_port + 0), - *(src_dst_port + 1)); - v6_tuple.dport = PORT(*(src_dst_port + 2), - *(src_dst_port + 3)); - } else { - v6_tuple.sport = 0; - v6_tuple.dport = 0; - } - - __u8 input_len = sizeof(v6_tuple) / sizeof(__u32); - if (rsskey->hash_fields & (1 << HASH_FIELD_IPV6_L3)) - input_len--; - hash = rte_softrss_be((__u32 *)&v6_tuple, key, 9); - } else { - return TC_ACT_PIPE; - } - - queue = rsskey->queues[(hash % rsskey->nb_queues) & - (TAP_MAX_QUEUES - 1)]; - skb->cb[1] = QUEUE_OFFSET + queue; - /* printt(">>>>> rss_l3_l4 hash=0x%x queue=%u\n", hash, queue); */ - - return TC_ACT_RECLASSIFY; -} - -#define RSS(L) \ - __section(#L) int \ - L ## _hash(struct __sk_buff *skb) \ - { \ - return rss_ ## L (skb); \ - } - -RSS(l3_l4) - -BPF_LICENSE("Dual BSD/GPL"); diff --git a/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.c b/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.c deleted file mode 100644 index 60f1c1b4c..000000000 --- a/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.c +++ /dev/null @@ -1,228 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (C) 2020 Marvell International Ltd. - */ - -#include -#include - -#include "cn9k_regexdev.h" -#include "cn9k_regexdev_compiler.h" - -#ifdef REE_COMPILER_SDK -#include - -static int -ree_rule_db_compile(const struct rte_regexdev_rule *rules, - uint16_t nb_rules, struct rxp_rof **rof, struct rxp_rof **rofi, - struct rxp_rof *rof_for_incremental_compile, - struct rxp_rof *rofi_for_incremental_compile) -{ - /*INPUT*/ - struct rxp_prefix_selection_control_list *prefix_selection_control_list - = NULL; - struct rxp_blacklist_data_sample *blacklist_sample_data = NULL; - struct rxp_rule_ids_to_remove *rule_ids_to_remove = NULL; - struct rxp_roff *roff_for_incremental_compile = NULL; - - /*OPTIONS - setting default values*/ - enum rxp_virtual_prefix_mode virtual_prefix_mode = - RXP_VIRTUAL_PREFIX_MODE_0; - enum rxp_prefix_capacity prefix_capacity = RXP_PREFIX_CAPACITY_32K; - /**< rxp_global_regex_options_flags*/ - enum rxp_compiler_objective objective = RXP_COMPILER_OBJECTIVE_5; - enum rxp_tpe_data_width tpe_data_width = RXP_TPE_DATA_WIDTH_4; - uint32_t compiler_options = RXP_COMPILER_OPTIONS_FORCE; - /**< rxp_compiler_options_flags*/ - enum rxp_verbose_level verbose = RXP_VERBOSE_LEVEL_3; - enum rxp_version set_rxp_version = RXP_VERSION_V5_8; - uint32_t compiler_output_flags = 0; - /**< rxp_compiler_output_flags*/ - uint32_t global_regex_options = 0; - /**< rxp_global_regex_options_flags*/ - float set_auto_blacklist = 0; - uint32_t max_rep_max = 65535; - uint32_t divide_ruleset = 1; - struct rxp_ruleset ruleset; - float ptpb_threshold = 0; - uint32_t set_max = 0; - uint32_t threads = 1; - - /*OUTPUT*/ - struct rxp_rule_direction_analysis *rule_direction_analysis = NULL; - struct rxp_compilation_statistics *compilation_statistics = NULL; - struct rxp_prefix_selection_control_list *generated_pscl = NULL; - struct rxp_uncompiled_rules_log *uncompiled_rules_log = NULL; - struct rxp_critical_rules_rank *critical_rules_rank = NULL; - struct rxp_compiled_rules_log *compiled_rules_log = NULL; - struct rxp_roff *roff = NULL; - - uint16_t i; - int ret; - - ruleset.number_of_entries = nb_rules; - ruleset.rules = rte_malloc("rxp_rule_entry", - nb_rules*sizeof(struct rxp_rule_entry), 0); - - if (ruleset.rules == NULL) { - cn9k_err("Could not allocate memory for rule compilation\n"); - return -EFAULT; - } - if (rof_for_incremental_compile) - compiler_options |= RXP_COMPILER_OPTIONS_INCREMENTAL; - if (rofi_for_incremental_compile) - compiler_options |= RXP_COMPILER_OPTIONS_CHECKSUM; - - for (i = 0; i < nb_rules; i++) { - ruleset.rules[i].number_of_prefix_entries = 0; - ruleset.rules[i].prefix = NULL; - ruleset.rules[i].rule = rules[i].pcre_rule; - ruleset.rules[i].rule_id = rules[i].rule_id; - ruleset.rules[i].subset_id = rules[i].group_id; - ruleset.rules[i].rule_direction_type = - RXP_RULE_DIRECTION_TYPE_NONE; - } - - ret = rxp_compile_advanced( - /*INPUT*/ - &ruleset, - prefix_selection_control_list, - rof_for_incremental_compile, - roff_for_incremental_compile, - rofi_for_incremental_compile, - rule_ids_to_remove, - blacklist_sample_data, - - /*OPTIONS*/ - compiler_options, - prefix_capacity, - global_regex_options, - set_auto_blacklist, - set_max, - objective, - ptpb_threshold, - max_rep_max, - threads, - set_rxp_version, - verbose, - tpe_data_width, - virtual_prefix_mode, - compiler_output_flags, - divide_ruleset, - - /*OUTPUT*/ - &compilation_statistics, - &compiled_rules_log, - &critical_rules_rank, - &rule_direction_analysis, - &uncompiled_rules_log, - rof, - &roff, - rofi, - &generated_pscl); - rte_free(ruleset.rules); - - return ret; -} - -int -cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev) -{ - struct cn9k_ree_data *data = dev->data->dev_private; - struct roc_ree_vf *vf = &data->vf; - char compiler_version[] = "20.5.2.eda0fa2"; - char timestamp[] = "19700101_000001"; - uint32_t rule_db_len, rule_dbi_len; - struct rxp_rof *rofi_inc_p = NULL; - struct rxp_rof_entry rule_dbi[6]; - char *rofi_rof_entries = NULL; - struct rxp_rof *rofi = NULL; - struct rxp_rof *rof = NULL; - struct rxp_rof rofi_inc; - struct rxp_rof rof_inc; - char *rule_db = NULL; - int ret; - - ree_func_trace(); - - ret = roc_ree_rule_db_len_get(vf, &rule_db_len, &rule_dbi_len); - if (ret != 0) { - cn9k_err("Could not get rule db length"); - return ret; - } - - if (rule_db_len > 0) { - cn9k_ree_dbg("Incremental compile, rule db len %d rule dbi len %d", - rule_db_len, rule_dbi_len); - rule_db = rte_malloc("ree_rule_db", rule_db_len, 0); - if (!rule_db) { - cn9k_err("Could not allocate memory for rule db"); - return -EFAULT; - } - - ret = roc_ree_rule_db_get(vf, rule_db, rule_db_len, - (char *)rule_dbi, rule_dbi_len); - if (ret) { - cn9k_err("Could not read rule db"); - rte_free(rule_db); - return -EFAULT; - } - rof_inc.rof_revision = 0; - rof_inc.rof_version = 2; - rof_inc.rof_entries = (struct rxp_rof_entry *)rule_db; - rof_inc.rxp_compiler_version = compiler_version; - rof_inc.timestamp = timestamp; - rof_inc.number_of_entries = - (rule_db_len/sizeof(struct rxp_rof_entry)); - - if (rule_dbi_len > 0) { - /* incremental compilation not the first time */ - rofi_inc.rof_revision = 0; - rofi_inc.rof_version = 2; - rofi_inc.rof_entries = rule_dbi; - rofi_inc.rxp_compiler_version = compiler_version; - rofi_inc.timestamp = timestamp; - rofi_inc.number_of_entries = - (rule_dbi_len/sizeof(struct rxp_rof_entry)); - rofi_inc_p = &rofi_inc; - } - ret = ree_rule_db_compile(data->rules, data->nb_rules, &rof, - &rofi, &rof_inc, rofi_inc_p); - if (rofi->number_of_entries == 0) { - cn9k_ree_dbg("No change to rule db"); - ret = 0; - goto free_structs; - } - rule_dbi_len = rofi->number_of_entries * - sizeof(struct rxp_rof_entry); - rofi_rof_entries = (char *)rofi->rof_entries; - } else { - /* full compilation */ - ret = ree_rule_db_compile(data->rules, data->nb_rules, &rof, - &rofi, NULL, NULL); - } - if (ret != 0) { - cn9k_err("Could not compile rule db"); - goto free_structs; - } - rule_db_len = rof->number_of_entries * sizeof(struct rxp_rof_entry); - ret = roc_ree_rule_db_prog(vf, (char *)rof->rof_entries, rule_db_len, - rofi_rof_entries, rule_dbi_len); - if (ret) - cn9k_err("Could not program rule db"); - -free_structs: - rxp_free_structs(NULL, NULL, NULL, NULL, NULL, &rof, NULL, &rofi, NULL, - 1); - - rte_free(rule_db); - - return ret; -} -#else -int -cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev) -{ - RTE_SET_USED(dev); - return -ENOTSUP; -} -#endif diff --git a/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.h b/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.h deleted file mode 100644 index 4c29a69ad..000000000 --- a/dpdk/drivers/regex/cn9k/cn9k_regexdev_compiler.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (C) 2020 Marvell International Ltd. - */ - -#ifndef _CN9K_REGEXDEV_COMPILER_H_ -#define _CN9K_REGEXDEV_COMPILER_H_ - -int -cn9k_ree_rule_db_compile_prog(struct rte_regexdev *dev); - -#endif /* _CN9K_REGEXDEV_COMPILER_H_ */ diff --git a/dpdk/dts/framework/remote_session/remote_session.py b/dpdk/dts/framework/remote_session/remote_session.py deleted file mode 100644 index 33047d9d0..000000000 --- a/dpdk/dts/framework/remote_session/remote_session.py +++ /dev/null @@ -1,95 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation -# Copyright(c) 2022 PANTHEON.tech s.r.o. -# Copyright(c) 2022 University of New Hampshire - -import dataclasses -from abc import ABC, abstractmethod - -from framework.config import NodeConfiguration -from framework.logger import DTSLOG -from framework.settings import SETTINGS - - -@dataclasses.dataclass(slots=True, frozen=True) -class HistoryRecord: - name: str - command: str - output: str | int - - -class RemoteSession(ABC): - name: str - hostname: str - ip: str - port: int | None - username: str - password: str - logger: DTSLOG - history: list[HistoryRecord] - _node_config: NodeConfiguration - - def __init__( - self, - node_config: NodeConfiguration, - session_name: str, - logger: DTSLOG, - ): - self._node_config = node_config - - self.name = session_name - self.hostname = node_config.hostname - self.ip = self.hostname - self.port = None - if ":" in self.hostname: - self.ip, port = self.hostname.split(":") - self.port = int(port) - self.username = node_config.user - self.password = node_config.password or "" - self.logger = logger - self.history = [] - - self.logger.info(f"Connecting to {self.username}@{self.hostname}.") - self._connect() - self.logger.info(f"Connection to {self.username}@{self.hostname} successful.") - - @abstractmethod - def _connect(self) -> None: - """ - Create connection to assigned node. - """ - pass - - def send_command(self, command: str, timeout: float = SETTINGS.timeout) -> str: - self.logger.info(f"Sending: {command}") - out = self._send_command(command, timeout) - self.logger.debug(f"Received from {command}: {out}") - self._history_add(command=command, output=out) - return out - - @abstractmethod - def _send_command(self, command: str, timeout: float) -> str: - """ - Send a command and return the output. - """ - - def _history_add(self, command: str, output: str) -> None: - self.history.append( - HistoryRecord(name=self.name, command=command, output=output) - ) - - def close(self, force: bool = False) -> None: - self.logger.logger_exit() - self._close(force) - - @abstractmethod - def _close(self, force: bool = False) -> None: - """ - Close the remote session, freeing all used resources. - """ - - @abstractmethod - def is_alive(self) -> bool: - """ - Check whether the session is still responding. - """ diff --git a/dpdk/dts/framework/remote_session/ssh_session.py b/dpdk/dts/framework/remote_session/ssh_session.py deleted file mode 100644 index 7ec327054..000000000 --- a/dpdk/dts/framework/remote_session/ssh_session.py +++ /dev/null @@ -1,184 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation -# Copyright(c) 2022 PANTHEON.tech s.r.o. -# Copyright(c) 2022 University of New Hampshire - -import time - -from pexpect import pxssh # type: ignore - -from framework.config import NodeConfiguration -from framework.exception import SSHConnectionError, SSHSessionDeadError, SSHTimeoutError -from framework.logger import DTSLOG -from framework.utils import GREEN, RED - -from .remote_session import RemoteSession - - -class SSHSession(RemoteSession): - """ - Module for creating Pexpect SSH sessions to a node. - """ - - session: pxssh.pxssh - magic_prompt: str - - def __init__( - self, - node_config: NodeConfiguration, - session_name: str, - logger: DTSLOG, - ): - self.magic_prompt = "MAGIC PROMPT" - super(SSHSession, self).__init__(node_config, session_name, logger) - - def _connect(self) -> None: - """ - Create connection to assigned node. - """ - retry_attempts = 10 - login_timeout = 20 if self.port else 10 - password_regex = ( - r"(?i)(?:password:)|(?:passphrase for key)|(?i)(password for .+:)" - ) - try: - for retry_attempt in range(retry_attempts): - self.session = pxssh.pxssh(encoding="utf-8") - try: - self.session.login( - self.ip, - self.username, - self.password, - original_prompt="[$#>]", - port=self.port, - login_timeout=login_timeout, - password_regex=password_regex, - ) - break - except Exception as e: - self.logger.warning(e) - time.sleep(2) - self.logger.info( - f"Retrying connection: retry number {retry_attempt + 1}." - ) - else: - raise Exception(f"Connection to {self.hostname} failed") - - self.send_expect("stty -echo", "#") - self.send_expect("stty columns 1000", "#") - except Exception as e: - self.logger.error(RED(str(e))) - if getattr(self, "port", None): - suggestion = ( - f"\nSuggestion: Check if the firewall on {self.hostname} is " - f"stopped.\n" - ) - self.logger.info(GREEN(suggestion)) - - raise SSHConnectionError(self.hostname) - - def send_expect( - self, command: str, prompt: str, timeout: float = 15, verify: bool = False - ) -> str | int: - try: - ret = self.send_expect_base(command, prompt, timeout) - if verify: - ret_status = self.send_expect_base("echo $?", prompt, timeout) - try: - retval = int(ret_status) - if retval: - self.logger.error(f"Command: {command} failure!") - self.logger.error(ret) - return retval - else: - return ret - except ValueError: - return ret - else: - return ret - except Exception as e: - self.logger.error( - f"Exception happened in [{command}] and output is " - f"[{self._get_output()}]" - ) - raise e - - def send_expect_base(self, command: str, prompt: str, timeout: float) -> str: - self._clean_session() - original_prompt = self.session.PROMPT - self.session.PROMPT = prompt - self._send_line(command) - self._prompt(command, timeout) - - before = self._get_output() - self.session.PROMPT = original_prompt - return before - - def _clean_session(self) -> None: - self.session.PROMPT = self.magic_prompt - self.get_output(timeout=0.01) - self.session.PROMPT = self.session.UNIQUE_PROMPT - - def _send_line(self, command: str) -> None: - if not self.is_alive(): - raise SSHSessionDeadError(self.hostname) - if len(command) == 2 and command.startswith("^"): - self.session.sendcontrol(command[1]) - else: - self.session.sendline(command) - - def _prompt(self, command: str, timeout: float) -> None: - if not self.session.prompt(timeout): - raise SSHTimeoutError(command, self._get_output()) from None - - def get_output(self, timeout: float = 15) -> str: - """ - Get all output before timeout - """ - try: - self.session.prompt(timeout) - except Exception: - pass - - before = self._get_output() - self._flush() - - return before - - def _get_output(self) -> str: - if not self.is_alive(): - raise SSHSessionDeadError(self.hostname) - before = self.session.before.rsplit("\r\n", 1)[0] - if before == "[PEXPECT]": - return "" - return before - - def _flush(self) -> None: - """ - Clear all session buffer - """ - self.session.buffer = "" - self.session.before = "" - - def is_alive(self) -> bool: - return self.session.isalive() - - def _send_command(self, command: str, timeout: float) -> str: - try: - self._clean_session() - self._send_line(command) - except Exception as e: - raise e - - output = self.get_output(timeout=timeout) - self.session.PROMPT = self.session.UNIQUE_PROMPT - self.session.prompt(0.1) - - return output - - def _close(self, force: bool = False) -> None: - if force is True: - self.session.close() - else: - if self.is_alive(): - self.session.logout() diff --git a/dpdk/examples/bond/main.h b/dpdk/examples/bond/main.h deleted file mode 100644 index f91ed9c88..000000000 --- a/dpdk/examples/bond/main.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2015 Intel Corporation - */ - -#ifndef _MAIN_H_ -#define _MAIN_H_ - -int main(int argc, char *argv[]); - -#endif /* ifndef _MAIN_H_ */ diff --git a/dpdk/examples/flow_classify/Makefile b/dpdk/examples/flow_classify/Makefile deleted file mode 100644 index 539bf9682..000000000 --- a/dpdk/examples/flow_classify/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -# binary name -APP = flow_classify - -# all source are stored in SRCS-y -SRCS-y := flow_classify.c - -PKGCONF ?= pkg-config - -# Build using pkg-config variables if possible -ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) -$(error "no installation of DPDK found") -endif - -all: shared -.PHONY: shared static -shared: build/$(APP)-shared - ln -sf $(APP)-shared build/$(APP) -static: build/$(APP)-static - ln -sf $(APP)-static build/$(APP) - -PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) -CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) - -ifeq ($(MAKECMDGOALS),static) -# check for broken pkg-config -ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) -$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") -$(error "Cannot generate statically-linked binaries with this version of pkg-config") -endif -endif - -CFLAGS += -DALLOW_EXPERIMENTAL_API - -build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) - -build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) - -build: - @mkdir -p $@ - -.PHONY: clean -clean: - rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared - test -d build && rmdir -p build || true diff --git a/dpdk/examples/flow_classify/flow_classify.c b/dpdk/examples/flow_classify/flow_classify.c deleted file mode 100644 index cdd51b247..000000000 --- a/dpdk/examples/flow_classify/flow_classify.c +++ /dev/null @@ -1,878 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define RX_RING_SIZE 1024 -#define TX_RING_SIZE 1024 - -#define NUM_MBUFS 8191 -#define MBUF_CACHE_SIZE 250 -#define BURST_SIZE 32 - -#define MAX_NUM_CLASSIFY 30 -#define FLOW_CLASSIFY_MAX_RULE_NUM 91 -#define FLOW_CLASSIFY_MAX_PRIORITY 8 -#define FLOW_CLASSIFIER_NAME_SIZE 64 - -#define COMMENT_LEAD_CHAR ('#') -#define OPTION_RULE_IPV4 "rule_ipv4" -#define RTE_LOGTYPE_FLOW_CLASSIFY RTE_LOGTYPE_USER3 -#define flow_classify_log(format, ...) \ - RTE_LOG(ERR, FLOW_CLASSIFY, format, ##__VA_ARGS__) - -#define uint32_t_to_char(ip, a, b, c, d) do {\ - *a = (unsigned char)(ip >> 24 & 0xff);\ - *b = (unsigned char)(ip >> 16 & 0xff);\ - *c = (unsigned char)(ip >> 8 & 0xff);\ - *d = (unsigned char)(ip & 0xff);\ - } while (0) - -enum { - CB_FLD_SRC_ADDR, - CB_FLD_DST_ADDR, - CB_FLD_SRC_PORT, - CB_FLD_SRC_PORT_DLM, - CB_FLD_SRC_PORT_MASK, - CB_FLD_DST_PORT, - CB_FLD_DST_PORT_DLM, - CB_FLD_DST_PORT_MASK, - CB_FLD_PROTO, - CB_FLD_PRIORITY, - CB_FLD_NUM, -}; - -static struct{ - const char *rule_ipv4_name; -} parm_config; -const char cb_port_delim[] = ":"; - -/* Creation of flow classifier object. 8< */ -struct flow_classifier { - struct rte_flow_classifier *cls; -}; - -struct flow_classifier_acl { - struct flow_classifier cls; -} __rte_cache_aligned; -/* >8 End of creation of flow classifier object. */ - -/* Creation of ACL table during initialization of application. 8< */ - -/* ACL field definitions for IPv4 5 tuple rule */ -enum { - PROTO_FIELD_IPV4, - SRC_FIELD_IPV4, - DST_FIELD_IPV4, - SRCP_FIELD_IPV4, - DSTP_FIELD_IPV4, - NUM_FIELDS_IPV4 -}; - -enum { - PROTO_INPUT_IPV4, - SRC_INPUT_IPV4, - DST_INPUT_IPV4, - SRCP_DESTP_INPUT_IPV4 -}; - -static struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = { - /* first input field - always one byte long. */ - { - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint8_t), - .field_index = PROTO_FIELD_IPV4, - .input_index = PROTO_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, next_proto_id), - }, - /* next input field (IPv4 source address) - 4 consecutive bytes. */ - { - /* rte_flow uses a bit mask for IPv4 addresses */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint32_t), - .field_index = SRC_FIELD_IPV4, - .input_index = SRC_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, src_addr), - }, - /* next input field (IPv4 destination address) - 4 consecutive bytes. */ - { - /* rte_flow uses a bit mask for IPv4 addresses */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint32_t), - .field_index = DST_FIELD_IPV4, - .input_index = DST_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - offsetof(struct rte_ipv4_hdr, dst_addr), - }, - /* - * Next 2 fields (src & dst ports) form 4 consecutive bytes. - * They share the same input index. - */ - { - /* rte_flow uses a bit mask for protocol ports */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint16_t), - .field_index = SRCP_FIELD_IPV4, - .input_index = SRCP_DESTP_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - sizeof(struct rte_ipv4_hdr) + - offsetof(struct rte_tcp_hdr, src_port), - }, - { - /* rte_flow uses a bit mask for protocol ports */ - .type = RTE_ACL_FIELD_TYPE_BITMASK, - .size = sizeof(uint16_t), - .field_index = DSTP_FIELD_IPV4, - .input_index = SRCP_DESTP_INPUT_IPV4, - .offset = sizeof(struct rte_ether_hdr) + - sizeof(struct rte_ipv4_hdr) + - offsetof(struct rte_tcp_hdr, dst_port), - }, -}; -/* >8 End of creation of ACL table. */ - -/* Flow classify data. 8< */ -static int num_classify_rules; -static struct rte_flow_classify_rule *rules[MAX_NUM_CLASSIFY]; -static struct rte_flow_classify_ipv4_5tuple_stats ntuple_stats; -static struct rte_flow_classify_stats classify_stats = { - .stats = (void **)&ntuple_stats -}; -/* >8 End of flow classify data. */ - -/* parameters for rte_flow_classify_validate and - * rte_flow_classify_table_entry_add functions - */ - -static struct rte_flow_item eth_item = { RTE_FLOW_ITEM_TYPE_ETH, - 0, 0, 0 }; -static struct rte_flow_item end_item = { RTE_FLOW_ITEM_TYPE_END, - 0, 0, 0 }; - -/* sample actions: - * "actions count / end" - */ -struct rte_flow_query_count count = { - .reset = 1, - .hits_set = 1, - .bytes_set = 1, - .hits = 0, - .bytes = 0, -}; -static struct rte_flow_action count_action = { RTE_FLOW_ACTION_TYPE_COUNT, - &count}; -static struct rte_flow_action end_action = { RTE_FLOW_ACTION_TYPE_END, 0}; -static struct rte_flow_action actions[2]; - -/* sample attributes */ -static struct rte_flow_attr attr; - -/* flow_classify.c: * Based on DPDK skeleton forwarding example. */ - -/* - * Initializes a given port using global settings and with the RX buffers - * coming from the mbuf_pool passed as a parameter. - */ - -/* Initializing port using global settings. 8< */ -static inline int -port_init(uint8_t port, struct rte_mempool *mbuf_pool) -{ - struct rte_eth_conf port_conf; - struct rte_ether_addr addr; - const uint16_t rx_rings = 1, tx_rings = 1; - int retval; - uint16_t q; - struct rte_eth_dev_info dev_info; - struct rte_eth_txconf txconf; - - if (!rte_eth_dev_is_valid_port(port)) - return -1; - - memset(&port_conf, 0, sizeof(struct rte_eth_conf)); - - retval = rte_eth_dev_info_get(port, &dev_info); - if (retval != 0) { - printf("Error during getting device (port %u) info: %s\n", - port, strerror(-retval)); - return retval; - } - - if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) - port_conf.txmode.offloads |= - RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; - - /* Configure the Ethernet device. */ - retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf); - if (retval != 0) - return retval; - - /* Allocate and set up 1 RX queue per Ethernet port. */ - for (q = 0; q < rx_rings; q++) { - retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE, - rte_eth_dev_socket_id(port), NULL, mbuf_pool); - if (retval < 0) - return retval; - } - - txconf = dev_info.default_txconf; - txconf.offloads = port_conf.txmode.offloads; - /* Allocate and set up 1 TX queue per Ethernet port. */ - for (q = 0; q < tx_rings; q++) { - retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE, - rte_eth_dev_socket_id(port), &txconf); - if (retval < 0) - return retval; - } - - /* Start the Ethernet port. 8< */ - retval = rte_eth_dev_start(port); - /* >8 End of starting the Ethernet port. */ - if (retval < 0) - return retval; - - /* Display the port MAC address. */ - retval = rte_eth_macaddr_get(port, &addr); - if (retval != 0) - return retval; - - printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8 - " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n", - port, RTE_ETHER_ADDR_BYTES(&addr)); - - /* Enable RX in promiscuous mode for the Ethernet device. */ - retval = rte_eth_promiscuous_enable(port); - if (retval != 0) - return retval; - - return 0; -} -/* >8 End of initializing a given port. */ - -/* - * The lcore main. This is the main thread that does the work, reading from - * an input port classifying the packets and writing to an output port. - */ - -/* Classifying the packets. 8< */ -static __rte_noreturn void -lcore_main(struct flow_classifier *cls_app) -{ - uint16_t port; - int ret; - int i = 0; - - ret = rte_flow_classify_table_entry_delete(cls_app->cls, - rules[7]); - if (ret) - printf("table_entry_delete failed [7] %d\n\n", ret); - else - printf("table_entry_delete succeeded [7]\n\n"); - - /* - * Check that the port is on the same NUMA node as the polling thread - * for best performance. - */ - RTE_ETH_FOREACH_DEV(port) - if (rte_eth_dev_socket_id(port) >= 0 && - rte_eth_dev_socket_id(port) != (int)rte_socket_id()) { - printf("\n\n"); - printf("WARNING: port %u is on remote NUMA node\n", - port); - printf("to polling thread.\n"); - printf("Performance will not be optimal.\n"); - } - printf("\nCore %u forwarding packets. ", rte_lcore_id()); - printf("[Ctrl+C to quit]\n"); - - /* Run until the application is quit or killed. 8< */ - for (;;) { - /* - * Receive packets on a port, classify them and forward them - * on the paired port. - * The mapping is 0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2, etc. - */ - RTE_ETH_FOREACH_DEV(port) { - /* Get burst of RX packets, from first port of pair. */ - struct rte_mbuf *bufs[BURST_SIZE]; - const uint16_t nb_rx = rte_eth_rx_burst(port, 0, - bufs, BURST_SIZE); - - if (unlikely(nb_rx == 0)) - continue; - - for (i = 0; i < MAX_NUM_CLASSIFY; i++) { - if (rules[i]) { - ret = rte_flow_classifier_query( - cls_app->cls, - bufs, nb_rx, rules[i], - &classify_stats); - if (ret) - printf( - "rule [%d] query failed ret [%d]\n\n", - i, ret); - else { - printf( - "rule[%d] count=%"PRIu64"\n", - i, ntuple_stats.counter1); - - printf("proto = %d\n", - ntuple_stats.ipv4_5tuple.proto); - } - } - } - - /* Send burst of TX packets, to second port of pair. */ - const uint16_t nb_tx = rte_eth_tx_burst(port ^ 1, 0, - bufs, nb_rx); - - /* Free any unsent packets. */ - if (unlikely(nb_tx < nb_rx)) { - uint16_t buf; - - for (buf = nb_tx; buf < nb_rx; buf++) - rte_pktmbuf_free(bufs[buf]); - } - } - } - /* >8 End of main loop. */ -} -/* >8 End of lcore main. */ - -/* - * Parse IPv4 5 tuple rules file, ipv4_rules_file.txt. - * Expected format: - * '/' \ - * '/' \ - * ":" \ - * ":" \ - * '/' \ - * - */ - -static int -get_cb_field(char **in, uint32_t *fd, int base, unsigned long lim, - char dlm) -{ - unsigned long val; - char *end; - - errno = 0; - val = strtoul(*in, &end, base); - if (errno != 0 || end[0] != dlm || val > lim) - return -EINVAL; - *fd = (uint32_t)val; - *in = end + 1; - return 0; -} - -static int -parse_ipv4_net(char *in, uint32_t *addr, uint32_t *mask_len) -{ - uint32_t a, b, c, d, m; - - if (get_cb_field(&in, &a, 0, UINT8_MAX, '.')) - return -EINVAL; - if (get_cb_field(&in, &b, 0, UINT8_MAX, '.')) - return -EINVAL; - if (get_cb_field(&in, &c, 0, UINT8_MAX, '.')) - return -EINVAL; - if (get_cb_field(&in, &d, 0, UINT8_MAX, '/')) - return -EINVAL; - if (get_cb_field(&in, &m, 0, sizeof(uint32_t) * CHAR_BIT, 0)) - return -EINVAL; - - addr[0] = RTE_IPV4(a, b, c, d); - mask_len[0] = m; - return 0; -} - -static int -parse_ipv4_5tuple_rule(char *str, struct rte_eth_ntuple_filter *ntuple_filter) -{ - int i, ret; - char *s, *sp, *in[CB_FLD_NUM]; - static const char *dlm = " \t\n"; - int dim = CB_FLD_NUM; - uint32_t temp; - - s = str; - for (i = 0; i != dim; i++, s = NULL) { - in[i] = strtok_r(s, dlm, &sp); - if (in[i] == NULL) - return -EINVAL; - } - - ret = parse_ipv4_net(in[CB_FLD_SRC_ADDR], - &ntuple_filter->src_ip, - &ntuple_filter->src_ip_mask); - if (ret != 0) { - flow_classify_log("failed to read source address/mask: %s\n", - in[CB_FLD_SRC_ADDR]); - return ret; - } - - ret = parse_ipv4_net(in[CB_FLD_DST_ADDR], - &ntuple_filter->dst_ip, - &ntuple_filter->dst_ip_mask); - if (ret != 0) { - flow_classify_log("failed to read destination address/mask: %s\n", - in[CB_FLD_DST_ADDR]); - return ret; - } - - if (get_cb_field(&in[CB_FLD_SRC_PORT], &temp, 0, UINT16_MAX, 0)) - return -EINVAL; - ntuple_filter->src_port = (uint16_t)temp; - - if (strncmp(in[CB_FLD_SRC_PORT_DLM], cb_port_delim, - sizeof(cb_port_delim)) != 0) - return -EINVAL; - - if (get_cb_field(&in[CB_FLD_SRC_PORT_MASK], &temp, 0, UINT16_MAX, 0)) - return -EINVAL; - ntuple_filter->src_port_mask = (uint16_t)temp; - - if (get_cb_field(&in[CB_FLD_DST_PORT], &temp, 0, UINT16_MAX, 0)) - return -EINVAL; - ntuple_filter->dst_port = (uint16_t)temp; - - if (strncmp(in[CB_FLD_DST_PORT_DLM], cb_port_delim, - sizeof(cb_port_delim)) != 0) - return -EINVAL; - - if (get_cb_field(&in[CB_FLD_DST_PORT_MASK], &temp, 0, UINT16_MAX, 0)) - return -EINVAL; - ntuple_filter->dst_port_mask = (uint16_t)temp; - - if (get_cb_field(&in[CB_FLD_PROTO], &temp, 0, UINT8_MAX, '/')) - return -EINVAL; - ntuple_filter->proto = (uint8_t)temp; - - if (get_cb_field(&in[CB_FLD_PROTO], &temp, 0, UINT8_MAX, 0)) - return -EINVAL; - ntuple_filter->proto_mask = (uint8_t)temp; - - if (get_cb_field(&in[CB_FLD_PRIORITY], &temp, 0, UINT16_MAX, 0)) - return -EINVAL; - ntuple_filter->priority = (uint16_t)temp; - if (ntuple_filter->priority > FLOW_CLASSIFY_MAX_PRIORITY) - ret = -EINVAL; - - return ret; -} - -/* Bypass comment and empty lines */ -static inline int -is_bypass_line(char *buff) -{ - int i = 0; - - /* comment line */ - if (buff[0] == COMMENT_LEAD_CHAR) - return 1; - /* empty line */ - while (buff[i] != '\0') { - if (!isspace(buff[i])) - return 0; - i++; - } - return 1; -} - -static uint32_t -convert_depth_to_bitmask(uint32_t depth_val) -{ - uint32_t bitmask = 0; - int i, j; - - for (i = depth_val, j = 0; i > 0; i--, j++) - bitmask |= (1 << (31 - j)); - return bitmask; -} - -static int -add_classify_rule(struct rte_eth_ntuple_filter *ntuple_filter, - struct flow_classifier *cls_app) -{ - int ret = -1; - int key_found; - struct rte_flow_error error; - struct rte_flow_item_ipv4 ipv4_spec; - struct rte_flow_item_ipv4 ipv4_mask; - struct rte_flow_item ipv4_udp_item; - struct rte_flow_item ipv4_tcp_item; - struct rte_flow_item ipv4_sctp_item; - struct rte_flow_item_udp udp_spec; - struct rte_flow_item_udp udp_mask; - struct rte_flow_item udp_item; - struct rte_flow_item_tcp tcp_spec; - struct rte_flow_item_tcp tcp_mask; - struct rte_flow_item tcp_item; - struct rte_flow_item_sctp sctp_spec; - struct rte_flow_item_sctp sctp_mask; - struct rte_flow_item sctp_item; - struct rte_flow_item pattern_ipv4_5tuple[4]; - struct rte_flow_classify_rule *rule; - uint8_t ipv4_proto; - - if (num_classify_rules >= MAX_NUM_CLASSIFY) { - printf( - "\nINFO: classify rule capacity %d reached\n", - num_classify_rules); - return ret; - } - - /* set up parameters for validate and add */ - memset(&ipv4_spec, 0, sizeof(ipv4_spec)); - ipv4_spec.hdr.next_proto_id = ntuple_filter->proto; - ipv4_spec.hdr.src_addr = ntuple_filter->src_ip; - ipv4_spec.hdr.dst_addr = ntuple_filter->dst_ip; - ipv4_proto = ipv4_spec.hdr.next_proto_id; - - memset(&ipv4_mask, 0, sizeof(ipv4_mask)); - ipv4_mask.hdr.next_proto_id = ntuple_filter->proto_mask; - ipv4_mask.hdr.src_addr = ntuple_filter->src_ip_mask; - ipv4_mask.hdr.src_addr = - convert_depth_to_bitmask(ipv4_mask.hdr.src_addr); - ipv4_mask.hdr.dst_addr = ntuple_filter->dst_ip_mask; - ipv4_mask.hdr.dst_addr = - convert_depth_to_bitmask(ipv4_mask.hdr.dst_addr); - - switch (ipv4_proto) { - case IPPROTO_UDP: - ipv4_udp_item.type = RTE_FLOW_ITEM_TYPE_IPV4; - ipv4_udp_item.spec = &ipv4_spec; - ipv4_udp_item.mask = &ipv4_mask; - ipv4_udp_item.last = NULL; - - udp_spec.hdr.src_port = ntuple_filter->src_port; - udp_spec.hdr.dst_port = ntuple_filter->dst_port; - udp_spec.hdr.dgram_len = 0; - udp_spec.hdr.dgram_cksum = 0; - - udp_mask.hdr.src_port = ntuple_filter->src_port_mask; - udp_mask.hdr.dst_port = ntuple_filter->dst_port_mask; - udp_mask.hdr.dgram_len = 0; - udp_mask.hdr.dgram_cksum = 0; - - udp_item.type = RTE_FLOW_ITEM_TYPE_UDP; - udp_item.spec = &udp_spec; - udp_item.mask = &udp_mask; - udp_item.last = NULL; - - attr.priority = ntuple_filter->priority; - pattern_ipv4_5tuple[1] = ipv4_udp_item; - pattern_ipv4_5tuple[2] = udp_item; - break; - case IPPROTO_TCP: - ipv4_tcp_item.type = RTE_FLOW_ITEM_TYPE_IPV4; - ipv4_tcp_item.spec = &ipv4_spec; - ipv4_tcp_item.mask = &ipv4_mask; - ipv4_tcp_item.last = NULL; - - memset(&tcp_spec, 0, sizeof(tcp_spec)); - tcp_spec.hdr.src_port = ntuple_filter->src_port; - tcp_spec.hdr.dst_port = ntuple_filter->dst_port; - - memset(&tcp_mask, 0, sizeof(tcp_mask)); - tcp_mask.hdr.src_port = ntuple_filter->src_port_mask; - tcp_mask.hdr.dst_port = ntuple_filter->dst_port_mask; - - tcp_item.type = RTE_FLOW_ITEM_TYPE_TCP; - tcp_item.spec = &tcp_spec; - tcp_item.mask = &tcp_mask; - tcp_item.last = NULL; - - attr.priority = ntuple_filter->priority; - pattern_ipv4_5tuple[1] = ipv4_tcp_item; - pattern_ipv4_5tuple[2] = tcp_item; - break; - case IPPROTO_SCTP: - ipv4_sctp_item.type = RTE_FLOW_ITEM_TYPE_IPV4; - ipv4_sctp_item.spec = &ipv4_spec; - ipv4_sctp_item.mask = &ipv4_mask; - ipv4_sctp_item.last = NULL; - - sctp_spec.hdr.src_port = ntuple_filter->src_port; - sctp_spec.hdr.dst_port = ntuple_filter->dst_port; - sctp_spec.hdr.cksum = 0; - sctp_spec.hdr.tag = 0; - - sctp_mask.hdr.src_port = ntuple_filter->src_port_mask; - sctp_mask.hdr.dst_port = ntuple_filter->dst_port_mask; - sctp_mask.hdr.cksum = 0; - sctp_mask.hdr.tag = 0; - - sctp_item.type = RTE_FLOW_ITEM_TYPE_SCTP; - sctp_item.spec = &sctp_spec; - sctp_item.mask = &sctp_mask; - sctp_item.last = NULL; - - attr.priority = ntuple_filter->priority; - pattern_ipv4_5tuple[1] = ipv4_sctp_item; - pattern_ipv4_5tuple[2] = sctp_item; - break; - default: - return ret; - } - - attr.ingress = 1; - pattern_ipv4_5tuple[0] = eth_item; - pattern_ipv4_5tuple[3] = end_item; - actions[0] = count_action; - actions[1] = end_action; - - /* Validate and add rule */ - ret = rte_flow_classify_validate(cls_app->cls, &attr, - pattern_ipv4_5tuple, actions, &error); - if (ret) { - printf("table entry validate failed ipv4_proto = %u\n", - ipv4_proto); - return ret; - } - - rule = rte_flow_classify_table_entry_add( - cls_app->cls, &attr, pattern_ipv4_5tuple, - actions, &key_found, &error); - if (rule == NULL) { - printf("table entry add failed ipv4_proto = %u\n", - ipv4_proto); - ret = -1; - return ret; - } - - rules[num_classify_rules] = rule; - num_classify_rules++; - return 0; -} - -/* Reads file and calls the add_classify_rule function. 8< */ -static int -add_rules(const char *rule_path, struct flow_classifier *cls_app) -{ - FILE *fh; - char buff[LINE_MAX]; - unsigned int i = 0; - unsigned int total_num = 0; - struct rte_eth_ntuple_filter ntuple_filter; - int ret; - - fh = fopen(rule_path, "rb"); - if (fh == NULL) - rte_exit(EXIT_FAILURE, "%s: fopen %s failed\n", __func__, - rule_path); - - ret = fseek(fh, 0, SEEK_SET); - if (ret) - rte_exit(EXIT_FAILURE, "%s: fseek %d failed\n", __func__, - ret); - - i = 0; - while (fgets(buff, LINE_MAX, fh) != NULL) { - i++; - - if (is_bypass_line(buff)) - continue; - - if (total_num >= FLOW_CLASSIFY_MAX_RULE_NUM - 1) { - printf("\nINFO: classify rule capacity %d reached\n", - total_num); - break; - } - - if (parse_ipv4_5tuple_rule(buff, &ntuple_filter) != 0) - rte_exit(EXIT_FAILURE, - "%s Line %u: parse rules error\n", - rule_path, i); - - if (add_classify_rule(&ntuple_filter, cls_app) != 0) - rte_exit(EXIT_FAILURE, "add rule error\n"); - - total_num++; - } - - fclose(fh); - return 0; -} -/* >8 End of add_rules. */ - -/* display usage */ -static void -print_usage(const char *prgname) -{ - printf("%s usage:\n", prgname); - printf("[EAL options] -- --"OPTION_RULE_IPV4"=FILE: "); - printf("specify the ipv4 rules file.\n"); - printf("Each rule occupies one line in the file.\n"); -} - -/* Parse the argument given in the command line of the application */ -static int -parse_args(int argc, char **argv) -{ - int opt, ret; - char **argvopt; - int option_index; - char *prgname = argv[0]; - static struct option lgopts[] = { - {OPTION_RULE_IPV4, 1, 0, 0}, - {NULL, 0, 0, 0} - }; - - argvopt = argv; - - while ((opt = getopt_long(argc, argvopt, "", - lgopts, &option_index)) != EOF) { - - switch (opt) { - /* long options */ - case 0: - if (!strncmp(lgopts[option_index].name, - OPTION_RULE_IPV4, - sizeof(OPTION_RULE_IPV4))) - parm_config.rule_ipv4_name = optarg; - break; - default: - print_usage(prgname); - return -1; - } - } - - if (optind >= 0) - argv[optind-1] = prgname; - - ret = optind-1; - optind = 1; /* reset getopt lib */ - return ret; -} - -/* - * The main function, which does initialization and calls the lcore_main - * function. - */ -int -main(int argc, char *argv[]) -{ - struct rte_mempool *mbuf_pool; - uint16_t nb_ports; - uint16_t portid; - int ret; - int socket_id; - struct rte_table_acl_params table_acl_params; - struct rte_flow_classify_table_params cls_table_params; - struct flow_classifier *cls_app; - struct rte_flow_classifier_params cls_params; - uint32_t size; - - /* Initialize the Environment Abstraction Layer (EAL). 8< */ - ret = rte_eal_init(argc, argv); - if (ret < 0) - rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); - /* >8 End of initialization of EAL. */ - - argc -= ret; - argv += ret; - - /* Parse application arguments (after the EAL ones). 8< */ - ret = parse_args(argc, argv); - if (ret < 0) - rte_exit(EXIT_FAILURE, "Invalid flow_classify parameters\n"); - /* >8 End of parse application arguments. */ - - /* Check that there is an even number of ports to send/receive on. */ - nb_ports = rte_eth_dev_count_avail(); - if (nb_ports < 2 || (nb_ports & 1)) - rte_exit(EXIT_FAILURE, "Error: number of ports must be even\n"); - - /* Creates a new mempool in memory to hold the mbufs. 8< */ - mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports, - MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); - /* >8 End of creation of new mempool in memory. */ - - if (mbuf_pool == NULL) - rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); - - /* Initialize all ports. 8< */ - RTE_ETH_FOREACH_DEV(portid) - if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n", - portid); - /* >8 End of initialization of all ports. */ - - if (rte_lcore_count() > 1) - printf("\nWARNING: Too many lcores enabled. Only 1 used.\n"); - - socket_id = rte_eth_dev_socket_id(0); - if (socket_id == SOCKET_ID_ANY) - socket_id = rte_lcore_to_socket_id(rte_get_next_lcore(-1, 0, 0)); - - /* Memory allocation. 8< */ - size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct flow_classifier_acl)); - cls_app = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE); - if (cls_app == NULL) - rte_exit(EXIT_FAILURE, "Cannot allocate classifier memory\n"); - - cls_params.name = "flow_classifier"; - cls_params.socket_id = socket_id; - - cls_app->cls = rte_flow_classifier_create(&cls_params); - if (cls_app->cls == NULL) { - rte_free(cls_app); - rte_exit(EXIT_FAILURE, "Cannot create classifier\n"); - } - - /* initialise ACL table params */ - table_acl_params.name = "table_acl_ipv4_5tuple"; - table_acl_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM; - table_acl_params.n_rule_fields = RTE_DIM(ipv4_defs); - memcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs)); - - /* initialise table create params */ - cls_table_params.ops = &rte_table_acl_ops; - cls_table_params.arg_create = &table_acl_params; - cls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE; - - ret = rte_flow_classify_table_create(cls_app->cls, &cls_table_params); - if (ret) { - rte_flow_classifier_free(cls_app->cls); - rte_free(cls_app); - rte_exit(EXIT_FAILURE, "Failed to create classifier table\n"); - } - /* >8 End of initialization of table create params. */ - - /* read file of IPv4 5 tuple rules and initialize parameters - * for rte_flow_classify_validate and rte_flow_classify_table_entry_add - * API's. - */ - - /* Read file of IPv4 tuple rules. 8< */ - if (add_rules(parm_config.rule_ipv4_name, cls_app)) { - rte_flow_classifier_free(cls_app->cls); - rte_free(cls_app); - rte_exit(EXIT_FAILURE, "Failed to add rules\n"); - } - /* >8 End of reading file of IPv4 5 tuple rules. */ - - /* Call lcore_main on the main core only. */ - lcore_main(cls_app); - - /* clean up the EAL */ - rte_eal_cleanup(); - - return 0; -} diff --git a/dpdk/examples/flow_classify/ipv4_rules_file.txt b/dpdk/examples/flow_classify/ipv4_rules_file.txt deleted file mode 100644 index cd5215736..000000000 --- a/dpdk/examples/flow_classify/ipv4_rules_file.txt +++ /dev/null @@ -1,14 +0,0 @@ -#file format: -#src_ip/masklen dst_ip/masklen src_port : mask dst_port : mask proto/mask priority -# -2.2.2.3/24 2.2.2.7/24 32 : 0xffff 33 : 0xffff 17/0xff 0 -9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 17/0xff 1 -9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 6/0xff 2 -9.9.8.3/24 9.9.8.7/24 32 : 0xffff 33 : 0xffff 6/0xff 3 -6.7.8.9/24 2.3.4.5/24 32 : 0x0000 33 : 0x0000 132/0xff 4 -6.7.8.9/32 192.168.0.36/32 10 : 0xffff 11 : 0xffff 6/0xfe 5 -6.7.8.9/24 192.168.0.36/24 10 : 0xffff 11 : 0xffff 6/0xfe 6 -6.7.8.9/16 192.168.0.36/16 10 : 0xffff 11 : 0xffff 6/0xfe 7 -6.7.8.9/8 192.168.0.36/8 10 : 0xffff 11 : 0xffff 6/0xfe 8 -#error rules -#9.8.7.6/8 192.168.0.36/8 10 : 0xffff 11 : 0xffff 6/0xfe 9 diff --git a/dpdk/examples/flow_classify/meson.build b/dpdk/examples/flow_classify/meson.build deleted file mode 100644 index 1be1bf037..000000000 --- a/dpdk/examples/flow_classify/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -# meson file, for building this example as part of a main DPDK build. -# -# To build this example as a standalone application with an already-installed -# DPDK instance, use 'make' - -deps += 'flow_classify' -allow_experimental_apis = true -sources = files( - 'flow_classify.c', -) diff --git a/dpdk/examples/ip_pipeline/examples/kni.cli b/dpdk/examples/ip_pipeline/examples/kni.cli deleted file mode 100644 index 143834093..000000000 --- a/dpdk/examples/ip_pipeline/examples/kni.cli +++ /dev/null @@ -1,69 +0,0 @@ -; SPDX-License-Identifier: BSD-3-Clause -; Copyright(c) 2010-2018 Intel Corporation - -; _______________ ______________________ -; | | KNI0 | | -; LINK0 RXQ0 --->|...............|------->|--+ | -; | | KNI1 | | br0 | -; LINK1 TXQ0 <---|...............|<-------|<-+ | -; | | | Linux Kernel | -; | PIPELINE0 | | Network Stack | -; | | KNI1 | | -; LINK1 RXQ0 --->|...............|------->|--+ | -; | | KNI0 | | br0 | -; LINK0 TXQ0 <---|...............|<-------|<-+ | -; |_______________| |______________________| -; -; Insert Linux kernel KNI module: -; [Linux]$ insmod rte_kni.ko -; -; Configure Linux kernel bridge between KNI0 and KNI1 interfaces: -; [Linux]$ brctl addbr br0 -; [Linux]$ brctl addif br0 KNI0 -; [Linux]$ brctl addif br0 KNI1 -; [Linux]$ ifconfig br0 up -; [Linux]$ ifconfig KNI0 up -; [Linux]$ ifconfig KNI1 up -; -; Monitor packet forwarding performed by Linux kernel between KNI0 and KNI1: -; [Linux]$ tcpdump -i KNI0 -; [Linux]$ tcpdump -i KNI1 - -mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 - -link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on - -kni KNI0 link LINK0 mempool MEMPOOL0 -kni KNI1 link LINK1 mempool MEMPOOL0 - -table action profile AP0 ipv4 offset 270 fwd - -pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0 - -pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0 -pipeline PIPELINE0 port in bsz 32 kni KNI1 -pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0 -pipeline PIPELINE0 port in bsz 32 kni KNI0 - -pipeline PIPELINE0 port out bsz 32 kni KNI0 -pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0 -pipeline PIPELINE0 port out bsz 32 kni KNI1 -pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0 - -pipeline PIPELINE0 table match stub action AP0 -pipeline PIPELINE0 table match stub action AP0 -pipeline PIPELINE0 table match stub action AP0 -pipeline PIPELINE0 table match stub action AP0 - -pipeline PIPELINE0 port in 0 table 0 -pipeline PIPELINE0 port in 1 table 1 -pipeline PIPELINE0 port in 2 table 2 -pipeline PIPELINE0 port in 3 table 3 - -thread 1 pipeline PIPELINE0 enable - -pipeline PIPELINE0 table 0 rule add match default action fwd port 0 -pipeline PIPELINE0 table 1 rule add match default action fwd port 1 -pipeline PIPELINE0 table 2 rule add match default action fwd port 2 -pipeline PIPELINE0 table 3 rule add match default action fwd port 3 diff --git a/dpdk/examples/ip_pipeline/kni.c b/dpdk/examples/ip_pipeline/kni.c deleted file mode 100644 index cd02c3947..000000000 --- a/dpdk/examples/ip_pipeline/kni.c +++ /dev/null @@ -1,168 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2018 Intel Corporation - */ - -#include -#include - -#include -#include - -#include "kni.h" -#include "mempool.h" -#include "link.h" - -static struct kni_list kni_list; - -#ifndef KNI_MAX -#define KNI_MAX 16 -#endif - -int -kni_init(void) -{ - TAILQ_INIT(&kni_list); - -#ifdef RTE_LIB_KNI - rte_kni_init(KNI_MAX); -#endif - - return 0; -} - -struct kni * -kni_find(const char *name) -{ - struct kni *kni; - - if (name == NULL) - return NULL; - - TAILQ_FOREACH(kni, &kni_list, node) - if (strcmp(kni->name, name) == 0) - return kni; - - return NULL; -} - -#ifndef RTE_LIB_KNI - -struct kni * -kni_create(const char *name __rte_unused, - struct kni_params *params __rte_unused) -{ - return NULL; -} - -void -kni_handle_request(void) -{ - return; -} - -#else - -static int -kni_config_network_interface(uint16_t port_id, uint8_t if_up) -{ - int ret = 0; - - if (!rte_eth_dev_is_valid_port(port_id)) - return -EINVAL; - - ret = (if_up) ? - rte_eth_dev_set_link_up(port_id) : - rte_eth_dev_set_link_down(port_id); - - return ret; -} - -static int -kni_change_mtu(uint16_t port_id, unsigned int new_mtu) -{ - int ret; - - if (!rte_eth_dev_is_valid_port(port_id)) - return -EINVAL; - - if (new_mtu > RTE_ETHER_MAX_LEN) - return -EINVAL; - - /* Set new MTU */ - ret = rte_eth_dev_set_mtu(port_id, new_mtu); - if (ret < 0) - return ret; - - return 0; -} - -struct kni * -kni_create(const char *name, struct kni_params *params) -{ - struct rte_eth_dev_info dev_info; - struct rte_kni_conf kni_conf; - struct rte_kni_ops kni_ops; - struct kni *kni; - struct mempool *mempool; - struct link *link; - struct rte_kni *k; - int ret; - - /* Check input params */ - if ((name == NULL) || - kni_find(name) || - (params == NULL)) - return NULL; - - mempool = mempool_find(params->mempool_name); - link = link_find(params->link_name); - if ((mempool == NULL) || - (link == NULL)) - return NULL; - - /* Resource create */ - ret = rte_eth_dev_info_get(link->port_id, &dev_info); - if (ret != 0) - return NULL; - - memset(&kni_conf, 0, sizeof(kni_conf)); - strlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE); - kni_conf.force_bind = params->force_bind; - kni_conf.core_id = params->thread_id; - kni_conf.group_id = link->port_id; - kni_conf.mbuf_size = mempool->buffer_size; - - memset(&kni_ops, 0, sizeof(kni_ops)); - kni_ops.port_id = link->port_id; - kni_ops.config_network_if = kni_config_network_interface; - kni_ops.change_mtu = kni_change_mtu; - - k = rte_kni_alloc(mempool->m, &kni_conf, &kni_ops); - if (k == NULL) - return NULL; - - /* Node allocation */ - kni = calloc(1, sizeof(struct kni)); - if (kni == NULL) - return NULL; - - /* Node fill in */ - strlcpy(kni->name, name, sizeof(kni->name)); - kni->k = k; - - /* Node add to list */ - TAILQ_INSERT_TAIL(&kni_list, kni, node); - - return kni; -} - -void -kni_handle_request(void) -{ - struct kni *kni; - - TAILQ_FOREACH(kni, &kni_list, node) - rte_kni_handle_request(kni->k); -} - -#endif diff --git a/dpdk/examples/ip_pipeline/kni.h b/dpdk/examples/ip_pipeline/kni.h deleted file mode 100644 index 118f48df7..000000000 --- a/dpdk/examples/ip_pipeline/kni.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2018 Intel Corporation - */ - -#ifndef _INCLUDE_KNI_H_ -#define _INCLUDE_KNI_H_ - -#include -#include - -#ifdef RTE_LIB_KNI -#include -#endif - -#include "common.h" - -struct kni { - TAILQ_ENTRY(kni) node; - char name[NAME_SIZE]; -#ifdef RTE_LIB_KNI - struct rte_kni *k; -#endif -}; - -TAILQ_HEAD(kni_list, kni); - -int -kni_init(void); - -struct kni * -kni_find(const char *name); - -struct kni_params { - const char *link_name; - const char *mempool_name; - int force_bind; - uint32_t thread_id; -}; - -struct kni * -kni_create(const char *name, struct kni_params *params); - -void -kni_handle_request(void); - -#endif /* _INCLUDE_KNI_H_ */ diff --git a/dpdk/examples/multi_process/hotplug_mp/commands.h b/dpdk/examples/multi_process/hotplug_mp/commands.h deleted file mode 100644 index afcf177db..000000000 --- a/dpdk/examples/multi_process/hotplug_mp/commands.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Intel Corporation - */ - -#ifndef _COMMANDS_H_ -#define _COMMANDS_H_ - -extern cmdline_parse_ctx_t main_ctx[]; - -#endif /* _COMMANDS_H_ */ diff --git a/dpdk/examples/server_node_efd/node/Makefile b/dpdk/examples/server_node_efd/node/Makefile deleted file mode 100644 index 115e2da7a..000000000 --- a/dpdk/examples/server_node_efd/node/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2016-2020 Intel Corporation - -# binary name -APP = node - -# all source are stored in SRCS-y -SRCS-y := node.c - -CFLAGS += -I../shared - -PKGCONF ?= pkg-config - -# Build using pkg-config variables if possible -ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) -$(error "no installation of DPDK found") -endif - -all: shared -.PHONY: shared static -shared: build/$(APP)-shared - ln -sf $(APP)-shared build/$(APP) -static: build/$(APP)-static - ln -sf $(APP)-static build/$(APP) - -PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) -CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) - -ifeq ($(MAKECMDGOALS),static) -# check for broken pkg-config -ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) -$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") -$(error "Cannot generate statically-linked binaries with this version of pkg-config") -endif -endif - -CFLAGS += -DALLOW_EXPERIMENTAL_API - -build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) - -build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) - -build: - @mkdir -p $@ - -.PHONY: clean -clean: - rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared - test -d build && rmdir -p build || true diff --git a/dpdk/examples/server_node_efd/node/meson.build b/dpdk/examples/server_node_efd/node/meson.build deleted file mode 100644 index 1c720968a..000000000 --- a/dpdk/examples/server_node_efd/node/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2019 Intel Corporation - -# meson file, for building this example as part of a main DPDK build. -# -# To build this example as a standalone application with an already-installed -# DPDK instance, use 'make' - -name = 'efd_node' - -allow_experimental_apis = true -deps += ['hash'] -sources += files('node.c') -includes += include_directories('../shared') diff --git a/dpdk/examples/server_node_efd/node/node.c b/dpdk/examples/server_node_efd/node/node.c deleted file mode 100644 index fc2aa5ffe..000000000 --- a/dpdk/examples/server_node_efd/node/node.c +++ /dev/null @@ -1,395 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" - -/* Number of packets to attempt to read from queue */ -#define PKT_READ_SIZE ((uint16_t)32) - -/* - * Our node id number - tells us which rx queue to read, and NIC TX - * queue to write to. - */ -static uint8_t node_id; - -#define MBQ_CAPACITY 32 - -/* maps input ports to output ports for packets */ -static uint16_t output_ports[RTE_MAX_ETHPORTS]; - -/* buffers up a set of packet that are ready to send */ -struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; - -/* shared data from server. We update statistics here */ -static struct tx_stats *tx_stats; - -static struct filter_stats *filter_stats; - -/* - * print a usage message - */ -static void -usage(const char *progname) -{ - printf("Usage: %s [EAL args] -- -n \n\n", progname); -} - -/* - * Convert the node id number from a string to an int. - */ -static int -parse_node_num(const char *node) -{ - char *end = NULL; - unsigned long temp; - - if (node == NULL || *node == '\0') - return -1; - - temp = strtoul(node, &end, 10); - if (end == NULL || *end != '\0') - return -1; - - node_id = (uint8_t)temp; - return 0; -} - -/* - * Parse the application arguments to the node app. - */ -static int -parse_app_args(int argc, char *argv[]) -{ - int option_index, opt; - char **argvopt = argv; - const char *progname = NULL; - static struct option lgopts[] = { /* no long options */ - {NULL, 0, 0, 0 } - }; - progname = argv[0]; - - while ((opt = getopt_long(argc, argvopt, "n:", lgopts, - &option_index)) != EOF) { - switch (opt) { - case 'n': - if (parse_node_num(optarg) != 0) { - usage(progname); - return -1; - } - break; - default: - usage(progname); - return -1; - } - } - return 0; -} - -/* - * Tx buffer error callback - */ -static void -flush_tx_error_callback(struct rte_mbuf **unsent, uint16_t count, - void *userdata) { - int i; - uint16_t port_id = (uintptr_t)userdata; - - tx_stats->tx_drop[port_id] += count; - - /* free the mbufs which failed from transmit */ - for (i = 0; i < count; i++) - rte_pktmbuf_free(unsent[i]); - -} - -static void -configure_tx_buffer(uint16_t port_id, uint16_t size) -{ - int ret; - - /* Initialize TX buffers */ - tx_buffer[port_id] = rte_zmalloc_socket("tx_buffer", - RTE_ETH_TX_BUFFER_SIZE(size), 0, - rte_eth_dev_socket_id(port_id)); - if (tx_buffer[port_id] == NULL) - rte_exit(EXIT_FAILURE, - "Cannot allocate buffer for tx on port %u\n", port_id); - - rte_eth_tx_buffer_init(tx_buffer[port_id], size); - - ret = rte_eth_tx_buffer_set_err_callback(tx_buffer[port_id], - flush_tx_error_callback, (void *)(intptr_t)port_id); - if (ret < 0) - rte_exit(EXIT_FAILURE, - "Cannot set error callback for tx buffer on port %u\n", - port_id); -} - -/* - * set up output ports so that all traffic on port gets sent out - * its paired port. Index using actual port numbers since that is - * what comes in the mbuf structure. - */ -static void -configure_output_ports(const struct shared_info *info) -{ - int i; - - if (info->num_ports > RTE_MAX_ETHPORTS) - rte_exit(EXIT_FAILURE, "Too many ethernet ports. " - "RTE_MAX_ETHPORTS = %u\n", - (unsigned int)RTE_MAX_ETHPORTS); - for (i = 0; i < info->num_ports - 1; i += 2) { - uint8_t p1 = info->id[i]; - uint8_t p2 = info->id[i+1]; - - output_ports[p1] = p2; - output_ports[p2] = p1; - - configure_tx_buffer(p1, MBQ_CAPACITY); - configure_tx_buffer(p2, MBQ_CAPACITY); - - } -} - -/* - * Create the hash table that will contain the flows that - * the node will handle, which will be used to decide if packet - * is transmitted or dropped. - */ - -/* Creation of hash table. 8< */ -static struct rte_hash * -create_hash_table(const struct shared_info *info) -{ - uint32_t num_flows_node = info->num_flows / info->num_nodes; - char name[RTE_HASH_NAMESIZE]; - struct rte_hash *h; - - /* create table */ - struct rte_hash_parameters hash_params = { - .entries = num_flows_node * 2, /* table load = 50% */ - .key_len = sizeof(uint32_t), /* Store IPv4 dest IP address */ - .socket_id = rte_socket_id(), - .hash_func_init_val = 0, - }; - - snprintf(name, sizeof(name), "hash_table_%d", node_id); - hash_params.name = name; - h = rte_hash_create(&hash_params); - - if (h == NULL) - rte_exit(EXIT_FAILURE, - "Problem creating the hash table for node %d\n", - node_id); - return h; -} - -static void -populate_hash_table(const struct rte_hash *h, const struct shared_info *info) -{ - unsigned int i; - int32_t ret; - uint32_t ip_dst; - uint32_t num_flows_node = 0; - uint64_t target_node; - - /* Add flows in table */ - for (i = 0; i < info->num_flows; i++) { - target_node = i % info->num_nodes; - if (target_node != node_id) - continue; - - ip_dst = rte_cpu_to_be_32(i); - - ret = rte_hash_add_key(h, (void *) &ip_dst); - if (ret < 0) - rte_exit(EXIT_FAILURE, "Unable to add entry %u " - "in hash table\n", i); - else - num_flows_node++; - - } - - printf("Hash table: Adding 0x%x keys\n", num_flows_node); -} -/* >8 End of creation of hash table. */ - -/* - * This function performs routing of packets - * Just sends each input packet out an output port based solely on the input - * port it arrived on. - */ -static inline void -transmit_packet(struct rte_mbuf *buf) -{ - int sent; - const uint16_t in_port = buf->port; - const uint16_t out_port = output_ports[in_port]; - struct rte_eth_dev_tx_buffer *buffer = tx_buffer[out_port]; - - sent = rte_eth_tx_buffer(out_port, node_id, buffer, buf); - if (sent) - tx_stats->tx[out_port] += sent; - -} - -/* Packets dequeued from the shared ring. 8< */ -static inline void -handle_packets(struct rte_hash *h, struct rte_mbuf **bufs, uint16_t num_packets) -{ - struct rte_ipv4_hdr *ipv4_hdr; - uint32_t ipv4_dst_ip[PKT_READ_SIZE]; - const void *key_ptrs[PKT_READ_SIZE]; - unsigned int i; - int32_t positions[PKT_READ_SIZE] = {0}; - - for (i = 0; i < num_packets; i++) { - /* Handle IPv4 header.*/ - ipv4_hdr = rte_pktmbuf_mtod_offset(bufs[i], - struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); - ipv4_dst_ip[i] = ipv4_hdr->dst_addr; - key_ptrs[i] = &ipv4_dst_ip[i]; - } - /* Check if packets belongs to any flows handled by this node */ - rte_hash_lookup_bulk(h, key_ptrs, num_packets, positions); - - for (i = 0; i < num_packets; i++) { - if (likely(positions[i] >= 0)) { - filter_stats->passed++; - transmit_packet(bufs[i]); - } else { - filter_stats->drop++; - /* Drop packet, as flow is not handled by this node */ - rte_pktmbuf_free(bufs[i]); - } - } -} -/* >8 End of packets dequeuing. */ - -/* - * Application main function - loops through - * receiving and processing packets. Never returns - */ -int -main(int argc, char *argv[]) -{ - const struct rte_memzone *mz; - struct rte_ring *rx_ring; - struct rte_hash *h; - struct rte_mempool *mp; - struct shared_info *info; - int need_flush = 0; /* indicates whether we have unsent packets */ - int retval; - void *pkts[PKT_READ_SIZE]; - uint16_t sent; - - retval = rte_eal_init(argc, argv); - if (retval < 0) - return -1; - argc -= retval; - argv += retval; - - if (parse_app_args(argc, argv) < 0) - rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); - - if (rte_eth_dev_count_avail() == 0) - rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); - - /* Attaching to the server process memory. 8< */ - rx_ring = rte_ring_lookup(get_rx_queue_name(node_id)); - if (rx_ring == NULL) - rte_exit(EXIT_FAILURE, "Cannot get RX ring - " - "is server process running?\n"); - - mp = rte_mempool_lookup(PKTMBUF_POOL_NAME); - if (mp == NULL) - rte_exit(EXIT_FAILURE, "Cannot get mempool for mbufs\n"); - - mz = rte_memzone_lookup(MZ_SHARED_INFO); - if (mz == NULL) - rte_exit(EXIT_FAILURE, "Cannot get port info structure\n"); - info = mz->addr; - tx_stats = &(info->tx_stats[node_id]); - filter_stats = &(info->filter_stats[node_id]); - /* >8 End of attaching to the server process memory. */ - - configure_output_ports(info); - - h = create_hash_table(info); - - populate_hash_table(h, info); - - RTE_LOG(INFO, APP, "Finished Process Init.\n"); - - printf("\nNode process %d handling packets\n", node_id); - printf("[Press Ctrl-C to quit ...]\n"); - - for (;;) { - uint16_t rx_pkts = PKT_READ_SIZE; - uint16_t port; - - /* - * Try dequeuing max possible packets first, if that fails, - * get the most we can. Loop body should only execute once, - * maximum - */ - while (rx_pkts > 0 && - unlikely(rte_ring_dequeue_bulk(rx_ring, pkts, - rx_pkts, NULL) == 0)) - rx_pkts = (uint16_t)RTE_MIN(rte_ring_count(rx_ring), - PKT_READ_SIZE); - - if (unlikely(rx_pkts == 0)) { - if (need_flush) - for (port = 0; port < info->num_ports; port++) { - sent = rte_eth_tx_buffer_flush( - info->id[port], - node_id, - tx_buffer[port]); - if (unlikely(sent)) - tx_stats->tx[port] += sent; - } - need_flush = 0; - continue; - } - - handle_packets(h, (struct rte_mbuf **)pkts, rx_pkts); - - need_flush = 1; - } - - /* clean up the EAL */ - rte_eal_cleanup(); -} diff --git a/dpdk/examples/server_node_efd/server/Makefile b/dpdk/examples/server_node_efd/server/Makefile deleted file mode 100644 index 8eb75fe35..000000000 --- a/dpdk/examples/server_node_efd/server/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2016-2020 Intel Corporation - -# binary name -APP = server - -# all source are stored in SRCS-y -SRCS-y := main.c init.c args.c - -CFLAGS += -I../shared - -PKGCONF ?= pkg-config - -# Build using pkg-config variables if possible -ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) -$(error "no installation of DPDK found") -endif - -all: shared -.PHONY: shared static -shared: build/$(APP)-shared - ln -sf $(APP)-shared build/$(APP) -static: build/$(APP)-static - ln -sf $(APP)-static build/$(APP) - -PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) -CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) - -ifeq ($(MAKECMDGOALS),static) -# check for broken pkg-config -ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) -$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") -$(error "Cannot generate statically-linked binaries with this version of pkg-config") -endif -endif - -CFLAGS += -DALLOW_EXPERIMENTAL_API - -build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) - -build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) - -build: - @mkdir -p $@ - -.PHONY: clean -clean: - rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared - test -d build && rmdir -p build || true diff --git a/dpdk/examples/server_node_efd/server/args.c b/dpdk/examples/server_node_efd/server/args.c deleted file mode 100644 index 0e5e89705..000000000 --- a/dpdk/examples/server_node_efd/server/args.c +++ /dev/null @@ -1,171 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "common.h" -#include "args.h" -#include "init.h" - -/* 1M flows by default */ -#define DEFAULT_NUM_FLOWS 0x100000 - -/* global var for number of nodes - extern in header */ -uint8_t num_nodes; -/* global var for number of flows - extern in header */ -uint32_t num_flows = DEFAULT_NUM_FLOWS; - -static const char *progname; - -/** - * Prints out usage information to stdout - */ -static void -usage(void) -{ - printf("%s [EAL options] -- -p PORTMASK -n NUM_NODES -f NUM_FLOWS\n" - " -p PORTMASK: hexadecimal bitmask of ports to use\n" - " -n NUM_NODES: number of node processes to use\n" - " -f NUM_FLOWS: number of flows to be added in the EFD table\n", - progname); -} - -/** - * The ports to be used by the application are passed in - * the form of a bitmask. This function parses the bitmask - * and places the port numbers to be used into the port[] - * array variable - */ -static int -parse_portmask(uint8_t max_ports, const char *portmask) -{ - char *end = NULL; - unsigned long pm; - uint8_t count = 0; - - if (portmask == NULL || *portmask == '\0') - return -1; - - /* convert parameter to a number and verify */ - pm = strtoul(portmask, &end, 16); - if (end == NULL || *end != '\0' || pm == 0) - return -1; - - /* loop through bits of the mask and mark ports */ - while (pm != 0) { - if (pm & 0x01) { /* bit is set in mask, use port */ - if (count >= max_ports) - printf("WARNING: requested port %u not present" - " - ignoring\n", (unsigned int)count); - else - info->id[info->num_ports++] = count; - } - pm = (pm >> 1); - count++; - } - - return 0; -} - -/** - * Take the number of nodes parameter passed to the app - * and convert to a number to store in the num_nodes variable - */ -static int -parse_num_nodes(const char *nodes) -{ - char *end = NULL; - unsigned long temp; - - if (nodes == NULL || *nodes == '\0') - return -1; - - temp = strtoul(nodes, &end, 10); - if (end == NULL || *end != '\0' || temp == 0) - return -1; - - num_nodes = (uint8_t)temp; - return 0; -} - -static int -parse_num_flows(const char *flows) -{ - char *end = NULL; - - /* parse hexadecimal string */ - num_flows = strtoul(flows, &end, 16); - if ((flows[0] == '\0') || (end == NULL) || (*end != '\0')) - return -1; - - if (num_flows == 0) - return -1; - - return 0; -} - -/** - * The application specific arguments follow the DPDK-specific - * arguments which are stripped by the DPDK init. This function - * processes these application arguments, printing usage info - * on error. - */ -int -parse_app_args(uint8_t max_ports, int argc, char *argv[]) -{ - int option_index, opt; - char **argvopt = argv; - static struct option lgopts[] = { /* no long options */ - {NULL, 0, 0, 0 } - }; - progname = argv[0]; - - while ((opt = getopt_long(argc, argvopt, "n:f:p:", lgopts, - &option_index)) != EOF) { - switch (opt) { - case 'p': - if (parse_portmask(max_ports, optarg) != 0) { - usage(); - return -1; - } - break; - case 'n': - if (parse_num_nodes(optarg) != 0) { - usage(); - return -1; - } - break; - case 'f': - if (parse_num_flows(optarg) != 0) { - usage(); - return -1; - } - break; - default: - printf("ERROR: Unknown option '%c'\n", opt); - usage(); - return -1; - } - } - - if (info->num_ports == 0 || num_nodes == 0) { - usage(); - return -1; - } - - if (info->num_ports % 2 != 0) { - printf("ERROR: application requires an even " - "number of ports to use\n"); - return -1; - } - return 0; -} diff --git a/dpdk/examples/server_node_efd/server/args.h b/dpdk/examples/server_node_efd/server/args.h deleted file mode 100644 index 226f66922..000000000 --- a/dpdk/examples/server_node_efd/server/args.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#ifndef _ARGS_H_ -#define _ARGS_H_ - -int parse_app_args(uint8_t max_ports, int argc, char *argv[]); - -#endif /* ifndef _ARGS_H_ */ diff --git a/dpdk/examples/server_node_efd/server/init.c b/dpdk/examples/server_node_efd/server/init.c deleted file mode 100644 index 9c89f6b60..000000000 --- a/dpdk/examples/server_node_efd/server/init.c +++ /dev/null @@ -1,368 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "args.h" -#include "init.h" - -#define MBUFS_PER_NODE 1536 -#define MBUFS_PER_PORT 1536 -#define MBUF_CACHE_SIZE 512 - -#define RTE_MP_RX_DESC_DEFAULT 512 -#define RTE_MP_TX_DESC_DEFAULT 512 -#define NODE_QUEUE_RINGSIZE 128 - -#define NO_FLAGS 0 - -/* The mbuf pool for packet rx */ -struct rte_mempool *pktmbuf_pool; - -/* array of info/queues for nodes */ -struct node *nodes; - -/* EFD table */ -struct rte_efd_table *efd_table; - -/* Shared info between server and nodes */ -struct shared_info *info; - -/** - * Initialise the mbuf pool for packet reception for the NIC, and any other - * buffer pools needed by the app - currently none. - */ -static int -init_mbuf_pools(void) -{ - const unsigned int num_mbufs = (num_nodes * MBUFS_PER_NODE) + - (info->num_ports * MBUFS_PER_PORT); - - /* - * Don't pass single-producer/single-consumer flags to mbuf create as it - * seems faster to use a cache instead - */ - printf("Creating mbuf pool '%s' [%u mbufs] ...\n", - PKTMBUF_POOL_NAME, num_mbufs); - pktmbuf_pool = rte_pktmbuf_pool_create(PKTMBUF_POOL_NAME, num_mbufs, - MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); - - return pktmbuf_pool == NULL; /* 0 on success */ -} - -/** - * Initialise an individual port: - * - configure number of rx and tx rings - * - set up each rx ring, to pull from the main mbuf pool - * - set up each tx ring - * - start the port and report its status to stdout - */ -static int -init_port(uint16_t port_num) -{ - /* for port configuration all features are off by default */ - struct rte_eth_conf port_conf = { - .rxmode = { - .mq_mode = RTE_ETH_MQ_RX_RSS, - }, - }; - const uint16_t rx_rings = 1, tx_rings = num_nodes; - uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT; - uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT; - struct rte_eth_dev_info dev_info; - struct rte_eth_txconf txconf; - - uint16_t q; - int retval; - - printf("Port %u init ... ", port_num); - fflush(stdout); - - retval = rte_eth_dev_info_get(port_num, &dev_info); - if (retval != 0) - return retval; - - if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) - port_conf.txmode.offloads |= - RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; - - /* - * Standard DPDK port initialisation - config port, then set up - * rx and tx rings. - */ - retval = rte_eth_dev_configure(port_num, rx_rings, tx_rings, &port_conf); - if (retval != 0) - return retval; - - retval = rte_eth_dev_adjust_nb_rx_tx_desc(port_num, &rx_ring_size, - &tx_ring_size); - if (retval != 0) - return retval; - - for (q = 0; q < rx_rings; q++) { - retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size, - rte_eth_dev_socket_id(port_num), - NULL, pktmbuf_pool); - if (retval < 0) - return retval; - } - - txconf = dev_info.default_txconf; - txconf.offloads = port_conf.txmode.offloads; - for (q = 0; q < tx_rings; q++) { - retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size, - rte_eth_dev_socket_id(port_num), - &txconf); - if (retval < 0) - return retval; - } - - retval = rte_eth_promiscuous_enable(port_num); - if (retval != 0) - return retval; - - retval = rte_eth_dev_start(port_num); - if (retval < 0) - return retval; - - printf("done:\n"); - - return 0; -} - -/** - * Set up the DPDK rings which will be used to pass packets, via - * pointers, between the multi-process server and node processes. - * Each node needs one RX queue. - */ -static int -init_shm_rings(void) -{ - unsigned int i; - unsigned int socket_id; - const char *q_name; - const unsigned int ringsize = NODE_QUEUE_RINGSIZE; - - nodes = rte_malloc("node details", - sizeof(*nodes) * num_nodes, 0); - if (nodes == NULL) - rte_exit(EXIT_FAILURE, "Cannot allocate memory for " - "node program details\n"); - - for (i = 0; i < num_nodes; i++) { - /* Create an RX queue for each node */ - socket_id = rte_socket_id(); - q_name = get_rx_queue_name(i); - nodes[i].rx_q = rte_ring_create(q_name, - ringsize, socket_id, - RING_F_SP_ENQ | RING_F_SC_DEQ); - if (nodes[i].rx_q == NULL) - rte_exit(EXIT_FAILURE, "Cannot create rx ring queue " - "for node %u\n", i); - } - return 0; -} - -/* - * Create EFD table which will contain all the flows - * that will be distributed among the nodes - */ - -/* Create EFD table. 8< */ -static void -create_efd_table(void) -{ - uint8_t socket_id = rte_socket_id(); - - /* create table */ - efd_table = rte_efd_create("flow table", num_flows * 2, sizeof(uint32_t), - 1 << socket_id, socket_id); - - if (efd_table == NULL) - rte_exit(EXIT_FAILURE, "Problem creating the flow table\n"); -} - -static void -populate_efd_table(void) -{ - unsigned int i; - int32_t ret; - uint32_t ip_dst; - uint8_t socket_id = rte_socket_id(); - uint64_t node_id; - - /* Add flows in table */ - for (i = 0; i < num_flows; i++) { - node_id = i % num_nodes; - - ip_dst = rte_cpu_to_be_32(i); - ret = rte_efd_update(efd_table, socket_id, - (void *)&ip_dst, (efd_value_t)node_id); - if (ret < 0) - rte_exit(EXIT_FAILURE, "Unable to add entry %u in " - "EFD table\n", i); - } - - printf("EFD table: Adding 0x%x keys\n", num_flows); -} -/* >8 End of creation EFD table. */ - -/* Check the link status of all ports in up to 9s, and print them finally */ -static void -check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) -{ -#define CHECK_INTERVAL 100 /* 100ms */ -#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ - uint8_t count, all_ports_up, print_flag = 0; - uint16_t portid; - struct rte_eth_link link; - int ret; - char link_status_text[RTE_ETH_LINK_MAX_STR_LEN]; - - printf("\nChecking link status"); - fflush(stdout); - for (count = 0; count <= MAX_CHECK_TIME; count++) { - all_ports_up = 1; - for (portid = 0; portid < port_num; portid++) { - if ((port_mask & (1 << info->id[portid])) == 0) - continue; - memset(&link, 0, sizeof(link)); - ret = rte_eth_link_get_nowait(info->id[portid], &link); - if (ret < 0) { - all_ports_up = 0; - if (print_flag == 1) - printf("Port %u link get failed: %s\n", - portid, rte_strerror(-ret)); - continue; - } - /* print link status if flag set */ - if (print_flag == 1) { - rte_eth_link_to_str(link_status_text, - sizeof(link_status_text), &link); - printf("Port %d %s\n", info->id[portid], - link_status_text); - continue; - } - /* clear all_ports_up flag if any link down */ - if (link.link_status == RTE_ETH_LINK_DOWN) { - all_ports_up = 0; - break; - } - } - /* after finally printing all link status, get out */ - if (print_flag == 1) - break; - - if (all_ports_up == 0) { - printf("."); - fflush(stdout); - rte_delay_ms(CHECK_INTERVAL); - } - - /* set the print_flag if all ports up or timeout */ - if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) { - print_flag = 1; - printf("done\n"); - } - } -} - -/** - * Main init function for the multi-process server app, - * calls subfunctions to do each stage of the initialisation. - */ -int -init(int argc, char *argv[]) -{ - int retval; - const struct rte_memzone *mz; - uint8_t i, total_ports; - - /* init EAL, parsing EAL args */ - retval = rte_eal_init(argc, argv); - if (retval < 0) - return -1; - argc -= retval; - argv += retval; - - /* get total number of ports */ - total_ports = rte_eth_dev_count_avail(); - - /* set up array for port data */ - mz = rte_memzone_reserve(MZ_SHARED_INFO, sizeof(*info), - rte_socket_id(), NO_FLAGS); - if (mz == NULL) - rte_exit(EXIT_FAILURE, "Cannot reserve memory zone " - "for port information\n"); - memset(mz->addr, 0, sizeof(*info)); - info = mz->addr; - - /* parse additional, application arguments */ - retval = parse_app_args(total_ports, argc, argv); - if (retval != 0) - return -1; - - /* initialise mbuf pools */ - retval = init_mbuf_pools(); - if (retval != 0) - rte_exit(EXIT_FAILURE, "Cannot create needed mbuf pools\n"); - - /* now initialise the ports we will use */ - for (i = 0; i < info->num_ports; i++) { - retval = init_port(info->id[i]); - if (retval != 0) - rte_exit(EXIT_FAILURE, "Cannot initialise port %u\n", - (unsigned int) i); - } - - check_all_ports_link_status(info->num_ports, (~0x0)); - - /* initialise the node queues/rings for inter-eu comms */ - init_shm_rings(); - - /* Create the EFD table */ - create_efd_table(); - - /* Populate the EFD table */ - populate_efd_table(); - - /* Share the total number of nodes */ - info->num_nodes = num_nodes; - - /* Share the total number of flows */ - info->num_flows = num_flows; - return 0; -} diff --git a/dpdk/examples/server_node_efd/server/init.h b/dpdk/examples/server_node_efd/server/init.h deleted file mode 100644 index 506e2e456..000000000 --- a/dpdk/examples/server_node_efd/server/init.h +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#ifndef _INIT_H_ -#define _INIT_H_ - -/* - * #include - * #include "args.h" - */ - -/* - * Define a node structure with all needed info, including - * stats from the nodes. - */ -struct node { - struct rte_ring *rx_q; - unsigned int node_id; - /* these stats hold how many packets the node will actually receive, - * and how many packets were dropped because the node's queue was full. - * The port-info stats, in contrast, record how many packets were received - * or transmitted on an actual NIC port. - */ - struct { - uint64_t rx; - uint64_t rx_drop; - } stats; -}; - -extern struct rte_efd_table *efd_table; -extern struct node *nodes; - -/* - * shared information between server and nodes: number of nodes, - * port numbers, rx and tx stats etc. - */ -extern struct shared_info *info; - -extern struct rte_mempool *pktmbuf_pool; -extern uint8_t num_nodes; -extern unsigned int num_sockets; -extern uint32_t num_flows; - -int init(int argc, char *argv[]); - -#endif /* ifndef _INIT_H_ */ diff --git a/dpdk/examples/server_node_efd/server/main.c b/dpdk/examples/server_node_efd/server/main.c deleted file mode 100644 index fd72882e3..000000000 --- a/dpdk/examples/server_node_efd/server/main.c +++ /dev/null @@ -1,350 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016-2017 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "args.h" -#include "init.h" - -/* - * When doing reads from the NIC or the node queues, - * use this batch size - */ -#define PACKET_READ_SIZE 32 - -/* - * Local buffers to put packets in, used to send packets in bursts to the - * nodes - */ -struct node_rx_buf { - struct rte_mbuf *buffer[PACKET_READ_SIZE]; - uint16_t count; -}; - -struct efd_stats { - uint64_t distributed; - uint64_t drop; -} flow_dist_stats; - -/* One buffer per node rx queue - dynamically allocate array */ -static struct node_rx_buf *cl_rx_buf; - -static const char * -get_printable_mac_addr(uint16_t port) -{ - static const char err_address[] = "00:00:00:00:00:00"; - static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)]; - struct rte_ether_addr mac; - int ret; - - if (unlikely(port >= RTE_MAX_ETHPORTS)) - return err_address; - if (unlikely(addresses[port][0] == '\0')) { - ret = rte_eth_macaddr_get(port, &mac); - if (ret != 0) { - printf("Failed to get MAC address (port %u): %s\n", - port, rte_strerror(-ret)); - return err_address; - } - - snprintf(addresses[port], sizeof(addresses[port]), - RTE_ETHER_ADDR_PRT_FMT "\n", - RTE_ETHER_ADDR_BYTES(&mac)); - } - return addresses[port]; -} - -/* - * This function displays the recorded statistics for each port - * and for each node. It uses ANSI terminal codes to clear - * screen when called. It is called from a single worker - * thread in the server process, when the process is run with more - * than one lcore enabled. - */ - -/* Display recorded statistics. 8< */ -static void -do_stats_display(void) -{ - unsigned int i, j; - const char clr[] = {27, '[', '2', 'J', '\0'}; - const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'}; - uint64_t port_tx[RTE_MAX_ETHPORTS], port_tx_drop[RTE_MAX_ETHPORTS]; - uint64_t node_tx[MAX_NODES], node_tx_drop[MAX_NODES]; - - /* to get TX stats, we need to do some summing calculations */ - memset(port_tx, 0, sizeof(port_tx)); - memset(port_tx_drop, 0, sizeof(port_tx_drop)); - memset(node_tx, 0, sizeof(node_tx)); - memset(node_tx_drop, 0, sizeof(node_tx_drop)); - - for (i = 0; i < num_nodes; i++) { - const struct tx_stats *tx = &info->tx_stats[i]; - - for (j = 0; j < info->num_ports; j++) { - const uint64_t tx_val = tx->tx[info->id[j]]; - const uint64_t drop_val = tx->tx_drop[info->id[j]]; - - port_tx[j] += tx_val; - port_tx_drop[j] += drop_val; - node_tx[i] += tx_val; - node_tx_drop[i] += drop_val; - } - } - - /* Clear screen and move to top left */ - printf("%s%s", clr, topLeft); - - printf("PORTS\n"); - printf("-----\n"); - for (i = 0; i < info->num_ports; i++) - printf("Port %u: '%s'\t", (unsigned int)info->id[i], - get_printable_mac_addr(info->id[i])); - printf("\n\n"); - for (i = 0; i < info->num_ports; i++) { - printf("Port %u - rx: %9"PRIu64"\t" - "tx: %9"PRIu64"\n", - (unsigned int)info->id[i], info->rx_stats.rx[i], - port_tx[i]); - } - - printf("\nSERVER\n"); - printf("-----\n"); - printf("distributed: %9"PRIu64", drop: %9"PRIu64"\n", - flow_dist_stats.distributed, flow_dist_stats.drop); - - printf("\nNODES\n"); - printf("-------\n"); - for (i = 0; i < num_nodes; i++) { - const unsigned long long rx = nodes[i].stats.rx; - const unsigned long long rx_drop = nodes[i].stats.rx_drop; - const struct filter_stats *filter = &info->filter_stats[i]; - - printf("Node %2u - rx: %9llu, rx_drop: %9llu\n" - " tx: %9"PRIu64", tx_drop: %9"PRIu64"\n" - " filter_passed: %9"PRIu64", " - "filter_drop: %9"PRIu64"\n", - i, rx, rx_drop, node_tx[i], node_tx_drop[i], - filter->passed, filter->drop); - } - - printf("\n"); -} -/* >8 End of displaying the recorded statistics. */ - -/* - * The function called from each non-main lcore used by the process. - * The test_and_set function is used to randomly pick a single lcore on which - * the code to display the statistics will run. Otherwise, the code just - * repeatedly sleeps. - */ -static int -sleep_lcore(__rte_unused void *dummy) -{ - /* Used to pick a display thread - static, so zero-initialised */ - static uint32_t display_stats; - - /* Only one core should display stats */ - uint32_t display_init = 0; - if (__atomic_compare_exchange_n(&display_stats, &display_init, 1, 0, - __ATOMIC_RELAXED, __ATOMIC_RELAXED)) { - const unsigned int sleeptime = 1; - - printf("Core %u displaying statistics\n", rte_lcore_id()); - - /* Longer initial pause so above printf is seen */ - sleep(sleeptime * 3); - - /* Loop forever: sleep always returns 0 or <= param */ - while (sleep(sleeptime) <= sleeptime) - do_stats_display(); - } - return 0; -} - -/* - * Function to set all the node statistic values to zero. - * Called at program startup. - */ -static void -clear_stats(void) -{ - unsigned int i; - - for (i = 0; i < num_nodes; i++) - nodes[i].stats.rx = nodes[i].stats.rx_drop = 0; -} - -/* - * send a burst of traffic to a node, assuming there are packets - * available to be sent to this node - */ - -/* Flush rx queue. 8< */ -static void -flush_rx_queue(uint16_t node) -{ - uint16_t j; - struct node *cl; - - if (cl_rx_buf[node].count == 0) - return; - - cl = &nodes[node]; - if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count, NULL) != cl_rx_buf[node].count){ - for (j = 0; j < cl_rx_buf[node].count; j++) - rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); - cl->stats.rx_drop += cl_rx_buf[node].count; - } else - cl->stats.rx += cl_rx_buf[node].count; - - cl_rx_buf[node].count = 0; -} -/* >8 End of sending a burst of traffic to a node. */ - -/* - * marks a packet down to be sent to a particular node process - */ -static inline void -enqueue_rx_packet(uint8_t node, struct rte_mbuf *buf) -{ - cl_rx_buf[node].buffer[cl_rx_buf[node].count++] = buf; -} - -/* - * This function takes a group of packets and routes them - * individually to the node process. Very simply round-robins the packets - * without checking any of the packet contents. 8< - */ - -/* Processing packets. 8< */ -static void -process_packets(uint32_t port_num __rte_unused, struct rte_mbuf *pkts[], - uint16_t rx_count, unsigned int socket_id) -{ - uint16_t i; - uint8_t node; - efd_value_t data[RTE_EFD_BURST_MAX]; - const void *key_ptrs[RTE_EFD_BURST_MAX]; - - struct rte_ipv4_hdr *ipv4_hdr; - uint32_t ipv4_dst_ip[RTE_EFD_BURST_MAX]; - - for (i = 0; i < rx_count; i++) { - /* Handle IPv4 header.*/ - ipv4_hdr = rte_pktmbuf_mtod_offset(pkts[i], - struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); - ipv4_dst_ip[i] = ipv4_hdr->dst_addr; - key_ptrs[i] = (void *)&ipv4_dst_ip[i]; - } - - rte_efd_lookup_bulk(efd_table, socket_id, rx_count, - (const void **) key_ptrs, data); - for (i = 0; i < rx_count; i++) { - node = (uint8_t) ((uintptr_t)data[i]); - - if (node >= num_nodes) { - /* - * Node is out of range, which means that - * flow has not been inserted - */ - flow_dist_stats.drop++; - rte_pktmbuf_free(pkts[i]); - } else { - flow_dist_stats.distributed++; - enqueue_rx_packet(node, pkts[i]); - } - } - - for (i = 0; i < num_nodes; i++) - flush_rx_queue(i); -} -/* >8 End of process_packets. */ - -/* - * Function called by the main lcore of the DPDK process. - */ -static void -do_packet_forwarding(void) -{ - unsigned int port_num = 0; /* indexes the port[] array */ - unsigned int socket_id = rte_socket_id(); - - for (;;) { - struct rte_mbuf *buf[PACKET_READ_SIZE]; - uint16_t rx_count; - - /* read a port */ - rx_count = rte_eth_rx_burst(info->id[port_num], 0, - buf, PACKET_READ_SIZE); - info->rx_stats.rx[port_num] += rx_count; - - /* Now process the NIC packets read */ - if (likely(rx_count > 0)) - process_packets(port_num, buf, rx_count, socket_id); - - /* move to next port */ - if (++port_num == info->num_ports) - port_num = 0; - } -} - -int -main(int argc, char *argv[]) -{ - /* initialise the system */ - if (init(argc, argv) < 0) - return -1; - RTE_LOG(INFO, APP, "Finished Process Init.\n"); - - cl_rx_buf = calloc(num_nodes, sizeof(cl_rx_buf[0])); - - /* clear statistics */ - clear_stats(); - - /* put all other cores to sleep except main */ - rte_eal_mp_remote_launch(sleep_lcore, NULL, SKIP_MAIN); - - do_packet_forwarding(); - - /* clean up the EAL */ - rte_eal_cleanup(); - - return 0; -} diff --git a/dpdk/examples/server_node_efd/server/meson.build b/dpdk/examples/server_node_efd/server/meson.build deleted file mode 100644 index 7abc333e1..000000000 --- a/dpdk/examples/server_node_efd/server/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2019 Intel Corporation - -# meson file, for building this example as part of a main DPDK build. -# -# To build this example as a standalone application with an already-installed -# DPDK instance, use 'make' - -name = 'efd_server' - -allow_experimental_apis = true -deps += 'efd' -sources += files('args.c', 'init.c', 'main.c') -includes += include_directories('../shared') diff --git a/dpdk/kernel/linux/igb_uio/Kbuild b/dpdk/kernel/linux/igb_uio/Kbuild deleted file mode 100644 index 3ab85c411..000000000 --- a/dpdk/kernel/linux/igb_uio/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -ccflags-y := $(MODULE_CFLAGS) -obj-m := igb_uio.o diff --git a/dpdk/kernel/linux/igb_uio/Makefile b/dpdk/kernel/linux/igb_uio/Makefile deleted file mode 100644 index bd2e356c0..000000000 --- a/dpdk/kernel/linux/igb_uio/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -KSRC ?= /lib/modules/$(shell uname -r)/build - -all: - make -C $(KSRC)/ M=$(CURDIR) - -%: - make -C $(KSRC)/ M=$(CURDIR) $@ diff --git a/dpdk/kernel/linux/igb_uio/compat.h b/dpdk/kernel/linux/igb_uio/compat.h deleted file mode 100644 index 71172f40c..000000000 --- a/dpdk/kernel/linux/igb_uio/compat.h +++ /dev/null @@ -1,168 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Minimal wrappers to allow compiling igb_uio on older kernels. - */ - -#ifndef RHEL_RELEASE_VERSION -#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b)) -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) -#define pci_cfg_access_lock pci_block_user_cfg_access -#define pci_cfg_access_unlock pci_unblock_user_cfg_access -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) -#define HAVE_PTE_MASK_PAGE_IOMAP -#endif - -#ifndef PCI_MSIX_ENTRY_SIZE -#define PCI_MSIX_ENTRY_SIZE 16 -#define PCI_MSIX_ENTRY_VECTOR_CTRL 12 -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 -#endif - -/* - * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition - * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not - * PCI_MSIX_ENTRY_CTRL_MASKBIT - */ -#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \ - (!(defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9))) - -static int pci_num_vf(struct pci_dev *dev) -{ - struct iov { - int pos; - int nres; - u32 cap; - u16 ctrl; - u16 total; - u16 initial; - u16 nr_virtfn; - } *iov = (struct iov *)dev->sriov; - - if (!dev->is_physfn) - return 0; - - return iov->nr_virtfn; -} - -#endif /* < 2.6.34 */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \ - (!(defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4))) - -#define kstrtoul strict_strtoul - -#endif /* < 2.6.39 */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && \ - (!(defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 3))) - -/* Check if INTX works to control irq's. - * Set's INTX_DISABLE flag and reads it back - */ -static bool pci_intx_mask_supported(struct pci_dev *pdev) -{ - bool mask_supported = false; - uint16_t orig, new; - - pci_block_user_cfg_access(pdev); - pci_read_config_word(pdev, PCI_COMMAND, &orig); - pci_write_config_word(pdev, PCI_COMMAND, - orig ^ PCI_COMMAND_INTX_DISABLE); - pci_read_config_word(pdev, PCI_COMMAND, &new); - - if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) { - dev_err(&pdev->dev, "Command register changed from " - "0x%x to 0x%x: driver or hardware bug?\n", orig, new); - } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) { - mask_supported = true; - pci_write_config_word(pdev, PCI_COMMAND, orig); - } - pci_unblock_user_cfg_access(pdev); - - return mask_supported; -} - -static bool pci_check_and_mask_intx(struct pci_dev *pdev) -{ - bool pending; - uint32_t status; - - pci_block_user_cfg_access(pdev); - pci_read_config_dword(pdev, PCI_COMMAND, &status); - - /* interrupt is not ours, goes to out */ - pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0); - if (pending) { - uint16_t old, new; - - old = status; - if (status != 0) - new = old & (~PCI_COMMAND_INTX_DISABLE); - else - new = old | PCI_COMMAND_INTX_DISABLE; - - if (old != new) - pci_write_config_word(pdev, PCI_COMMAND, new); - } - pci_unblock_user_cfg_access(pdev); - - return pending; -} - -#endif /* < 3.3.0 */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) -#define HAVE_PCI_IS_BRIDGE_API 1 -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) -#define HAVE_MSI_LIST_IN_GENERIC_DEVICE 1 -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) -#define HAVE_PCI_MSI_MASK_IRQ 1 -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) -#define HAVE_ALLOC_IRQ_VECTORS 1 -#endif - -static inline bool igbuio_kernel_is_locked_down(void) -{ -#ifdef CONFIG_LOCK_DOWN_KERNEL -#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT - return kernel_is_locked_down(NULL); -#elif defined(CONFIG_EFI_SECURE_BOOT_LOCK_DOWN) - return kernel_is_locked_down(); -#else - return false; -#endif -#else - return false; -#endif -} - -#ifndef fallthrough - -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif - -#if __has_attribute(__fallthrough__) -#define fallthrough __attribute__((__fallthrough__)) -#else -#define fallthrough do {} while (0) /* fallthrough */ -#endif - -#endif diff --git a/dpdk/kernel/linux/igb_uio/igb_uio.c b/dpdk/kernel/linux/igb_uio/igb_uio.c deleted file mode 100644 index aea67dac4..000000000 --- a/dpdk/kernel/linux/igb_uio/igb_uio.c +++ /dev/null @@ -1,668 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/*- - * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * These enum and macro definitions are copied from the - * file rte_pci_dev_features.h - */ -enum rte_intr_mode { - RTE_INTR_MODE_NONE = 0, - RTE_INTR_MODE_LEGACY, - RTE_INTR_MODE_MSI, - RTE_INTR_MODE_MSIX -}; -#define RTE_INTR_MODE_NONE_NAME "none" -#define RTE_INTR_MODE_LEGACY_NAME "legacy" -#define RTE_INTR_MODE_MSI_NAME "msi" -#define RTE_INTR_MODE_MSIX_NAME "msix" - - -#include "compat.h" - -/** - * A structure describing the private information for a uio device. - */ -struct rte_uio_pci_dev { - struct uio_info info; - struct pci_dev *pdev; - enum rte_intr_mode mode; - atomic_t refcnt; -}; - -static int wc_activate; -static char *intr_mode; -static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; -/* sriov sysfs */ -static ssize_t -show_max_vfs(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return snprintf(buf, 10, "%u\n", dev_num_vf(dev)); -} - -static ssize_t -store_max_vfs(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int err = 0; - unsigned long max_vfs; - struct pci_dev *pdev = to_pci_dev(dev); - - if (0 != kstrtoul(buf, 0, &max_vfs)) - return -EINVAL; - - if (0 == max_vfs) - pci_disable_sriov(pdev); - else if (0 == pci_num_vf(pdev)) - err = pci_enable_sriov(pdev, max_vfs); - else /* do nothing if change max_vfs number */ - err = -EINVAL; - - return err ? err : count; -} - -static DEVICE_ATTR(max_vfs, S_IRUGO | S_IWUSR, show_max_vfs, store_max_vfs); - -static struct attribute *dev_attrs[] = { - &dev_attr_max_vfs.attr, - NULL, -}; - -static const struct attribute_group dev_attr_grp = { - .attrs = dev_attrs, -}; - -#ifndef HAVE_PCI_MSI_MASK_IRQ -/* - * It masks the msix on/off of generating MSI-X messages. - */ -static void -igbuio_msix_mask_irq(struct msi_desc *desc, s32 state) -{ - u32 mask_bits = desc->masked; - unsigned int offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + - PCI_MSIX_ENTRY_VECTOR_CTRL; - - if (state != 0) - mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; - else - mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT; - - if (mask_bits != desc->masked) { - writel(mask_bits, desc->mask_base + offset); - readl(desc->mask_base); - desc->masked = mask_bits; - } -} - -/* - * It masks the msi on/off of generating MSI messages. - */ -static void -igbuio_msi_mask_irq(struct pci_dev *pdev, struct msi_desc *desc, int32_t state) -{ - u32 mask_bits = desc->masked; - u32 offset = desc->irq - pdev->irq; - u32 mask = 1 << offset; - - if (!desc->msi_attrib.maskbit) - return; - - if (state != 0) - mask_bits &= ~mask; - else - mask_bits |= mask; - - if (mask_bits != desc->masked) { - pci_write_config_dword(pdev, desc->mask_pos, mask_bits); - desc->masked = mask_bits; - } -} - -static void -igbuio_mask_irq(struct pci_dev *pdev, enum rte_intr_mode mode, s32 irq_state) -{ - struct msi_desc *desc; - struct list_head *msi_list; - -#ifdef HAVE_MSI_LIST_IN_GENERIC_DEVICE - msi_list = &pdev->dev.msi_list; -#else - msi_list = &pdev->msi_list; -#endif - - if (mode == RTE_INTR_MODE_MSIX) { - list_for_each_entry(desc, msi_list, list) - igbuio_msix_mask_irq(desc, irq_state); - } else if (mode == RTE_INTR_MODE_MSI) { - list_for_each_entry(desc, msi_list, list) - igbuio_msi_mask_irq(pdev, desc, irq_state); - } -} -#endif - -/** - * This is the irqcontrol callback to be registered to uio_info. - * It can be used to disable/enable interrupt from user space processes. - * - * @param info - * pointer to uio_info. - * @param irq_state - * state value. 1 to enable interrupt, 0 to disable interrupt. - * - * @return - * - On success, 0. - * - On failure, a negative value. - */ -static int -igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) -{ - struct rte_uio_pci_dev *udev = info->priv; - struct pci_dev *pdev = udev->pdev; - -#ifdef HAVE_PCI_MSI_MASK_IRQ - struct irq_data *irq = irq_get_irq_data(udev->info.irq); -#endif - - pci_cfg_access_lock(pdev); - - if (udev->mode == RTE_INTR_MODE_MSIX || udev->mode == RTE_INTR_MODE_MSI) { -#ifdef HAVE_PCI_MSI_MASK_IRQ - if (irq_state == 1) - pci_msi_unmask_irq(irq); - else - pci_msi_mask_irq(irq); -#else - igbuio_mask_irq(pdev, udev->mode, irq_state); -#endif - } - - if (udev->mode == RTE_INTR_MODE_LEGACY) - pci_intx(pdev, !!irq_state); - - pci_cfg_access_unlock(pdev); - - return 0; -} - -/** - * This is interrupt handler which will check if the interrupt is for the right device. - * If yes, disable it here and will be enable later. - */ -static irqreturn_t -igbuio_pci_irqhandler(int irq, void *dev_id) -{ - struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id; - struct uio_info *info = &udev->info; - - /* Legacy mode need to mask in hardware */ - if (udev->mode == RTE_INTR_MODE_LEGACY && - !pci_check_and_mask_intx(udev->pdev)) - return IRQ_NONE; - - uio_event_notify(info); - - /* Message signal mode, no share IRQ and automasked */ - return IRQ_HANDLED; -} - -static int -igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) -{ - int err = 0; -#ifndef HAVE_ALLOC_IRQ_VECTORS - struct msix_entry msix_entry; -#endif - - switch (igbuio_intr_mode_preferred) { - case RTE_INTR_MODE_MSIX: - /* Only 1 msi-x vector needed */ -#ifndef HAVE_ALLOC_IRQ_VECTORS - msix_entry.entry = 0; - if (pci_enable_msix(udev->pdev, &msix_entry, 1) == 0) { - dev_dbg(&udev->pdev->dev, "using MSI-X"); - udev->info.irq_flags = IRQF_NO_THREAD; - udev->info.irq = msix_entry.vector; - udev->mode = RTE_INTR_MODE_MSIX; - break; - } -#else - if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSIX) == 1) { - dev_dbg(&udev->pdev->dev, "using MSI-X"); - udev->info.irq_flags = IRQF_NO_THREAD; - udev->info.irq = pci_irq_vector(udev->pdev, 0); - udev->mode = RTE_INTR_MODE_MSIX; - break; - } -#endif - - fallthrough; - case RTE_INTR_MODE_MSI: -#ifndef HAVE_ALLOC_IRQ_VECTORS - if (pci_enable_msi(udev->pdev) == 0) { - dev_dbg(&udev->pdev->dev, "using MSI"); - udev->info.irq_flags = IRQF_NO_THREAD; - udev->info.irq = udev->pdev->irq; - udev->mode = RTE_INTR_MODE_MSI; - break; - } -#else - if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSI) == 1) { - dev_dbg(&udev->pdev->dev, "using MSI"); - udev->info.irq_flags = IRQF_NO_THREAD; - udev->info.irq = pci_irq_vector(udev->pdev, 0); - udev->mode = RTE_INTR_MODE_MSI; - break; - } -#endif - fallthrough; - case RTE_INTR_MODE_LEGACY: - if (pci_intx_mask_supported(udev->pdev)) { - dev_dbg(&udev->pdev->dev, "using INTX"); - udev->info.irq_flags = IRQF_SHARED | IRQF_NO_THREAD; - udev->info.irq = udev->pdev->irq; - udev->mode = RTE_INTR_MODE_LEGACY; - break; - } - dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n"); - fallthrough; - case RTE_INTR_MODE_NONE: - udev->mode = RTE_INTR_MODE_NONE; - udev->info.irq = UIO_IRQ_NONE; - break; - - default: - dev_err(&udev->pdev->dev, "invalid IRQ mode %u", - igbuio_intr_mode_preferred); - udev->info.irq = UIO_IRQ_NONE; - err = -EINVAL; - } - - if (udev->info.irq != UIO_IRQ_NONE) - err = request_irq(udev->info.irq, igbuio_pci_irqhandler, - udev->info.irq_flags, udev->info.name, - udev); - dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n", - udev->info.irq); - - return err; -} - -static void -igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev) -{ - if (udev->info.irq) { - free_irq(udev->info.irq, udev); - udev->info.irq = 0; - } - -#ifndef HAVE_ALLOC_IRQ_VECTORS - if (udev->mode == RTE_INTR_MODE_MSIX) - pci_disable_msix(udev->pdev); - if (udev->mode == RTE_INTR_MODE_MSI) - pci_disable_msi(udev->pdev); -#else - if (udev->mode == RTE_INTR_MODE_MSIX || - udev->mode == RTE_INTR_MODE_MSI) - pci_free_irq_vectors(udev->pdev); -#endif -} - - -/** - * This gets called while opening uio device file. - */ -static int -igbuio_pci_open(struct uio_info *info, struct inode *inode) -{ - struct rte_uio_pci_dev *udev = info->priv; - struct pci_dev *dev = udev->pdev; - int err; - - if (atomic_inc_return(&udev->refcnt) != 1) - return 0; - - /* set bus master, which was cleared by the reset function */ - pci_set_master(dev); - - /* enable interrupts */ - err = igbuio_pci_enable_interrupts(udev); - if (err) { - atomic_dec(&udev->refcnt); - dev_err(&dev->dev, "Enable interrupt fails\n"); - } - return err; -} - -static int -igbuio_pci_release(struct uio_info *info, struct inode *inode) -{ - struct rte_uio_pci_dev *udev = info->priv; - struct pci_dev *dev = udev->pdev; - - if (atomic_dec_and_test(&udev->refcnt)) { - /* disable interrupts */ - igbuio_pci_disable_interrupts(udev); - - /* stop the device from further DMA */ - pci_clear_master(dev); - } - - return 0; -} - -/* Remap pci resources described by bar #pci_bar in uio resource n. */ -static int -igbuio_pci_setup_iomem(struct pci_dev *dev, struct uio_info *info, - int n, int pci_bar, const char *name) -{ - unsigned long addr, len; - void *internal_addr; - - if (n >= ARRAY_SIZE(info->mem)) - return -EINVAL; - - addr = pci_resource_start(dev, pci_bar); - len = pci_resource_len(dev, pci_bar); - if (addr == 0 || len == 0) - return -1; - if (wc_activate == 0) { - internal_addr = ioremap(addr, len); - if (internal_addr == NULL) - return -1; - } else { - internal_addr = NULL; - } - info->mem[n].name = name; - info->mem[n].addr = addr; - info->mem[n].internal_addr = internal_addr; - info->mem[n].size = len; - info->mem[n].memtype = UIO_MEM_PHYS; - return 0; -} - -/* Get pci port io resources described by bar #pci_bar in uio resource n. */ -static int -igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info, - int n, int pci_bar, const char *name) -{ - unsigned long addr, len; - - if (n >= ARRAY_SIZE(info->port)) - return -EINVAL; - - addr = pci_resource_start(dev, pci_bar); - len = pci_resource_len(dev, pci_bar); - if (addr == 0 || len == 0) - return -EINVAL; - - info->port[n].name = name; - info->port[n].start = addr; - info->port[n].size = len; - info->port[n].porttype = UIO_PORT_X86; - - return 0; -} - -/* Unmap previously ioremap'd resources */ -static void -igbuio_pci_release_iomem(struct uio_info *info) -{ - int i; - - for (i = 0; i < MAX_UIO_MAPS; i++) { - if (info->mem[i].internal_addr) - iounmap(info->mem[i].internal_addr); - } -} - -static int -igbuio_setup_bars(struct pci_dev *dev, struct uio_info *info) -{ - int i, iom, iop, ret; - unsigned long flags; - static const char *bar_names[PCI_STD_RESOURCE_END + 1] = { - "BAR0", - "BAR1", - "BAR2", - "BAR3", - "BAR4", - "BAR5", - }; - - iom = 0; - iop = 0; - - for (i = 0; i < ARRAY_SIZE(bar_names); i++) { - if (pci_resource_len(dev, i) != 0 && - pci_resource_start(dev, i) != 0) { - flags = pci_resource_flags(dev, i); - if (flags & IORESOURCE_MEM) { - ret = igbuio_pci_setup_iomem(dev, info, iom, - i, bar_names[i]); - if (ret != 0) - return ret; - iom++; - } else if (flags & IORESOURCE_IO) { - ret = igbuio_pci_setup_ioport(dev, info, iop, - i, bar_names[i]); - if (ret != 0) - return ret; - iop++; - } - } - } - - return (iom != 0 || iop != 0) ? ret : -ENOENT; -} - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) -static int __devinit -#else -static int -#endif -igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) -{ - struct rte_uio_pci_dev *udev; - dma_addr_t map_dma_addr; - void *map_addr; - int err; - -#ifdef HAVE_PCI_IS_BRIDGE_API - if (pci_is_bridge(dev)) { - dev_warn(&dev->dev, "Ignoring PCI bridge device\n"); - return -ENODEV; - } -#endif - - udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL); - if (!udev) - return -ENOMEM; - - /* - * enable device: ask low-level code to enable I/O and - * memory - */ - err = pci_enable_device(dev); - if (err != 0) { - dev_err(&dev->dev, "Cannot enable PCI device\n"); - goto fail_free; - } - - /* enable bus mastering on the device */ - pci_set_master(dev); - - /* remap IO memory */ - err = igbuio_setup_bars(dev, &udev->info); - if (err != 0) - goto fail_release_iomem; - - /* set 64-bit DMA mask */ - err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)); - if (err != 0) { - dev_err(&dev->dev, "Cannot set DMA mask\n"); - goto fail_release_iomem; - } - - /* fill uio infos */ - udev->info.name = "igb_uio"; - udev->info.version = "0.1"; - udev->info.irqcontrol = igbuio_pci_irqcontrol; - udev->info.open = igbuio_pci_open; - udev->info.release = igbuio_pci_release; - udev->info.priv = udev; - udev->pdev = dev; - atomic_set(&udev->refcnt, 0); - - err = sysfs_create_group(&dev->dev.kobj, &dev_attr_grp); - if (err != 0) - goto fail_release_iomem; - - /* register uio driver */ - err = uio_register_device(&dev->dev, &udev->info); - if (err != 0) - goto fail_remove_group; - - pci_set_drvdata(dev, udev); - - /* - * Doing a harmless dma mapping for attaching the device to - * the iommu identity mapping if kernel boots with iommu=pt. - * Note this is not a problem if no IOMMU at all. - */ - map_addr = dma_alloc_coherent(&dev->dev, 1024, &map_dma_addr, - GFP_KERNEL); - if (map_addr) - memset(map_addr, 0, 1024); - - if (!map_addr) - dev_info(&dev->dev, "dma mapping failed\n"); - else { - dev_info(&dev->dev, "mapping 1K dma=%#llx host=%p\n", - (unsigned long long)map_dma_addr, map_addr); - - dma_free_coherent(&dev->dev, 1024, map_addr, map_dma_addr); - dev_info(&dev->dev, "unmapping 1K dma=%#llx host=%p\n", - (unsigned long long)map_dma_addr, map_addr); - } - - return 0; - -fail_remove_group: - sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); -fail_release_iomem: - igbuio_pci_release_iomem(&udev->info); - pci_disable_device(dev); -fail_free: - kfree(udev); - - return err; -} - -static void -igbuio_pci_remove(struct pci_dev *dev) -{ - struct rte_uio_pci_dev *udev = pci_get_drvdata(dev); - - igbuio_pci_release(&udev->info, NULL); - - sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); - uio_unregister_device(&udev->info); - igbuio_pci_release_iomem(&udev->info); - pci_disable_device(dev); - pci_set_drvdata(dev, NULL); - kfree(udev); -} - -static int -igbuio_config_intr_mode(char *intr_str) -{ - if (!intr_str) { - pr_info("Use MSIX interrupt by default\n"); - return 0; - } - - if (!strcmp(intr_str, RTE_INTR_MODE_MSIX_NAME)) { - igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; - pr_info("Use MSIX interrupt\n"); - } else if (!strcmp(intr_str, RTE_INTR_MODE_MSI_NAME)) { - igbuio_intr_mode_preferred = RTE_INTR_MODE_MSI; - pr_info("Use MSI interrupt\n"); - } else if (!strcmp(intr_str, RTE_INTR_MODE_LEGACY_NAME)) { - igbuio_intr_mode_preferred = RTE_INTR_MODE_LEGACY; - pr_info("Use legacy interrupt\n"); - } else { - pr_info("Error: bad parameter - %s\n", intr_str); - return -EINVAL; - } - - return 0; -} - -static struct pci_driver igbuio_pci_driver = { - .name = "igb_uio", - .id_table = NULL, - .probe = igbuio_pci_probe, - .remove = igbuio_pci_remove, -}; - -static int __init -igbuio_pci_init_module(void) -{ - int ret; - - if (igbuio_kernel_is_locked_down()) { - pr_err("Not able to use module, kernel lock down is enabled\n"); - return -EINVAL; - } - - if (wc_activate != 0) - pr_info("wc_activate is set\n"); - - ret = igbuio_config_intr_mode(intr_mode); - if (ret < 0) - return ret; - - return pci_register_driver(&igbuio_pci_driver); -} - -static void __exit -igbuio_pci_exit_module(void) -{ - pci_unregister_driver(&igbuio_pci_driver); -} - -module_init(igbuio_pci_init_module); -module_exit(igbuio_pci_exit_module); - -module_param(intr_mode, charp, S_IRUGO); -MODULE_PARM_DESC(intr_mode, -"igb_uio interrupt mode (default=msix):\n" -" " RTE_INTR_MODE_MSIX_NAME " Use MSIX interrupt\n" -" " RTE_INTR_MODE_MSI_NAME " Use MSI interrupt\n" -" " RTE_INTR_MODE_LEGACY_NAME " Use Legacy interrupt\n" -"\n"); - -module_param(wc_activate, int, 0); -MODULE_PARM_DESC(wc_activate, -"Activate support for write combining (WC) (default=0)\n" -" 0 - disable\n" -" other - enable\n"); - -MODULE_DESCRIPTION("UIO driver for Intel IGB PCI cards"); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Intel Corporation"); diff --git a/dpdk/kernel/linux/igb_uio/meson.build b/dpdk/kernel/linux/igb_uio/meson.build deleted file mode 100644 index f6e04d585..000000000 --- a/dpdk/kernel/linux/igb_uio/meson.build +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -mkfile = custom_target('igb_uio_makefile', - output: 'Makefile', - command: ['touch', '@OUTPUT@']) - -custom_target('igb_uio', - input: ['igb_uio.c', 'Kbuild'], - output: 'igb_uio.ko', - command: ['make', '-C', kernel_build_dir, - 'M=' + meson.current_build_dir(), - 'src=' + meson.current_source_dir(), - 'EXTRA_CFLAGS=-I' + meson.current_source_dir() + - '/../../../lib/librte_eal/include', - 'modules'], - depends: mkfile, - install: true, - install_dir: kernel_build_dir + '/extra/dpdk', - build_by_default: get_option('enable_kmods')) diff --git a/dpdk/kernel/linux/kni/Kbuild b/dpdk/kernel/linux/kni/Kbuild deleted file mode 100644 index e5452d6c0..000000000 --- a/dpdk/kernel/linux/kni/Kbuild +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2018 Luca Boccassi - -ccflags-y := $(MODULE_CFLAGS) -obj-m := rte_kni.o -rte_kni-y := $(patsubst $(src)/%.c,%.o,$(wildcard $(src)/*.c)) diff --git a/dpdk/kernel/linux/kni/compat.h b/dpdk/kernel/linux/kni/compat.h deleted file mode 100644 index 8beb67046..000000000 --- a/dpdk/kernel/linux/kni/compat.h +++ /dev/null @@ -1,157 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Minimal wrappers to allow compiling kni on older kernels. - */ - -#include - -#ifndef RHEL_RELEASE_VERSION -#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b)) -#endif - -/* SuSE version macro is the same as Linux kernel version */ -#ifndef SLE_VERSION -#define SLE_VERSION(a, b, c) KERNEL_VERSION(a, b, c) -#endif -#ifdef CONFIG_SUSE_KERNEL -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 57)) -/* SLES12SP3 is at least 4.4.57+ based */ -#define SLE_VERSION_CODE SLE_VERSION(12, 3, 0) -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 28)) -/* SLES12 is at least 3.12.28+ based */ -#define SLE_VERSION_CODE SLE_VERSION(12, 0, 0) -#elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 61)) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0))) -/* SLES11 SP3 is at least 3.0.61+ based */ -#define SLE_VERSION_CODE SLE_VERSION(11, 3, 0) -#elif (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 32)) -/* SLES11 SP1 is 2.6.32 based */ -#define SLE_VERSION_CODE SLE_VERSION(11, 1, 0) -#elif (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 27)) -/* SLES11 GA is 2.6.27 based */ -#define SLE_VERSION_CODE SLE_VERSION(11, 0, 0) -#endif /* LINUX_VERSION_CODE == KERNEL_VERSION(x,y,z) */ -#endif /* CONFIG_SUSE_KERNEL */ -#ifndef SLE_VERSION_CODE -#define SLE_VERSION_CODE 0 -#endif /* SLE_VERSION_CODE */ - - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \ - (!(defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4))) - -#define kstrtoul strict_strtoul - -#endif /* < 2.6.39 */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33) -#define HAVE_SIMPLIFIED_PERNET_OPERATIONS -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) -#define sk_sleep(s) ((s)->sk_sleep) -#else -#define HAVE_SOCKET_WQ -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) -#define HAVE_STATIC_SOCK_MAP_FD -#else -#define kni_sock_map_fd(s) sock_map_fd(s, 0) -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) -#define HAVE_CHANGE_CARRIER_CB -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) -#define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN) -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) -#define HAVE_IOV_ITER_MSGHDR -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0) -#define HAVE_KIOCB_MSG_PARAM -#define HAVE_REBUILD_HEADER -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) -#define HAVE_SK_ALLOC_KERN_PARAM -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || \ - (defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 4)) || \ - (SLE_VERSION_CODE && SLE_VERSION_CODE == SLE_VERSION(12, 3, 0)) -#define HAVE_TRANS_START_HELPER -#endif - -/* - * KNI uses NET_NAME_UNKNOWN macro to select correct version of alloc_netdev() - * For old kernels just backported the commit that enables the macro - * (685343fc3ba6) but still uses old API, it is required to undefine macro to - * select correct version of API, this is safe since KNI doesn't use the value. - * This fix is specific to RedHat/CentOS kernels. - */ -#if (defined(RHEL_RELEASE_CODE) && \ - (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 8)) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34))) -#undef NET_NAME_UNKNOWN -#endif - -/* - * RHEL has two different version with different kernel version: - * 3.10 is for AMD, Intel, IBM POWER7 and POWER8; - * 4.14 is for ARM and IBM POWER9 - */ -#if (defined(RHEL_RELEASE_CODE) && \ - (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 5)) && \ - (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 0)) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))) -#define ndo_change_mtu ndo_change_mtu_rh74 -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) -#define HAVE_MAX_MTU_PARAM -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) -#define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER -#endif - -/* - * iova to kva mapping support can be provided since 4.6.0, but required - * kernel version increased to >= 4.10.0 because of the updates in - * get_user_pages_remote() kernel API - */ -#if KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE -#define HAVE_IOVA_TO_KVA_MAPPING_SUPPORT -#endif - -#if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE || \ - (defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_VERSION(8, 3) <= RHEL_RELEASE_CODE) || \ - (defined(CONFIG_SUSE_KERNEL) && defined(HAVE_ARG_TX_QUEUE)) -#define HAVE_TX_TIMEOUT_TXQUEUE -#endif - -#if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE -#define HAVE_TSK_IN_GUP -#endif - -#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE -#define HAVE_ETH_HW_ADDR_SET -#endif - -#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE && \ - (!(defined(RHEL_RELEASE_CODE) && \ - RHEL_RELEASE_VERSION(9, 1) <= RHEL_RELEASE_CODE)) -#define HAVE_NETIF_RX_NI -#endif - -#if KERNEL_VERSION(6, 5, 0) > LINUX_VERSION_CODE -#define HAVE_VMA_IN_GUP -#endif diff --git a/dpdk/kernel/linux/kni/kni_dev.h b/dpdk/kernel/linux/kni/kni_dev.h deleted file mode 100644 index 975379825..000000000 --- a/dpdk/kernel/linux/kni/kni_dev.h +++ /dev/null @@ -1,137 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright(c) 2010-2014 Intel Corporation. - */ - -#ifndef _KNI_DEV_H_ -#define _KNI_DEV_H_ - -#ifdef pr_fmt -#undef pr_fmt -#endif -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#define KNI_VERSION "1.0" - -#include "compat.h" - -#include -#include -#ifdef HAVE_SIGNAL_FUNCTIONS_OWN_HEADER -#include -#else -#include -#endif -#include -#include -#include - -#include -#define KNI_KTHREAD_MAX_RESCHEDULE_INTERVAL 1000000 /* us */ - -#define MBUF_BURST_SZ 32 - -/* Default carrier state for created KNI network interfaces */ -extern uint32_t kni_dflt_carrier; - -/* Request processing support for bifurcated drivers. */ -extern uint32_t bifurcated_support; - -/** - * A structure describing the private information for a kni device. - */ -struct kni_dev { - /* kni list */ - struct list_head list; - - uint8_t iova_mode; - - uint32_t core_id; /* Core ID to bind */ - char name[RTE_KNI_NAMESIZE]; /* Network device name */ - struct task_struct *pthread; - - /* wait queue for req/resp */ - wait_queue_head_t wq; - struct mutex sync_lock; - - /* kni device */ - struct net_device *net_dev; - - /* queue for packets to be sent out */ - struct rte_kni_fifo *tx_q; - - /* queue for the packets received */ - struct rte_kni_fifo *rx_q; - - /* queue for the allocated mbufs those can be used to save sk buffs */ - struct rte_kni_fifo *alloc_q; - - /* free queue for the mbufs to be freed */ - struct rte_kni_fifo *free_q; - - /* request queue */ - struct rte_kni_fifo *req_q; - - /* response queue */ - struct rte_kni_fifo *resp_q; - - void *sync_kva; - void *sync_va; - - void *mbuf_kva; - void *mbuf_va; - - /* mbuf size */ - uint32_t mbuf_size; - - /* buffers */ - void *pa[MBUF_BURST_SZ]; - void *va[MBUF_BURST_SZ]; - void *alloc_pa[MBUF_BURST_SZ]; - void *alloc_va[MBUF_BURST_SZ]; - - struct task_struct *usr_tsk; -}; - -#ifdef HAVE_IOVA_TO_KVA_MAPPING_SUPPORT -static inline phys_addr_t iova_to_phys(struct task_struct *tsk, - unsigned long iova) -{ - phys_addr_t offset, phys_addr; - struct page *page = NULL; - long ret; - - offset = iova & (PAGE_SIZE - 1); - - /* Read one page struct info */ -#ifdef HAVE_TSK_IN_GUP - ret = get_user_pages_remote(tsk, tsk->mm, iova, 1, 0, &page, NULL, NULL); -#else - #ifdef HAVE_VMA_IN_GUP - ret = get_user_pages_remote(tsk->mm, iova, 1, 0, &page, NULL, NULL); - #else - ret = get_user_pages_remote(tsk->mm, iova, 1, 0, &page, NULL); - #endif -#endif - if (ret < 0) - return 0; - - phys_addr = page_to_phys(page) | offset; - put_page(page); - - return phys_addr; -} - -static inline void *iova_to_kva(struct task_struct *tsk, unsigned long iova) -{ - return phys_to_virt(iova_to_phys(tsk, iova)); -} -#endif - -void kni_net_release_fifo_phy(struct kni_dev *kni); -void kni_net_rx(struct kni_dev *kni); -void kni_net_init(struct net_device *dev); -void kni_net_config_lo_mode(char *lo_str); -void kni_net_poll_resp(struct kni_dev *kni); - -#endif diff --git a/dpdk/kernel/linux/kni/kni_fifo.h b/dpdk/kernel/linux/kni/kni_fifo.h deleted file mode 100644 index 1ba517200..000000000 --- a/dpdk/kernel/linux/kni/kni_fifo.h +++ /dev/null @@ -1,87 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright(c) 2010-2014 Intel Corporation. - */ - -#ifndef _KNI_FIFO_H_ -#define _KNI_FIFO_H_ - -#include - -/* Skip some memory barriers on Linux < 3.14 */ -#ifndef smp_load_acquire -#define smp_load_acquire(a) (*(a)) -#endif -#ifndef smp_store_release -#define smp_store_release(a, b) *(a) = (b) -#endif - -/** - * Adds num elements into the fifo. Return the number actually written - */ -static inline uint32_t -kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num) -{ - uint32_t i = 0; - uint32_t fifo_write = fifo->write; - uint32_t fifo_read = smp_load_acquire(&fifo->read); - uint32_t new_write = fifo_write; - - for (i = 0; i < num; i++) { - new_write = (new_write + 1) & (fifo->len - 1); - - if (new_write == fifo_read) - break; - fifo->buffer[fifo_write] = data[i]; - fifo_write = new_write; - } - smp_store_release(&fifo->write, fifo_write); - - return i; -} - -/** - * Get up to num elements from the FIFO. Return the number actually read - */ -static inline uint32_t -kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num) -{ - uint32_t i = 0; - uint32_t new_read = fifo->read; - uint32_t fifo_write = smp_load_acquire(&fifo->write); - - for (i = 0; i < num; i++) { - if (new_read == fifo_write) - break; - - data[i] = fifo->buffer[new_read]; - new_read = (new_read + 1) & (fifo->len - 1); - } - smp_store_release(&fifo->read, new_read); - - return i; -} - -/** - * Get the num of elements in the fifo - */ -static inline uint32_t -kni_fifo_count(struct rte_kni_fifo *fifo) -{ - uint32_t fifo_write = smp_load_acquire(&fifo->write); - uint32_t fifo_read = smp_load_acquire(&fifo->read); - return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1); -} - -/** - * Get the num of available elements in the fifo - */ -static inline uint32_t -kni_fifo_free_count(struct rte_kni_fifo *fifo) -{ - uint32_t fifo_write = smp_load_acquire(&fifo->write); - uint32_t fifo_read = smp_load_acquire(&fifo->read); - return (fifo_read - fifo_write - 1) & (fifo->len - 1); -} - -#endif /* _KNI_FIFO_H_ */ diff --git a/dpdk/kernel/linux/kni/kni_misc.c b/dpdk/kernel/linux/kni/kni_misc.c deleted file mode 100644 index 0c3a86ee3..000000000 --- a/dpdk/kernel/linux/kni/kni_misc.c +++ /dev/null @@ -1,719 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright(c) 2010-2014 Intel Corporation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "compat.h" -#include "kni_dev.h" - -MODULE_VERSION(KNI_VERSION); -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("Intel Corporation"); -MODULE_DESCRIPTION("Kernel Module for managing kni devices"); - -#define KNI_RX_LOOP_NUM 1000 - -#define KNI_MAX_DEVICES 32 - -/* loopback mode */ -static char *lo_mode; - -/* Kernel thread mode */ -static char *kthread_mode; -static uint32_t multiple_kthread_on; - -/* Default carrier state for created KNI network interfaces */ -static char *carrier; -uint32_t kni_dflt_carrier; - -/* Request processing support for bifurcated drivers. */ -static char *enable_bifurcated; -uint32_t bifurcated_support; - -/* KNI thread scheduling interval */ -static long min_scheduling_interval = 100; /* us */ -static long max_scheduling_interval = 200; /* us */ - -#define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */ - -static int kni_net_id; - -struct kni_net { - unsigned long device_in_use; /* device in use flag */ - struct mutex kni_kthread_lock; - struct task_struct *kni_kthread; - struct rw_semaphore kni_list_lock; - struct list_head kni_list_head; -}; - -static int __net_init -kni_init_net(struct net *net) -{ -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - struct kni_net *knet = net_generic(net, kni_net_id); - - memset(knet, 0, sizeof(*knet)); -#else - struct kni_net *knet; - int ret; - - knet = kzalloc(sizeof(struct kni_net), GFP_KERNEL); - if (!knet) { - ret = -ENOMEM; - return ret; - } -#endif - - /* Clear the bit of device in use */ - clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); - - mutex_init(&knet->kni_kthread_lock); - - init_rwsem(&knet->kni_list_lock); - INIT_LIST_HEAD(&knet->kni_list_head); - -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - return 0; -#else - ret = net_assign_generic(net, kni_net_id, knet); - if (ret < 0) - kfree(knet); - - return ret; -#endif -} - -static void __net_exit -kni_exit_net(struct net *net) -{ - struct kni_net *knet __maybe_unused; - - knet = net_generic(net, kni_net_id); - mutex_destroy(&knet->kni_kthread_lock); - -#ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS - kfree(knet); -#endif -} - -static struct pernet_operations kni_net_ops = { - .init = kni_init_net, - .exit = kni_exit_net, -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - .id = &kni_net_id, - .size = sizeof(struct kni_net), -#endif -}; - -static int -kni_thread_single(void *data) -{ - struct kni_net *knet = data; - int j; - struct kni_dev *dev; - - while (!kthread_should_stop()) { - down_read(&knet->kni_list_lock); - for (j = 0; j < KNI_RX_LOOP_NUM; j++) { - list_for_each_entry(dev, &knet->kni_list_head, list) { - kni_net_rx(dev); - kni_net_poll_resp(dev); - } - } - up_read(&knet->kni_list_lock); - /* reschedule out for a while */ - usleep_range(min_scheduling_interval, max_scheduling_interval); - } - - return 0; -} - -static int -kni_thread_multiple(void *param) -{ - int j; - struct kni_dev *dev = param; - - while (!kthread_should_stop()) { - for (j = 0; j < KNI_RX_LOOP_NUM; j++) { - kni_net_rx(dev); - kni_net_poll_resp(dev); - } - usleep_range(min_scheduling_interval, max_scheduling_interval); - } - - return 0; -} - -static int -kni_open(struct inode *inode, struct file *file) -{ - struct net *net = current->nsproxy->net_ns; - struct kni_net *knet = net_generic(net, kni_net_id); - - /* kni device can be opened by one user only per netns */ - if (test_and_set_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use)) - return -EBUSY; - - file->private_data = get_net(net); - pr_debug("/dev/kni opened\n"); - - return 0; -} - -static int -kni_dev_remove(struct kni_dev *dev) -{ - if (!dev) - return -ENODEV; - - /* - * The memory of kni device is allocated and released together - * with net device. Release mbuf before freeing net device. - */ - kni_net_release_fifo_phy(dev); - - if (dev->net_dev) { - unregister_netdev(dev->net_dev); - free_netdev(dev->net_dev); - } - - return 0; -} - -static int -kni_release(struct inode *inode, struct file *file) -{ - struct net *net = file->private_data; - struct kni_net *knet = net_generic(net, kni_net_id); - struct kni_dev *dev, *n; - - /* Stop kernel thread for single mode */ - if (multiple_kthread_on == 0) { - mutex_lock(&knet->kni_kthread_lock); - /* Stop kernel thread */ - if (knet->kni_kthread != NULL) { - kthread_stop(knet->kni_kthread); - knet->kni_kthread = NULL; - } - mutex_unlock(&knet->kni_kthread_lock); - } - - down_write(&knet->kni_list_lock); - list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { - /* Stop kernel thread for multiple mode */ - if (multiple_kthread_on && dev->pthread != NULL) { - kthread_stop(dev->pthread); - dev->pthread = NULL; - } - - list_del(&dev->list); - kni_dev_remove(dev); - } - up_write(&knet->kni_list_lock); - - /* Clear the bit of device in use */ - clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); - - put_net(net); - pr_debug("/dev/kni closed\n"); - - return 0; -} - -static int -kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev) -{ - if (!kni || !dev) - return -1; - - /* Check if network name has been used */ - if (!strncmp(kni->name, dev->name, RTE_KNI_NAMESIZE)) { - pr_err("KNI name %s duplicated\n", dev->name); - return -1; - } - - return 0; -} - -static int -kni_run_thread(struct kni_net *knet, struct kni_dev *kni, uint8_t force_bind) -{ - /** - * Create a new kernel thread for multiple mode, set its core affinity, - * and finally wake it up. - */ - if (multiple_kthread_on) { - kni->pthread = kthread_create(kni_thread_multiple, - (void *)kni, "kni_%s", kni->name); - if (IS_ERR(kni->pthread)) { - kni_dev_remove(kni); - return -ECANCELED; - } - - if (force_bind) - kthread_bind(kni->pthread, kni->core_id); - wake_up_process(kni->pthread); - } else { - mutex_lock(&knet->kni_kthread_lock); - - if (knet->kni_kthread == NULL) { - knet->kni_kthread = kthread_create(kni_thread_single, - (void *)knet, "kni_single"); - if (IS_ERR(knet->kni_kthread)) { - mutex_unlock(&knet->kni_kthread_lock); - kni_dev_remove(kni); - return -ECANCELED; - } - - if (force_bind) - kthread_bind(knet->kni_kthread, kni->core_id); - wake_up_process(knet->kni_kthread); - } - - mutex_unlock(&knet->kni_kthread_lock); - } - - return 0; -} - -static int -kni_ioctl_create(struct net *net, uint32_t ioctl_num, - unsigned long ioctl_param) -{ - struct kni_net *knet = net_generic(net, kni_net_id); - int ret; - struct rte_kni_device_info dev_info; - struct net_device *net_dev = NULL; - struct kni_dev *kni, *dev, *n; - - pr_info("Creating kni...\n"); - /* Check the buffer size, to avoid warning */ - if (_IOC_SIZE(ioctl_num) > sizeof(dev_info)) - return -EINVAL; - - /* Copy kni info from user space */ - if (copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info))) - return -EFAULT; - - /* Check if name is zero-ended */ - if (strnlen(dev_info.name, sizeof(dev_info.name)) == sizeof(dev_info.name)) { - pr_err("kni.name not zero-terminated"); - return -EINVAL; - } - - /** - * Check if the cpu core id is valid for binding. - */ - if (dev_info.force_bind && !cpu_online(dev_info.core_id)) { - pr_err("cpu %u is not online\n", dev_info.core_id); - return -EINVAL; - } - - /* Check if it has been created */ - down_read(&knet->kni_list_lock); - list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { - if (kni_check_param(dev, &dev_info) < 0) { - up_read(&knet->kni_list_lock); - return -EINVAL; - } - } - up_read(&knet->kni_list_lock); - - net_dev = alloc_netdev(sizeof(struct kni_dev), dev_info.name, -#ifdef NET_NAME_USER - NET_NAME_USER, -#endif - kni_net_init); - if (net_dev == NULL) { - pr_err("error allocating device \"%s\"\n", dev_info.name); - return -EBUSY; - } - - dev_net_set(net_dev, net); - - kni = netdev_priv(net_dev); - - kni->net_dev = net_dev; - kni->core_id = dev_info.core_id; - strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); - - /* Translate user space info into kernel space info */ - if (dev_info.iova_mode) { -#ifdef HAVE_IOVA_TO_KVA_MAPPING_SUPPORT - kni->tx_q = iova_to_kva(current, dev_info.tx_phys); - kni->rx_q = iova_to_kva(current, dev_info.rx_phys); - kni->alloc_q = iova_to_kva(current, dev_info.alloc_phys); - kni->free_q = iova_to_kva(current, dev_info.free_phys); - - kni->req_q = iova_to_kva(current, dev_info.req_phys); - kni->resp_q = iova_to_kva(current, dev_info.resp_phys); - kni->sync_va = dev_info.sync_va; - kni->sync_kva = iova_to_kva(current, dev_info.sync_phys); - kni->usr_tsk = current; - kni->iova_mode = 1; -#else - pr_err("KNI module does not support IOVA to VA translation\n"); - return -EINVAL; -#endif - } else { - - kni->tx_q = phys_to_virt(dev_info.tx_phys); - kni->rx_q = phys_to_virt(dev_info.rx_phys); - kni->alloc_q = phys_to_virt(dev_info.alloc_phys); - kni->free_q = phys_to_virt(dev_info.free_phys); - - kni->req_q = phys_to_virt(dev_info.req_phys); - kni->resp_q = phys_to_virt(dev_info.resp_phys); - kni->sync_va = dev_info.sync_va; - kni->sync_kva = phys_to_virt(dev_info.sync_phys); - kni->iova_mode = 0; - } - - kni->mbuf_size = dev_info.mbuf_size; - - pr_debug("tx_phys: 0x%016llx, tx_q addr: 0x%p\n", - (unsigned long long) dev_info.tx_phys, kni->tx_q); - pr_debug("rx_phys: 0x%016llx, rx_q addr: 0x%p\n", - (unsigned long long) dev_info.rx_phys, kni->rx_q); - pr_debug("alloc_phys: 0x%016llx, alloc_q addr: 0x%p\n", - (unsigned long long) dev_info.alloc_phys, kni->alloc_q); - pr_debug("free_phys: 0x%016llx, free_q addr: 0x%p\n", - (unsigned long long) dev_info.free_phys, kni->free_q); - pr_debug("req_phys: 0x%016llx, req_q addr: 0x%p\n", - (unsigned long long) dev_info.req_phys, kni->req_q); - pr_debug("resp_phys: 0x%016llx, resp_q addr: 0x%p\n", - (unsigned long long) dev_info.resp_phys, kni->resp_q); - pr_debug("mbuf_size: %u\n", kni->mbuf_size); - - /* if user has provided a valid mac address */ - if (is_valid_ether_addr(dev_info.mac_addr)) { -#ifdef HAVE_ETH_HW_ADDR_SET - eth_hw_addr_set(net_dev, dev_info.mac_addr); -#else - memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN); -#endif - } else { - /* Assign random MAC address. */ - eth_hw_addr_random(net_dev); - } - - if (dev_info.mtu) - net_dev->mtu = dev_info.mtu; -#ifdef HAVE_MAX_MTU_PARAM - net_dev->max_mtu = net_dev->mtu; - - if (dev_info.min_mtu) - net_dev->min_mtu = dev_info.min_mtu; - - if (dev_info.max_mtu) - net_dev->max_mtu = dev_info.max_mtu; -#endif - - ret = register_netdev(net_dev); - if (ret) { - pr_err("error %i registering device \"%s\"\n", - ret, dev_info.name); - kni->net_dev = NULL; - kni_dev_remove(kni); - free_netdev(net_dev); - return -ENODEV; - } - - netif_carrier_off(net_dev); - - ret = kni_run_thread(knet, kni, dev_info.force_bind); - if (ret != 0) - return ret; - - down_write(&knet->kni_list_lock); - list_add(&kni->list, &knet->kni_list_head); - up_write(&knet->kni_list_lock); - - return 0; -} - -static int -kni_ioctl_release(struct net *net, uint32_t ioctl_num, - unsigned long ioctl_param) -{ - struct kni_net *knet = net_generic(net, kni_net_id); - int ret = -EINVAL; - struct kni_dev *dev, *n; - struct rte_kni_device_info dev_info; - - if (_IOC_SIZE(ioctl_num) > sizeof(dev_info)) - return -EINVAL; - - if (copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info))) - return -EFAULT; - - /* Release the network device according to its name */ - if (strlen(dev_info.name) == 0) - return -EINVAL; - - down_write(&knet->kni_list_lock); - list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { - if (strncmp(dev->name, dev_info.name, RTE_KNI_NAMESIZE) != 0) - continue; - - if (multiple_kthread_on && dev->pthread != NULL) { - kthread_stop(dev->pthread); - dev->pthread = NULL; - } - - list_del(&dev->list); - kni_dev_remove(dev); - ret = 0; - break; - } - up_write(&knet->kni_list_lock); - pr_info("%s release kni named %s\n", - (ret == 0 ? "Successfully" : "Unsuccessfully"), dev_info.name); - - return ret; -} - -static long -kni_ioctl(struct file *file, unsigned int ioctl_num, unsigned long ioctl_param) -{ - long ret = -EINVAL; - struct net *net = current->nsproxy->net_ns; - - pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param); - - /* - * Switch according to the ioctl called - */ - switch (_IOC_NR(ioctl_num)) { - case _IOC_NR(RTE_KNI_IOCTL_TEST): - /* For test only, not used */ - break; - case _IOC_NR(RTE_KNI_IOCTL_CREATE): - ret = kni_ioctl_create(net, ioctl_num, ioctl_param); - break; - case _IOC_NR(RTE_KNI_IOCTL_RELEASE): - ret = kni_ioctl_release(net, ioctl_num, ioctl_param); - break; - default: - pr_debug("IOCTL default\n"); - break; - } - - return ret; -} - -static long -kni_compat_ioctl(struct file *file, unsigned int ioctl_num, - unsigned long ioctl_param) -{ - /* 32 bits app on 64 bits OS to be supported later */ - pr_debug("Not implemented.\n"); - - return -EINVAL; -} - -static const struct file_operations kni_fops = { - .owner = THIS_MODULE, - .open = kni_open, - .release = kni_release, - .unlocked_ioctl = kni_ioctl, - .compat_ioctl = kni_compat_ioctl, -}; - -static struct miscdevice kni_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = KNI_DEVICE, - .fops = &kni_fops, -}; - -static int __init -kni_parse_kthread_mode(void) -{ - if (!kthread_mode) - return 0; - - if (strcmp(kthread_mode, "single") == 0) - return 0; - else if (strcmp(kthread_mode, "multiple") == 0) - multiple_kthread_on = 1; - else - return -1; - - return 0; -} - -static int __init -kni_parse_carrier_state(void) -{ - if (!carrier) { - kni_dflt_carrier = 0; - return 0; - } - - if (strcmp(carrier, "off") == 0) - kni_dflt_carrier = 0; - else if (strcmp(carrier, "on") == 0) - kni_dflt_carrier = 1; - else - return -1; - - return 0; -} - -static int __init -kni_parse_bifurcated_support(void) -{ - if (!enable_bifurcated) { - bifurcated_support = 0; - return 0; - } - - if (strcmp(enable_bifurcated, "on") == 0) - bifurcated_support = 1; - else - return -1; - - return 0; -} - -static int __init -kni_init(void) -{ - int rc; - - if (kni_parse_kthread_mode() < 0) { - pr_err("Invalid parameter for kthread_mode\n"); - return -EINVAL; - } - - if (multiple_kthread_on == 0) - pr_debug("Single kernel thread for all KNI devices\n"); - else - pr_debug("Multiple kernel thread mode enabled\n"); - - if (kni_parse_carrier_state() < 0) { - pr_err("Invalid parameter for carrier\n"); - return -EINVAL; - } - - if (kni_dflt_carrier == 0) - pr_debug("Default carrier state set to off.\n"); - else - pr_debug("Default carrier state set to on.\n"); - - if (kni_parse_bifurcated_support() < 0) { - pr_err("Invalid parameter for bifurcated support\n"); - return -EINVAL; - } - if (bifurcated_support == 1) - pr_debug("bifurcated support is enabled.\n"); - - if (min_scheduling_interval < 0 || max_scheduling_interval < 0 || - min_scheduling_interval > KNI_KTHREAD_MAX_RESCHEDULE_INTERVAL || - max_scheduling_interval > KNI_KTHREAD_MAX_RESCHEDULE_INTERVAL || - min_scheduling_interval >= max_scheduling_interval) { - pr_err("Invalid parameters for scheduling interval\n"); - return -EINVAL; - } - -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - rc = register_pernet_subsys(&kni_net_ops); -#else - rc = register_pernet_gen_subsys(&kni_net_id, &kni_net_ops); -#endif - if (rc) - return -EPERM; - - rc = misc_register(&kni_misc); - if (rc != 0) { - pr_err("Misc registration failed\n"); - goto out; - } - - /* Configure the lo mode according to the input parameter */ - kni_net_config_lo_mode(lo_mode); - - return 0; - -out: -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - unregister_pernet_subsys(&kni_net_ops); -#else - unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops); -#endif - return rc; -} - -static void __exit -kni_exit(void) -{ - misc_deregister(&kni_misc); -#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS - unregister_pernet_subsys(&kni_net_ops); -#else - unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops); -#endif -} - -module_init(kni_init); -module_exit(kni_exit); - -module_param(lo_mode, charp, 0644); -MODULE_PARM_DESC(lo_mode, -"KNI loopback mode (default=lo_mode_none):\n" -"\t\tlo_mode_none Kernel loopback disabled\n" -"\t\tlo_mode_fifo Enable kernel loopback with fifo\n" -"\t\tlo_mode_fifo_skb Enable kernel loopback with fifo and skb buffer\n" -"\t\t" -); - -module_param(kthread_mode, charp, 0644); -MODULE_PARM_DESC(kthread_mode, -"Kernel thread mode (default=single):\n" -"\t\tsingle Single kernel thread mode enabled.\n" -"\t\tmultiple Multiple kernel thread mode enabled.\n" -"\t\t" -); - -module_param(carrier, charp, 0644); -MODULE_PARM_DESC(carrier, -"Default carrier state for KNI interface (default=off):\n" -"\t\toff Interfaces will be created with carrier state set to off.\n" -"\t\ton Interfaces will be created with carrier state set to on.\n" -"\t\t" -); - -module_param(enable_bifurcated, charp, 0644); -MODULE_PARM_DESC(enable_bifurcated, -"Enable request processing support for bifurcated drivers, " -"which means releasing rtnl_lock before calling userspace callback and " -"supporting async requests (default=off):\n" -"\t\ton Enable request processing support for bifurcated drivers.\n" -"\t\t" -); - -module_param(min_scheduling_interval, long, 0644); -MODULE_PARM_DESC(min_scheduling_interval, -"KNI thread min scheduling interval (default=100 microseconds)" -); - -module_param(max_scheduling_interval, long, 0644); -MODULE_PARM_DESC(max_scheduling_interval, -"KNI thread max scheduling interval (default=200 microseconds)" -); diff --git a/dpdk/kernel/linux/kni/kni_net.c b/dpdk/kernel/linux/kni/kni_net.c deleted file mode 100644 index 30eb53221..000000000 --- a/dpdk/kernel/linux/kni/kni_net.c +++ /dev/null @@ -1,883 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright(c) 2010-2014 Intel Corporation. - */ - -/* - * This code is inspired from the book "Linux Device Drivers" by - * Alessandro Rubini and Jonathan Corbet, published by O'Reilly & Associates - */ - -#include -#include -#include -#include -#include /* eth_type_trans */ -#include -#include -#include -#include -#include - -#include -#include - -#include "compat.h" -#include "kni_dev.h" - -#define WD_TIMEOUT 5 /*jiffies */ - -#define KNI_WAIT_RESPONSE_TIMEOUT 300 /* 3 seconds */ - -/* typedef for rx function */ -typedef void (*kni_net_rx_t)(struct kni_dev *kni); - -static void kni_net_rx_normal(struct kni_dev *kni); - -/* kni rx function pointer, with default to normal rx */ -static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal; - -#ifdef HAVE_IOVA_TO_KVA_MAPPING_SUPPORT -/* iova to kernel virtual address */ -static inline void * -iova2kva(struct kni_dev *kni, void *iova) -{ - return phys_to_virt(iova_to_phys(kni->usr_tsk, (unsigned long)iova)); -} - -static inline void * -iova2data_kva(struct kni_dev *kni, struct rte_kni_mbuf *m) -{ - return phys_to_virt(iova_to_phys(kni->usr_tsk, m->buf_iova) + - m->data_off); -} -#endif - -/* physical address to kernel virtual address */ -static void * -pa2kva(void *pa) -{ - return phys_to_virt((unsigned long)pa); -} - -/* physical address to virtual address */ -static void * -pa2va(void *pa, struct rte_kni_mbuf *m) -{ - void *va; - - va = (void *)((unsigned long)pa + - (unsigned long)m->buf_addr - - (unsigned long)m->buf_iova); - return va; -} - -/* mbuf data kernel virtual address from mbuf kernel virtual address */ -static void * -kva2data_kva(struct rte_kni_mbuf *m) -{ - return phys_to_virt(m->buf_iova + m->data_off); -} - -static inline void * -get_kva(struct kni_dev *kni, void *pa) -{ -#ifdef HAVE_IOVA_TO_KVA_MAPPING_SUPPORT - if (kni->iova_mode == 1) - return iova2kva(kni, pa); -#endif - return pa2kva(pa); -} - -static inline void * -get_data_kva(struct kni_dev *kni, void *pkt_kva) -{ -#ifdef HAVE_IOVA_TO_KVA_MAPPING_SUPPORT - if (kni->iova_mode == 1) - return iova2data_kva(kni, pkt_kva); -#endif - return kva2data_kva(pkt_kva); -} - -/* - * It can be called to process the request. - */ -static int -kni_net_process_request(struct net_device *dev, struct rte_kni_request *req) -{ - struct kni_dev *kni = netdev_priv(dev); - int ret = -1; - void *resp_va; - uint32_t num; - int ret_val; - - ASSERT_RTNL(); - - if (bifurcated_support) { - /* If we need to wait and RTNL mutex is held - * drop the mutex and hold reference to keep device - */ - if (req->async == 0) { - dev_hold(dev); - rtnl_unlock(); - } - } - - mutex_lock(&kni->sync_lock); - - /* Construct data */ - memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request)); - num = kni_fifo_put(kni->req_q, &kni->sync_va, 1); - if (num < 1) { - pr_err("Cannot send to req_q\n"); - ret = -EBUSY; - goto fail; - } - - if (bifurcated_support) { - /* No result available since request is handled - * asynchronously. set response to success. - */ - if (req->async != 0) { - req->result = 0; - goto async; - } - } - - ret_val = wait_event_interruptible_timeout(kni->wq, - kni_fifo_count(kni->resp_q), 3 * HZ); - if (signal_pending(current) || ret_val <= 0) { - ret = -ETIME; - goto fail; - } - num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1); - if (num != 1 || resp_va != kni->sync_va) { - /* This should never happen */ - pr_err("No data in resp_q\n"); - ret = -ENODATA; - goto fail; - } - - memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request)); -async: - ret = 0; - -fail: - mutex_unlock(&kni->sync_lock); - if (bifurcated_support) { - if (req->async == 0) { - rtnl_lock(); - dev_put(dev); - } - } - return ret; -} - -/* - * Open and close - */ -static int -kni_net_open(struct net_device *dev) -{ - int ret; - struct rte_kni_request req; - - netif_start_queue(dev); - if (kni_dflt_carrier == 1) - netif_carrier_on(dev); - else - netif_carrier_off(dev); - - memset(&req, 0, sizeof(req)); - req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF; - - /* Setting if_up to non-zero means up */ - req.if_up = 1; - ret = kni_net_process_request(dev, &req); - - return (ret == 0) ? req.result : ret; -} - -static int -kni_net_release(struct net_device *dev) -{ - int ret; - struct rte_kni_request req; - - netif_stop_queue(dev); /* can't transmit any more */ - netif_carrier_off(dev); - - memset(&req, 0, sizeof(req)); - req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF; - - /* Setting if_up to 0 means down */ - req.if_up = 0; - - if (bifurcated_support) { - /* request async because of the deadlock problem */ - req.async = 1; - } - - ret = kni_net_process_request(dev, &req); - - return (ret == 0) ? req.result : ret; -} - -static void -kni_fifo_trans_pa2va(struct kni_dev *kni, - struct rte_kni_fifo *src_pa, struct rte_kni_fifo *dst_va) -{ - uint32_t ret, i, num_dst, num_rx; - struct rte_kni_mbuf *kva, *prev_kva; - int nb_segs; - int kva_nb_segs; - - do { - num_dst = kni_fifo_free_count(dst_va); - if (num_dst == 0) - return; - - num_rx = min_t(uint32_t, num_dst, MBUF_BURST_SZ); - - num_rx = kni_fifo_get(src_pa, kni->pa, num_rx); - if (num_rx == 0) - return; - - for (i = 0; i < num_rx; i++) { - kva = get_kva(kni, kni->pa[i]); - kni->va[i] = pa2va(kni->pa[i], kva); - - kva_nb_segs = kva->nb_segs; - for (nb_segs = 0; nb_segs < kva_nb_segs; nb_segs++) { - if (!kva->next) - break; - - prev_kva = kva; - kva = get_kva(kni, kva->next); - /* Convert physical address to virtual address */ - prev_kva->next = pa2va(prev_kva->next, kva); - } - } - - ret = kni_fifo_put(dst_va, kni->va, num_rx); - if (ret != num_rx) { - /* Failing should not happen */ - pr_err("Fail to enqueue entries into dst_va\n"); - return; - } - } while (1); -} - -/* Try to release mbufs when kni release */ -void kni_net_release_fifo_phy(struct kni_dev *kni) -{ - /* release rx_q first, because it can't release in userspace */ - kni_fifo_trans_pa2va(kni, kni->rx_q, kni->free_q); - /* release alloc_q for speeding up kni release in userspace */ - kni_fifo_trans_pa2va(kni, kni->alloc_q, kni->free_q); -} - -/* - * Configuration changes (passed on by ifconfig) - */ -static int -kni_net_config(struct net_device *dev, struct ifmap *map) -{ - if (dev->flags & IFF_UP) /* can't act on a running interface */ - return -EBUSY; - - /* ignore other fields */ - return 0; -} - -/* - * Transmit a packet (called by the kernel) - */ -static int -kni_net_tx(struct sk_buff *skb, struct net_device *dev) -{ - int len = 0; - uint32_t ret; - struct kni_dev *kni = netdev_priv(dev); - struct rte_kni_mbuf *pkt_kva = NULL; - void *pkt_pa = NULL; - void *pkt_va = NULL; - - /* save the timestamp */ -#ifdef HAVE_TRANS_START_HELPER - netif_trans_update(dev); -#else - dev->trans_start = jiffies; -#endif - - /* Check if the length of skb is less than mbuf size */ - if (skb->len > kni->mbuf_size) - goto drop; - - /** - * Check if it has at least one free entry in tx_q and - * one entry in alloc_q. - */ - if (kni_fifo_free_count(kni->tx_q) == 0 || - kni_fifo_count(kni->alloc_q) == 0) { - /** - * If no free entry in tx_q or no entry in alloc_q, - * drops skb and goes out. - */ - goto drop; - } - - /* dequeue a mbuf from alloc_q */ - ret = kni_fifo_get(kni->alloc_q, &pkt_pa, 1); - if (likely(ret == 1)) { - void *data_kva; - - pkt_kva = get_kva(kni, pkt_pa); - data_kva = get_data_kva(kni, pkt_kva); - pkt_va = pa2va(pkt_pa, pkt_kva); - - len = skb->len; - memcpy(data_kva, skb->data, len); - if (unlikely(len < ETH_ZLEN)) { - memset(data_kva + len, 0, ETH_ZLEN - len); - len = ETH_ZLEN; - } - pkt_kva->pkt_len = len; - pkt_kva->data_len = len; - - /* enqueue mbuf into tx_q */ - ret = kni_fifo_put(kni->tx_q, &pkt_va, 1); - if (unlikely(ret != 1)) { - /* Failing should not happen */ - pr_err("Fail to enqueue mbuf into tx_q\n"); - goto drop; - } - } else { - /* Failing should not happen */ - pr_err("Fail to dequeue mbuf from alloc_q\n"); - goto drop; - } - - /* Free skb and update statistics */ - dev_kfree_skb(skb); - dev->stats.tx_bytes += len; - dev->stats.tx_packets++; - - return NETDEV_TX_OK; - -drop: - /* Free skb and update statistics */ - dev_kfree_skb(skb); - dev->stats.tx_dropped++; - - return NETDEV_TX_OK; -} - -/* - * RX: normal working mode - */ -static void -kni_net_rx_normal(struct kni_dev *kni) -{ - uint32_t ret; - uint32_t len; - uint32_t i, num_rx, num_fq; - struct rte_kni_mbuf *kva, *prev_kva; - void *data_kva; - struct sk_buff *skb; - struct net_device *dev = kni->net_dev; - - /* Get the number of free entries in free_q */ - num_fq = kni_fifo_free_count(kni->free_q); - if (num_fq == 0) { - /* No room on the free_q, bail out */ - return; - } - - /* Calculate the number of entries to dequeue from rx_q */ - num_rx = min_t(uint32_t, num_fq, MBUF_BURST_SZ); - - /* Burst dequeue from rx_q */ - num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx); - if (num_rx == 0) - return; - - /* Transfer received packets to netif */ - for (i = 0; i < num_rx; i++) { - kva = get_kva(kni, kni->pa[i]); - len = kva->pkt_len; - data_kva = get_data_kva(kni, kva); - kni->va[i] = pa2va(kni->pa[i], kva); - - skb = netdev_alloc_skb(dev, len); - if (!skb) { - /* Update statistics */ - dev->stats.rx_dropped++; - continue; - } - - if (kva->nb_segs == 1) { - memcpy(skb_put(skb, len), data_kva, len); - } else { - int nb_segs; - int kva_nb_segs = kva->nb_segs; - - for (nb_segs = 0; nb_segs < kva_nb_segs; nb_segs++) { - memcpy(skb_put(skb, kva->data_len), - data_kva, kva->data_len); - - if (!kva->next) - break; - - prev_kva = kva; - kva = get_kva(kni, kva->next); - data_kva = kva2data_kva(kva); - /* Convert physical address to virtual address */ - prev_kva->next = pa2va(prev_kva->next, kva); - } - } - - skb->protocol = eth_type_trans(skb, dev); - skb->ip_summed = CHECKSUM_UNNECESSARY; - - /* Call netif interface */ -#ifdef HAVE_NETIF_RX_NI - netif_rx_ni(skb); -#else - netif_rx(skb); -#endif - - /* Update statistics */ - dev->stats.rx_bytes += len; - dev->stats.rx_packets++; - } - - /* Burst enqueue mbufs into free_q */ - ret = kni_fifo_put(kni->free_q, kni->va, num_rx); - if (ret != num_rx) - /* Failing should not happen */ - pr_err("Fail to enqueue entries into free_q\n"); -} - -/* - * RX: loopback with enqueue/dequeue fifos. - */ -static void -kni_net_rx_lo_fifo(struct kni_dev *kni) -{ - uint32_t ret; - uint32_t len; - uint32_t i, num, num_rq, num_tq, num_aq, num_fq; - struct rte_kni_mbuf *kva, *next_kva; - void *data_kva; - struct rte_kni_mbuf *alloc_kva; - void *alloc_data_kva; - struct net_device *dev = kni->net_dev; - - /* Get the number of entries in rx_q */ - num_rq = kni_fifo_count(kni->rx_q); - - /* Get the number of free entries in tx_q */ - num_tq = kni_fifo_free_count(kni->tx_q); - - /* Get the number of entries in alloc_q */ - num_aq = kni_fifo_count(kni->alloc_q); - - /* Get the number of free entries in free_q */ - num_fq = kni_fifo_free_count(kni->free_q); - - /* Calculate the number of entries to be dequeued from rx_q */ - num = min(num_rq, num_tq); - num = min(num, num_aq); - num = min(num, num_fq); - num = min_t(uint32_t, num, MBUF_BURST_SZ); - - /* Return if no entry to dequeue from rx_q */ - if (num == 0) - return; - - /* Burst dequeue from rx_q */ - ret = kni_fifo_get(kni->rx_q, kni->pa, num); - if (ret == 0) - return; /* Failing should not happen */ - - /* Dequeue entries from alloc_q */ - ret = kni_fifo_get(kni->alloc_q, kni->alloc_pa, num); - if (ret) { - num = ret; - /* Copy mbufs */ - for (i = 0; i < num; i++) { - kva = get_kva(kni, kni->pa[i]); - len = kva->data_len; - data_kva = get_data_kva(kni, kva); - kni->va[i] = pa2va(kni->pa[i], kva); - - while (kva->next) { - next_kva = get_kva(kni, kva->next); - /* Convert physical address to virtual address */ - kva->next = pa2va(kva->next, next_kva); - kva = next_kva; - } - - alloc_kva = get_kva(kni, kni->alloc_pa[i]); - alloc_data_kva = get_data_kva(kni, alloc_kva); - kni->alloc_va[i] = pa2va(kni->alloc_pa[i], alloc_kva); - - memcpy(alloc_data_kva, data_kva, len); - alloc_kva->pkt_len = len; - alloc_kva->data_len = len; - - dev->stats.tx_bytes += len; - dev->stats.rx_bytes += len; - } - - /* Burst enqueue mbufs into tx_q */ - ret = kni_fifo_put(kni->tx_q, kni->alloc_va, num); - if (ret != num) - /* Failing should not happen */ - pr_err("Fail to enqueue mbufs into tx_q\n"); - } - - /* Burst enqueue mbufs into free_q */ - ret = kni_fifo_put(kni->free_q, kni->va, num); - if (ret != num) - /* Failing should not happen */ - pr_err("Fail to enqueue mbufs into free_q\n"); - - /** - * Update statistic, and enqueue/dequeue failure is impossible, - * as all queues are checked at first. - */ - dev->stats.tx_packets += num; - dev->stats.rx_packets += num; -} - -/* - * RX: loopback with enqueue/dequeue fifos and sk buffer copies. - */ -static void -kni_net_rx_lo_fifo_skb(struct kni_dev *kni) -{ - uint32_t ret; - uint32_t len; - uint32_t i, num_rq, num_fq, num; - struct rte_kni_mbuf *kva, *prev_kva; - void *data_kva; - struct sk_buff *skb; - struct net_device *dev = kni->net_dev; - - /* Get the number of entries in rx_q */ - num_rq = kni_fifo_count(kni->rx_q); - - /* Get the number of free entries in free_q */ - num_fq = kni_fifo_free_count(kni->free_q); - - /* Calculate the number of entries to dequeue from rx_q */ - num = min(num_rq, num_fq); - num = min_t(uint32_t, num, MBUF_BURST_SZ); - - /* Return if no entry to dequeue from rx_q */ - if (num == 0) - return; - - /* Burst dequeue mbufs from rx_q */ - ret = kni_fifo_get(kni->rx_q, kni->pa, num); - if (ret == 0) - return; - - /* Copy mbufs to sk buffer and then call tx interface */ - for (i = 0; i < num; i++) { - kva = get_kva(kni, kni->pa[i]); - len = kva->pkt_len; - data_kva = get_data_kva(kni, kva); - kni->va[i] = pa2va(kni->pa[i], kva); - - skb = netdev_alloc_skb(dev, len); - if (skb) { - memcpy(skb_put(skb, len), data_kva, len); - skb->ip_summed = CHECKSUM_UNNECESSARY; - dev_kfree_skb(skb); - } - - /* Simulate real usage, allocate/copy skb twice */ - skb = netdev_alloc_skb(dev, len); - if (skb == NULL) { - dev->stats.rx_dropped++; - continue; - } - - if (kva->nb_segs == 1) { - memcpy(skb_put(skb, len), data_kva, len); - } else { - int nb_segs; - int kva_nb_segs = kva->nb_segs; - - for (nb_segs = 0; nb_segs < kva_nb_segs; nb_segs++) { - memcpy(skb_put(skb, kva->data_len), - data_kva, kva->data_len); - - if (!kva->next) - break; - - prev_kva = kva; - kva = get_kva(kni, kva->next); - data_kva = get_data_kva(kni, kva); - /* Convert physical address to virtual address */ - prev_kva->next = pa2va(prev_kva->next, kva); - } - } - - skb->ip_summed = CHECKSUM_UNNECESSARY; - - dev->stats.rx_bytes += len; - dev->stats.rx_packets++; - - /* call tx interface */ - kni_net_tx(skb, dev); - } - - /* enqueue all the mbufs from rx_q into free_q */ - ret = kni_fifo_put(kni->free_q, kni->va, num); - if (ret != num) - /* Failing should not happen */ - pr_err("Fail to enqueue mbufs into free_q\n"); -} - -/* rx interface */ -void -kni_net_rx(struct kni_dev *kni) -{ - /** - * It doesn't need to check if it is NULL pointer, - * as it has a default value - */ - (*kni_net_rx_func)(kni); -} - -/* - * Deal with a transmit timeout. - */ -#ifdef HAVE_TX_TIMEOUT_TXQUEUE -static void -kni_net_tx_timeout(struct net_device *dev, unsigned int txqueue) -#else -static void -kni_net_tx_timeout(struct net_device *dev) -#endif -{ - pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies, - jiffies - dev_trans_start(dev)); - - dev->stats.tx_errors++; - netif_wake_queue(dev); -} - -static int -kni_net_change_mtu(struct net_device *dev, int new_mtu) -{ - int ret; - struct rte_kni_request req; - - pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu); - - memset(&req, 0, sizeof(req)); - req.req_id = RTE_KNI_REQ_CHANGE_MTU; - req.new_mtu = new_mtu; - ret = kni_net_process_request(dev, &req); - if (ret == 0 && req.result == 0) - dev->mtu = new_mtu; - - return (ret == 0) ? req.result : ret; -} - -static void -kni_net_change_rx_flags(struct net_device *netdev, int flags) -{ - struct rte_kni_request req; - - memset(&req, 0, sizeof(req)); - - if (flags & IFF_ALLMULTI) { - req.req_id = RTE_KNI_REQ_CHANGE_ALLMULTI; - - if (netdev->flags & IFF_ALLMULTI) - req.allmulti = 1; - else - req.allmulti = 0; - } - - if (flags & IFF_PROMISC) { - req.req_id = RTE_KNI_REQ_CHANGE_PROMISC; - - if (netdev->flags & IFF_PROMISC) - req.promiscusity = 1; - else - req.promiscusity = 0; - } - - kni_net_process_request(netdev, &req); -} - -/* - * Checks if the user space application provided the resp message - */ -void -kni_net_poll_resp(struct kni_dev *kni) -{ - if (kni_fifo_count(kni->resp_q)) - wake_up_interruptible(&kni->wq); -} - -/* - * Fill the eth header - */ -static int -kni_net_header(struct sk_buff *skb, struct net_device *dev, - unsigned short type, const void *daddr, - const void *saddr, uint32_t len) -{ - struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN); - - memcpy(eth->h_source, saddr ? saddr : dev->dev_addr, dev->addr_len); - memcpy(eth->h_dest, daddr ? daddr : dev->dev_addr, dev->addr_len); - eth->h_proto = htons(type); - - return dev->hard_header_len; -} - -/* - * Re-fill the eth header - */ -#ifdef HAVE_REBUILD_HEADER -static int -kni_net_rebuild_header(struct sk_buff *skb) -{ - struct net_device *dev = skb->dev; - struct ethhdr *eth = (struct ethhdr *) skb->data; - - memcpy(eth->h_source, dev->dev_addr, dev->addr_len); - memcpy(eth->h_dest, dev->dev_addr, dev->addr_len); - - return 0; -} -#endif /* < 4.1.0 */ - -/** - * kni_net_set_mac - Change the Ethernet Address of the KNI NIC - * @netdev: network interface device structure - * @p: pointer to an address structure - * - * Returns 0 on success, negative on failure - **/ -static int -kni_net_set_mac(struct net_device *netdev, void *p) -{ - int ret; - struct rte_kni_request req; - struct sockaddr *addr = p; - - memset(&req, 0, sizeof(req)); - req.req_id = RTE_KNI_REQ_CHANGE_MAC_ADDR; - - if (!is_valid_ether_addr((unsigned char *)(addr->sa_data))) - return -EADDRNOTAVAIL; - - memcpy(req.mac_addr, addr->sa_data, netdev->addr_len); -#ifdef HAVE_ETH_HW_ADDR_SET - eth_hw_addr_set(netdev, addr->sa_data); -#else - memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -#endif - - ret = kni_net_process_request(netdev, &req); - - return (ret == 0 ? req.result : ret); -} - -#ifdef HAVE_CHANGE_CARRIER_CB -static int -kni_net_change_carrier(struct net_device *dev, bool new_carrier) -{ - if (new_carrier) - netif_carrier_on(dev); - else - netif_carrier_off(dev); - return 0; -} -#endif - -static const struct header_ops kni_net_header_ops = { - .create = kni_net_header, - .parse = eth_header_parse, -#ifdef HAVE_REBUILD_HEADER - .rebuild = kni_net_rebuild_header, -#endif /* < 4.1.0 */ - .cache = NULL, /* disable caching */ -}; - -static const struct net_device_ops kni_net_netdev_ops = { - .ndo_open = kni_net_open, - .ndo_stop = kni_net_release, - .ndo_set_config = kni_net_config, - .ndo_change_rx_flags = kni_net_change_rx_flags, - .ndo_start_xmit = kni_net_tx, - .ndo_change_mtu = kni_net_change_mtu, - .ndo_tx_timeout = kni_net_tx_timeout, - .ndo_set_mac_address = kni_net_set_mac, -#ifdef HAVE_CHANGE_CARRIER_CB - .ndo_change_carrier = kni_net_change_carrier, -#endif -}; - -static void kni_get_drvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) -{ -#if __GNUC__ >= 13 - strscpy(info->version, KNI_VERSION, sizeof(info->version)); - strscpy(info->driver, "kni", sizeof(info->driver)); -#else - strlcpy(info->version, KNI_VERSION, sizeof(info->version)); - strlcpy(info->driver, "kni", sizeof(info->driver)); -#endif -} - -static const struct ethtool_ops kni_net_ethtool_ops = { - .get_drvinfo = kni_get_drvinfo, - .get_link = ethtool_op_get_link, -}; - -void -kni_net_init(struct net_device *dev) -{ - struct kni_dev *kni = netdev_priv(dev); - - init_waitqueue_head(&kni->wq); - mutex_init(&kni->sync_lock); - - ether_setup(dev); /* assign some of the fields */ - dev->netdev_ops = &kni_net_netdev_ops; - dev->header_ops = &kni_net_header_ops; - dev->ethtool_ops = &kni_net_ethtool_ops; - dev->watchdog_timeo = WD_TIMEOUT; -} - -void -kni_net_config_lo_mode(char *lo_str) -{ - if (!lo_str) { - pr_debug("loopback disabled"); - return; - } - - if (!strcmp(lo_str, "lo_mode_none")) - pr_debug("loopback disabled"); - else if (!strcmp(lo_str, "lo_mode_fifo")) { - pr_debug("loopback mode=lo_mode_fifo enabled"); - kni_net_rx_func = kni_net_rx_lo_fifo; - } else if (!strcmp(lo_str, "lo_mode_fifo_skb")) { - pr_debug("loopback mode=lo_mode_fifo_skb enabled"); - kni_net_rx_func = kni_net_rx_lo_fifo_skb; - } else { - pr_debug("Unknown loopback parameter, disabled"); - } -} diff --git a/dpdk/kernel/linux/kni/meson.build b/dpdk/kernel/linux/kni/meson.build deleted file mode 100644 index 4c90069e9..000000000 --- a/dpdk/kernel/linux/kni/meson.build +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2018 Luca Boccassi - -# For SUSE build check function arguments of ndo_tx_timeout API -# Ref: https://jira.devtools.intel.com/browse/DPDK-29263 -kmod_cflags = '' -file_path = kernel_source_dir + '/include/linux/netdevice.h' -run_cmd = run_command('grep', 'ndo_tx_timeout', file_path, check: false) - -if run_cmd.stdout().contains('txqueue') == true - kmod_cflags = '-DHAVE_ARG_TX_QUEUE' -endif - - -kni_mkfile = custom_target('rte_kni_makefile', - output: 'Makefile', - command: ['touch', '@OUTPUT@']) - -kni_sources = files( - 'kni_misc.c', - 'kni_net.c', - 'Kbuild', -) - -custom_target('rte_kni', - input: kni_sources, - output: 'rte_kni.ko', - command: ['make', '-j4', '-C', kernel_build_dir, - 'M=' + meson.current_build_dir(), - 'src=' + meson.current_source_dir(), - ' '.join(['MODULE_CFLAGS=', kmod_cflags,'-include ']) - + dpdk_source_root + '/config/rte_config.h' + - ' -I' + dpdk_source_root + '/lib/eal/include' + - ' -I' + dpdk_source_root + '/lib/kni' + - ' -I' + dpdk_build_root + - ' -I' + meson.current_source_dir(), - 'modules'] + cross_args, - depends: kni_mkfile, - install: install, - install_dir: kernel_install_dir, - build_by_default: get_option('enable_kmods')) diff --git a/dpdk/kernel/linux/meson.build b/dpdk/kernel/linux/meson.build deleted file mode 100644 index 3d5faecbf..000000000 --- a/dpdk/kernel/linux/meson.build +++ /dev/null @@ -1,103 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2018 Intel Corporation - -subdirs = ['kni', 'igb_uio'] - -kernel_build_dir = get_option('kernel_dir') -kernel_source_dir = get_option('kernel_dir') -kernel_install_dir = '' -install = not meson.is_cross_build() -cross_args = [] - -if not meson.is_cross_build() - # native build - kernel_version = run_command('uname', '-r', check: true).stdout().strip() - if kernel_source_dir != '' - # Try kernel release from sources first - r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false) - if r.returncode() == 0 - kernel_version = r.stdout().strip() - endif - else - # use default path for native builds - kernel_source_dir = '/lib/modules/' + kernel_version + '/source' - endif - kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk' - if kernel_build_dir == '' - # use default path for native builds - kernel_build_dir = '/lib/modules/' + kernel_version + '/build' - endif - - # test running make in kernel directory, using "make kernelversion" - make_returncode = run_command('make', '-sC', kernel_build_dir, - 'kernelversion', check: true).returncode() - if make_returncode != 0 - # backward compatibility: - # the headers could still be in the 'build' subdir - if not kernel_build_dir.endswith('build') and not kernel_build_dir.endswith('build/') - kernel_build_dir = join_paths(kernel_build_dir, 'build') - make_returncode = run_command('make', '-sC', kernel_build_dir, - 'kernelversion', check: true).returncode() - endif - endif - - if make_returncode != 0 - error('Cannot compile kernel modules as requested - are kernel headers installed?') - endif - - # DO ACTUAL MODULE BUILDING - foreach d:subdirs - subdir(d) - endforeach - - subdir_done() -endif - -# cross build -# if we are cross-compiling we need kernel_build_dir specified -if kernel_build_dir == '' - error('Need "kernel_dir" option for kmod compilation when cross-compiling') -endif -cross_compiler = find_program('c').path() -if cross_compiler.endswith('gcc') - cross_prefix = run_command([py3, '-c', 'print("' + cross_compiler + '"[:-3])'], - check: true).stdout().strip() -elif cross_compiler.endswith('clang') - cross_prefix = '' - found_target = false - # search for '-target' and use the arg that follows - # (i.e. the value of '-target') as cross_prefix - foreach cross_c_arg : meson.get_cross_property('c_args') - if found_target and cross_prefix == '' - cross_prefix = cross_c_arg - endif - if cross_c_arg == '-target' - found_target = true - endif - endforeach - if cross_prefix == '' - error('Did not find -target and its value in c_args in input cross-file.') - endif - linker = 'lld' - foreach cross_c_link_arg : meson.get_cross_property('c_link_args') - if cross_c_link_arg.startswith('-fuse-ld') - linker = cross_c_link_arg.split('=')[1] - endif - endforeach - cross_args += ['CC=@0@'.format(cross_compiler), 'LD=ld.@0@'.format(linker)] -else - error('Unsupported cross compiler: @0@'.format(cross_compiler)) -endif - -cross_arch = host_machine.cpu_family() -if host_machine.cpu_family() == 'aarch64' - cross_arch = 'arm64' -endif - -cross_args += ['ARCH=@0@'.format(cross_arch), - 'CROSS_COMPILE=@0@'.format(cross_prefix)] - -# DO ACTUAL MODULE BUILDING -foreach d:subdirs - subdir(d) -endforeach diff --git a/dpdk/lib/cryptodev/rte_cryptodev_trace.h b/dpdk/lib/cryptodev/rte_cryptodev_trace.h deleted file mode 100644 index 6c214ce6e..000000000 --- a/dpdk/lib/cryptodev/rte_cryptodev_trace.h +++ /dev/null @@ -1,501 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2020 Marvell International Ltd. - */ - -#ifndef _RTE_CRYPTODEV_TRACE_H_ -#define _RTE_CRYPTODEV_TRACE_H_ - -/** - * @file - * - * API for cryptodev trace support - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include "rte_cryptodev.h" - -RTE_TRACE_POINT( - rte_cryptodev_trace_configure, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - struct rte_cryptodev_config *conf), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(conf->nb_queue_pairs); - rte_trace_point_emit_i64(conf->ff_disable); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_start, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, int rc), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_int(rc); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_stop, - RTE_TRACE_POINT_ARGS(uint8_t dev_id), - rte_trace_point_emit_u8(dev_id); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_close, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, int rc), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_int(rc); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_queue_pair_setup, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t queue_pair_id, - const struct rte_cryptodev_qp_conf *conf), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(queue_pair_id); - rte_trace_point_emit_u32(conf->nb_descriptors); - rte_trace_point_emit_ptr(conf->mp_session); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_session_pool_create, - RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, - uint32_t elt_size, uint32_t cache_size, - uint16_t user_data_size, void *mempool), - rte_trace_point_emit_string(name); - rte_trace_point_emit_u32(nb_elts); - rte_trace_point_emit_u32(elt_size); - rte_trace_point_emit_u32(cache_size); - rte_trace_point_emit_u16(user_data_size); - rte_trace_point_emit_ptr(mempool); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_session_create, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess, void *xforms, - void *mempool), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_ptr(xforms); - rte_trace_point_emit_ptr(mempool); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_session_pool_create, - RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, - uint16_t user_data_size, uint32_t cache_size, void *mempool), - rte_trace_point_emit_string(name); - rte_trace_point_emit_u32(nb_elts); - rte_trace_point_emit_u16(user_data_size); - rte_trace_point_emit_u32(cache_size); - rte_trace_point_emit_ptr(mempool); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_session_create, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *xforms, void *mempool, - void *sess), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(xforms); - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_ptr(sess); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_session_free, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sess); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_session_free, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sess); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_callback_register, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - enum rte_cryptodev_event_type event, const void *cb_fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_int(event); - rte_trace_point_emit_ptr(cb_fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_callback_unregister, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - enum rte_cryptodev_event_type event, const void *cb_fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_int(event); - rte_trace_point_emit_ptr(cb_fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_device_count_by_driver, - RTE_TRACE_POINT_ARGS(uint8_t driver_id, uint8_t dev_count), - rte_trace_point_emit_u8(driver_id); - rte_trace_point_emit_u8(dev_count); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_devices_get, - RTE_TRACE_POINT_ARGS(const char *driver_name, uint8_t count), - rte_trace_point_emit_string(driver_name); - rte_trace_point_emit_u8(count); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_driver_id_get, - RTE_TRACE_POINT_ARGS(const char *name, int driver_id), - rte_trace_point_emit_string(name); - rte_trace_point_emit_int(driver_id); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_driver_name_get, - RTE_TRACE_POINT_ARGS(uint8_t driver_id, const char *name), - rte_trace_point_emit_u8(driver_id); - rte_trace_point_emit_string(name); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_aead_algo_enum, - RTE_TRACE_POINT_ARGS(const char *algo_string, - enum rte_crypto_aead_algorithm algo_enum, int ret), - rte_trace_point_emit_string(algo_string); - rte_trace_point_emit_int(algo_enum); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_auth_algo_enum, - RTE_TRACE_POINT_ARGS(const char *algo_string, - enum rte_crypto_auth_algorithm algo_enum, int ret), - rte_trace_point_emit_string(algo_string); - rte_trace_point_emit_int(algo_enum); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_cipher_algo_enum, - RTE_TRACE_POINT_ARGS(const char *algo_string, - enum rte_crypto_cipher_algorithm algo_enum, int ret), - rte_trace_point_emit_string(algo_string); - rte_trace_point_emit_int(algo_enum); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_dev_id, - RTE_TRACE_POINT_ARGS(const char *name, int ret), - rte_trace_point_emit_string(name); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_feature_name, - RTE_TRACE_POINT_ARGS(uint64_t flag), - rte_trace_point_emit_u64(flag); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_sec_ctx, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const void *sec_ctx), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sec_ctx); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_info_get, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const char *driver_name), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_string(driver_name); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_is_valid_dev, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, unsigned int ret), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u32(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_name_get, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const char *name), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_string(name); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_queue_pair_count, - RTE_TRACE_POINT_ARGS(const void *dev, const char *name, - uint8_t socket_id, uint8_t dev_id, uint16_t nb_queue_pairs), - rte_trace_point_emit_ptr(dev); - rte_trace_point_emit_string(name); - rte_trace_point_emit_u8(socket_id); - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(nb_queue_pairs); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_socket_id, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const char *name, int socket_id), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_string(name); - rte_trace_point_emit_int(socket_id); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_stats_get, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - const struct rte_cryptodev_stats *stats), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u64(stats->enqueued_count); - rte_trace_point_emit_u64(stats->dequeued_count); - rte_trace_point_emit_u64(stats->enqueue_err_count); - rte_trace_point_emit_u64(stats->dequeue_err_count); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_stats_reset, - RTE_TRACE_POINT_ARGS(uint8_t dev_id), - rte_trace_point_emit_u8(dev_id); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_capability_check_aead, - RTE_TRACE_POINT_ARGS( - const struct rte_cryptodev_symmetric_capability *capability, - uint16_t key_size, uint16_t digest_size, uint16_t aad_size, - uint16_t iv_size, int ret), - rte_trace_point_emit_ptr(capability); - rte_trace_point_emit_int(capability->xform_type); - rte_trace_point_emit_u16(key_size); - rte_trace_point_emit_u16(digest_size); - rte_trace_point_emit_u16(aad_size); - rte_trace_point_emit_u16(iv_size); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_capability_check_auth, - RTE_TRACE_POINT_ARGS( - const struct rte_cryptodev_symmetric_capability *capability, - uint16_t key_size, uint16_t digest_size, uint16_t iv_size, - int ret), - rte_trace_point_emit_ptr(capability); - rte_trace_point_emit_int(capability->xform_type); - rte_trace_point_emit_u16(key_size); - rte_trace_point_emit_u16(digest_size); - rte_trace_point_emit_u16(iv_size); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_capability_check_cipher, - RTE_TRACE_POINT_ARGS( - const struct rte_cryptodev_symmetric_capability *capability, - uint16_t key_size, uint16_t iv_size, int ret), - rte_trace_point_emit_ptr(capability); - rte_trace_point_emit_int(capability->xform_type); - rte_trace_point_emit_u16(key_size); - rte_trace_point_emit_u16(iv_size); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_capability_get, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const char *driver_name, - uint8_t driver_id, int idx_type, const void *sym_capability), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_string(driver_name); - rte_trace_point_emit_u8(driver_id); - rte_trace_point_emit_int(idx_type); - rte_trace_point_emit_ptr(sym_capability); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_get_private_session_size, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint32_t priv_sess_size), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u32(priv_sess_size); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_capability_get, - RTE_TRACE_POINT_ARGS(const char *driver_name, uint8_t driver_id, - int idx_type, const void *asym_cap), - rte_trace_point_emit_string(driver_name); - rte_trace_point_emit_u8(driver_id); - rte_trace_point_emit_int(idx_type); - rte_trace_point_emit_ptr(asym_cap); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_get_private_session_size, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint32_t priv_sess_size), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u32(priv_sess_size); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_get_xform_enum, - RTE_TRACE_POINT_ARGS(const char *xform_string, - enum rte_crypto_asym_xform_type xform_enum, int ret), - rte_trace_point_emit_string(xform_string); - rte_trace_point_emit_int(xform_enum); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_xform_capability_check_modlen, - RTE_TRACE_POINT_ARGS(const void *capability, uint16_t modlen, int ret), - rte_trace_point_emit_ptr(capability); - rte_trace_point_emit_u16(modlen); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_cpu_crypto_process, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const void *sess), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sess); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_session_get_user_data, - RTE_TRACE_POINT_ARGS(const void *sess, const void *data), - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_ptr(data); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_sym_session_set_user_data, - RTE_TRACE_POINT_ARGS(const void *sess, const void *data, uint16_t size), - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_ptr(data); - rte_trace_point_emit_u16(size); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_qp_status, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t queue_pair_id, int ret), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(queue_pair_id); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_configure_raw_dp_ctx, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, int sess_type), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(qp_id); - rte_trace_point_emit_int(sess_type); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_get_raw_dp_ctx_size, - RTE_TRACE_POINT_ARGS(uint8_t dev_id), - rte_trace_point_emit_u8(dev_id); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_add_deq_callback, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, const void *cb_fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(qp_id); - rte_trace_point_emit_ptr(cb_fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_add_enq_callback, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, const void *cb_fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(qp_id); - rte_trace_point_emit_ptr(cb_fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_remove_deq_callback, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, const void *fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(qp_id); - rte_trace_point_emit_ptr(fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_remove_enq_callback, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id, const void *fn), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_u16(qp_id); - rte_trace_point_emit_ptr(fn); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_session_get_user_data, - RTE_TRACE_POINT_ARGS(const void *sess, const void *data), - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_ptr(data); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_session_set_user_data, - RTE_TRACE_POINT_ARGS(const void *sess, const void *data, uint16_t size), - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_ptr(data); - rte_trace_point_emit_u16(size); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_session_event_mdata_set, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, const void *sess, int op_type, - int sess_type, const void *ev_mdata, uint16_t size), - rte_trace_point_emit_u8(dev_id); - rte_trace_point_emit_ptr(sess); - rte_trace_point_emit_int(op_type); - rte_trace_point_emit_int(sess_type); - rte_trace_point_emit_ptr(ev_mdata); - rte_trace_point_emit_u16(size); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_allocate_driver, - RTE_TRACE_POINT_ARGS(const char *name), - rte_trace_point_emit_string(name); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_op_pool_create, - RTE_TRACE_POINT_ARGS(const char *name, int socket_id, int type, - uint32_t nb_elts, const void *mp), - rte_trace_point_emit_string(name); - rte_trace_point_emit_int(socket_id); - rte_trace_point_emit_int(type); - rte_trace_point_emit_u32(nb_elts); - rte_trace_point_emit_ptr(mp); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_asym_xform_capability_check_optype, - RTE_TRACE_POINT_ARGS(uint32_t op_types, - enum rte_crypto_asym_op_type op_type, int ret), - rte_trace_point_emit_u32(op_types); - rte_trace_point_emit_int(op_type); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_cryptodev_trace_count, - RTE_TRACE_POINT_ARGS(uint8_t nb_devs), - rte_trace_point_emit_u8(nb_devs); -) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_CRYPTODEV_TRACE_H_ */ diff --git a/dpdk/lib/eal/common/eal_common_log.c b/dpdk/lib/eal/common/eal_common_log.c deleted file mode 100644 index bd7b188ce..000000000 --- a/dpdk/lib/eal/common/eal_common_log.c +++ /dev/null @@ -1,548 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "eal_log.h" -#include "eal_private.h" - -struct rte_log_dynamic_type { - const char *name; - uint32_t loglevel; -}; - -/** The rte_log structure. */ -static struct rte_logs { - uint32_t type; /**< Bitfield with enabled logs. */ - uint32_t level; /**< Log level. */ - FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */ - size_t dynamic_types_len; - struct rte_log_dynamic_type *dynamic_types; -} rte_logs = { - .type = UINT32_MAX, - .level = RTE_LOG_DEBUG, -}; - -struct rte_eal_opt_loglevel { - /** Next list entry */ - TAILQ_ENTRY(rte_eal_opt_loglevel) next; - /** Compiled regular expression obtained from the option */ - regex_t re_match; - /** Globbing pattern option */ - char *pattern; - /** Log level value obtained from the option */ - uint32_t level; -}; - -TAILQ_HEAD(rte_eal_opt_loglevel_list, rte_eal_opt_loglevel); - -/** List of valid EAL log level options */ -static struct rte_eal_opt_loglevel_list opt_loglevel_list = - TAILQ_HEAD_INITIALIZER(opt_loglevel_list); - -/* Stream to use for logging if rte_logs.file is NULL */ -static FILE *default_log_stream; - -/** - * This global structure stores some information about the message - * that is currently being processed by one lcore - */ -struct log_cur_msg { - uint32_t loglevel; /**< log level - see rte_log.h */ - uint32_t logtype; /**< log type - see rte_log.h */ -}; - - /* per core log */ -static RTE_DEFINE_PER_LCORE(struct log_cur_msg, log_cur_msg); - -/* default logs */ - -/* Change the stream that will be used by logging system */ -int -rte_openlog_stream(FILE *f) -{ - rte_logs.file = f; - return 0; -} - -FILE * -rte_log_get_stream(void) -{ - FILE *f = rte_logs.file; - - if (f == NULL) { - /* - * Grab the current value of stderr here, rather than - * just initializing default_log_stream to stderr. This - * ensures that we will always use the current value - * of stderr, even if the application closes and - * reopens it. - */ - return default_log_stream ? : stderr; - } - return f; -} - -/* Set global log level */ -void -rte_log_set_global_level(uint32_t level) -{ - rte_logs.level = (uint32_t)level; -} - -/* Get global log level */ -uint32_t -rte_log_get_global_level(void) -{ - return rte_logs.level; -} - -int -rte_log_get_level(uint32_t type) -{ - if (type >= rte_logs.dynamic_types_len) - return -1; - - return rte_logs.dynamic_types[type].loglevel; -} - -bool -rte_log_can_log(uint32_t logtype, uint32_t level) -{ - int log_level; - - if (level > rte_log_get_global_level()) - return false; - - log_level = rte_log_get_level(logtype); - if (log_level < 0) - return false; - - if (level > (uint32_t)log_level) - return false; - - return true; -} - -static void -logtype_set_level(uint32_t type, uint32_t level) -{ - uint32_t current = rte_logs.dynamic_types[type].loglevel; - - if (current != level) { - rte_logs.dynamic_types[type].loglevel = level; - RTE_LOG(DEBUG, EAL, "%s log level changed from %s to %s\n", - rte_logs.dynamic_types[type].name == NULL ? - "" : rte_logs.dynamic_types[type].name, - eal_log_level2str(current), - eal_log_level2str(level)); - } -} - -int -rte_log_set_level(uint32_t type, uint32_t level) -{ - if (type >= rte_logs.dynamic_types_len) - return -1; - if (level > RTE_LOG_MAX) - return -1; - - logtype_set_level(type, level); - - return 0; -} - -/* set log level by regular expression */ -int -rte_log_set_level_regexp(const char *regex, uint32_t level) -{ - regex_t r; - size_t i; - - if (level > RTE_LOG_MAX) - return -1; - - if (regcomp(&r, regex, 0) != 0) - return -1; - - for (i = 0; i < rte_logs.dynamic_types_len; i++) { - if (rte_logs.dynamic_types[i].name == NULL) - continue; - if (regexec(&r, rte_logs.dynamic_types[i].name, 0, - NULL, 0) == 0) - logtype_set_level(i, level); - } - - regfree(&r); - - return 0; -} - -/* - * Save the type string and the loglevel for later dynamic - * logtypes which may register later. - */ -static int -log_save_level(uint32_t priority, const char *regex, const char *pattern) -{ - struct rte_eal_opt_loglevel *opt_ll = NULL; - - opt_ll = malloc(sizeof(*opt_ll)); - if (opt_ll == NULL) - goto fail; - - opt_ll->level = priority; - - if (regex) { - opt_ll->pattern = NULL; - if (regcomp(&opt_ll->re_match, regex, 0) != 0) - goto fail; - } else if (pattern) { - opt_ll->pattern = strdup(pattern); - if (opt_ll->pattern == NULL) - goto fail; - } else - goto fail; - - TAILQ_INSERT_HEAD(&opt_loglevel_list, opt_ll, next); - return 0; -fail: - free(opt_ll); - return -1; -} - -int -eal_log_save_regexp(const char *regex, uint32_t level) -{ - return log_save_level(level, regex, NULL); -} - -/* set log level based on globbing pattern */ -int -rte_log_set_level_pattern(const char *pattern, uint32_t level) -{ - size_t i; - - if (level > RTE_LOG_MAX) - return -1; - - for (i = 0; i < rte_logs.dynamic_types_len; i++) { - if (rte_logs.dynamic_types[i].name == NULL) - continue; - - if (fnmatch(pattern, rte_logs.dynamic_types[i].name, 0) == 0) - logtype_set_level(i, level); - } - - return 0; -} - -int -eal_log_save_pattern(const char *pattern, uint32_t level) -{ - return log_save_level(level, NULL, pattern); -} - -/* get the current loglevel for the message being processed */ -int rte_log_cur_msg_loglevel(void) -{ - return RTE_PER_LCORE(log_cur_msg).loglevel; -} - -/* get the current logtype for the message being processed */ -int rte_log_cur_msg_logtype(void) -{ - return RTE_PER_LCORE(log_cur_msg).logtype; -} - -static int -log_lookup(const char *name) -{ - size_t i; - - for (i = 0; i < rte_logs.dynamic_types_len; i++) { - if (rte_logs.dynamic_types[i].name == NULL) - continue; - if (strcmp(name, rte_logs.dynamic_types[i].name) == 0) - return i; - } - - return -1; -} - -static int -log_register(const char *name, uint32_t level) -{ - struct rte_log_dynamic_type *new_dynamic_types; - int id; - - id = log_lookup(name); - if (id >= 0) - return id; - - new_dynamic_types = realloc(rte_logs.dynamic_types, - sizeof(struct rte_log_dynamic_type) * - (rte_logs.dynamic_types_len + 1)); - if (new_dynamic_types == NULL) - return -ENOMEM; - rte_logs.dynamic_types = new_dynamic_types; - - id = rte_logs.dynamic_types_len; - memset(&rte_logs.dynamic_types[id], 0, - sizeof(rte_logs.dynamic_types[id])); - rte_logs.dynamic_types[id].name = strdup(name); - if (rte_logs.dynamic_types[id].name == NULL) - return -ENOMEM; - logtype_set_level(id, level); - - rte_logs.dynamic_types_len++; - - return id; -} - -/* register an extended log type */ -int -rte_log_register(const char *name) -{ - return log_register(name, RTE_LOG_INFO); -} - -/* Register an extended log type and try to pick its level from EAL options */ -int -rte_log_register_type_and_pick_level(const char *name, uint32_t level_def) -{ - struct rte_eal_opt_loglevel *opt_ll; - uint32_t level = level_def; - - TAILQ_FOREACH(opt_ll, &opt_loglevel_list, next) { - if (opt_ll->level > RTE_LOG_MAX) - continue; - - if (opt_ll->pattern) { - if (fnmatch(opt_ll->pattern, name, 0) == 0) - level = opt_ll->level; - } else { - if (regexec(&opt_ll->re_match, name, 0, NULL, 0) == 0) - level = opt_ll->level; - } - } - - return log_register(name, level); -} - -struct logtype { - uint32_t log_id; - const char *logtype; -}; - -static const struct logtype logtype_strings[] = { - {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MALLOC, "lib.malloc"}, - {RTE_LOGTYPE_RING, "lib.ring"}, - {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, - {RTE_LOGTYPE_TIMER, "lib.timer"}, - {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_LPM, "lib.lpm"}, - {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_ACL, "lib.acl"}, - {RTE_LOGTYPE_POWER, "lib.power"}, - {RTE_LOGTYPE_METER, "lib.meter"}, - {RTE_LOGTYPE_SCHED, "lib.sched"}, - {RTE_LOGTYPE_PORT, "lib.port"}, - {RTE_LOGTYPE_TABLE, "lib.table"}, - {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, - {RTE_LOGTYPE_MBUF, "lib.mbuf"}, - {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, - {RTE_LOGTYPE_EFD, "lib.efd"}, - {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, - {RTE_LOGTYPE_GSO, "lib.gso"}, - {RTE_LOGTYPE_USER1, "user1"}, - {RTE_LOGTYPE_USER2, "user2"}, - {RTE_LOGTYPE_USER3, "user3"}, - {RTE_LOGTYPE_USER4, "user4"}, - {RTE_LOGTYPE_USER5, "user5"}, - {RTE_LOGTYPE_USER6, "user6"}, - {RTE_LOGTYPE_USER7, "user7"}, - {RTE_LOGTYPE_USER8, "user8"} -}; - -/* Logging should be first initializer (before drivers and bus) */ -RTE_INIT_PRIO(log_init, LOG) -{ - uint32_t i; - - rte_log_set_global_level(RTE_LOG_DEBUG); - - rte_logs.dynamic_types = calloc(RTE_LOGTYPE_FIRST_EXT_ID, - sizeof(struct rte_log_dynamic_type)); - if (rte_logs.dynamic_types == NULL) - return; - - /* register legacy log types */ - for (i = 0; i < RTE_DIM(logtype_strings); i++) { - rte_logs.dynamic_types[logtype_strings[i].log_id].name = - strdup(logtype_strings[i].logtype); - logtype_set_level(logtype_strings[i].log_id, RTE_LOG_INFO); - } - - rte_logs.dynamic_types_len = RTE_LOGTYPE_FIRST_EXT_ID; -} - -const char * -eal_log_level2str(uint32_t level) -{ - switch (level) { - case 0: return "disabled"; - case RTE_LOG_EMERG: return "emergency"; - case RTE_LOG_ALERT: return "alert"; - case RTE_LOG_CRIT: return "critical"; - case RTE_LOG_ERR: return "error"; - case RTE_LOG_WARNING: return "warning"; - case RTE_LOG_NOTICE: return "notice"; - case RTE_LOG_INFO: return "info"; - case RTE_LOG_DEBUG: return "debug"; - default: return "unknown"; - } -} - -static int -log_type_compare(const void *a, const void *b) -{ - const struct rte_log_dynamic_type *type_a = a; - const struct rte_log_dynamic_type *type_b = b; - - if (type_a->name == NULL && type_b->name == NULL) - return 0; - if (type_a->name == NULL) - return -1; - if (type_b->name == NULL) - return 1; - return strcmp(type_a->name, type_b->name); -} - -/* Dump name of each logtype, one per line. */ -void -rte_log_list_types(FILE *out, const char *prefix) -{ - struct rte_log_dynamic_type *sorted_types; - const size_t type_size = sizeof(rte_logs.dynamic_types[0]); - const size_t type_count = rte_logs.dynamic_types_len; - const size_t total_size = type_size * type_count; - size_t type; - - sorted_types = malloc(total_size); - if (sorted_types == NULL) { - /* no sorting - unlikely */ - sorted_types = rte_logs.dynamic_types; - } else { - memcpy(sorted_types, rte_logs.dynamic_types, total_size); - qsort(sorted_types, type_count, type_size, log_type_compare); - } - - for (type = 0; type < type_count; ++type) { - if (sorted_types[type].name == NULL) - continue; - fprintf(out, "%s%s\n", prefix, sorted_types[type].name); - } - - if (sorted_types != rte_logs.dynamic_types) - free(sorted_types); -} - -/* dump global level and registered log types */ -void -rte_log_dump(FILE *f) -{ - size_t i; - - fprintf(f, "global log level is %s\n", - eal_log_level2str(rte_log_get_global_level())); - - for (i = 0; i < rte_logs.dynamic_types_len; i++) { - if (rte_logs.dynamic_types[i].name == NULL) - continue; - fprintf(f, "id %zu: %s, level is %s\n", - i, rte_logs.dynamic_types[i].name, - eal_log_level2str(rte_logs.dynamic_types[i].loglevel)); - } -} - -/* - * Generates a log message The message will be sent in the stream - * defined by the previous call to rte_openlog_stream(). - */ -int -rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) -{ - FILE *f = rte_log_get_stream(); - int ret; - - if (logtype >= rte_logs.dynamic_types_len) - return -1; - if (!rte_log_can_log(logtype, level)) - return 0; - - /* save loglevel and logtype in a global per-lcore variable */ - RTE_PER_LCORE(log_cur_msg).loglevel = level; - RTE_PER_LCORE(log_cur_msg).logtype = logtype; - - ret = vfprintf(f, format, ap); - fflush(f); - return ret; -} - -/* - * Generates a log message The message will be sent in the stream - * defined by the previous call to rte_openlog_stream(). - * No need to check level here, done by rte_vlog(). - */ -int -rte_log(uint32_t level, uint32_t logtype, const char *format, ...) -{ - va_list ap; - int ret; - - va_start(ap, format); - ret = rte_vlog(level, logtype, format, ap); - va_end(ap); - return ret; -} - -/* - * Called by environment-specific initialization functions. - */ -void -eal_log_set_default(FILE *default_log) -{ - default_log_stream = default_log; - -#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG - RTE_LOG(NOTICE, EAL, - "Debug dataplane logs available - lower performance\n"); -#endif -} - -/* - * Called by eal_cleanup - */ -void -rte_eal_log_cleanup(void) -{ - if (default_log_stream) { - fclose(default_log_stream); - default_log_stream = NULL; - } -} diff --git a/dpdk/lib/eal/common/eal_log.h b/dpdk/lib/eal/common/eal_log.h deleted file mode 100644 index c784fa604..000000000 --- a/dpdk/lib/eal/common/eal_log.h +++ /dev/null @@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2021 Mellanox Technologies, Ltd - */ - -#ifndef EAL_LOG_H -#define EAL_LOG_H - -#include -#include - -/* - * Initialize the default log stream. - */ -int eal_log_init(const char *id, int facility); - -/* - * Determine where log data is written when no call to rte_openlog_stream. - */ -void eal_log_set_default(FILE *default_log); - -/* - * Save a log option for later. - */ -int eal_log_save_regexp(const char *regexp, uint32_t level); -int eal_log_save_pattern(const char *pattern, uint32_t level); - -/* - * Convert log level to string. - */ -const char *eal_log_level2str(uint32_t level); - -#endif /* EAL_LOG_H */ diff --git a/dpdk/lib/eal/include/rte_log.h b/dpdk/lib/eal/include/rte_log.h deleted file mode 100644 index 6d2b0856a..000000000 --- a/dpdk/lib/eal/include/rte_log.h +++ /dev/null @@ -1,409 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2017 Intel Corporation - */ - -#ifndef _RTE_LOG_H_ -#define _RTE_LOG_H_ - -/** - * @file - * - * RTE Logs API - * - * This file provides a log API to RTE applications. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#include -#include - -/* SDK log type */ -#define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ -#define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ -#define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ -#define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ -#define RTE_LOGTYPE_TIMER 4 /**< Log related to timers. */ -#define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ -#define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ -#define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ -#define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ -#define RTE_LOGTYPE_ACL 9 /**< Log related to ACL. */ -#define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ -#define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ -#define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ -#define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ -#define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ -#define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ -#define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ -#define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ -#define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ -#define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ -#define RTE_LOGTYPE_GSO 20 /**< Log related to GSO. */ - -/* these log types can be used in an application */ -#define RTE_LOGTYPE_USER1 24 /**< User-defined log type 1. */ -#define RTE_LOGTYPE_USER2 25 /**< User-defined log type 2. */ -#define RTE_LOGTYPE_USER3 26 /**< User-defined log type 3. */ -#define RTE_LOGTYPE_USER4 27 /**< User-defined log type 4. */ -#define RTE_LOGTYPE_USER5 28 /**< User-defined log type 5. */ -#define RTE_LOGTYPE_USER6 29 /**< User-defined log type 6. */ -#define RTE_LOGTYPE_USER7 30 /**< User-defined log type 7. */ -#define RTE_LOGTYPE_USER8 31 /**< User-defined log type 8. */ - -/** First identifier for extended logs */ -#define RTE_LOGTYPE_FIRST_EXT_ID 32 - -/* Can't use 0, as it gives compiler warnings */ -#define RTE_LOG_EMERG 1U /**< System is unusable. */ -#define RTE_LOG_ALERT 2U /**< Action must be taken immediately. */ -#define RTE_LOG_CRIT 3U /**< Critical conditions. */ -#define RTE_LOG_ERR 4U /**< Error conditions. */ -#define RTE_LOG_WARNING 5U /**< Warning conditions. */ -#define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */ -#define RTE_LOG_INFO 7U /**< Informational. */ -#define RTE_LOG_DEBUG 8U /**< Debug-level messages. */ -#define RTE_LOG_MAX RTE_LOG_DEBUG /**< Most detailed log level. */ - -/** - * Change the stream that will be used by the logging system. - * - * This can be done at any time. The f argument represents the stream - * to be used to send the logs. If f is NULL, the default output is - * used (stderr). - * - * @param f - * Pointer to the stream. - * @return - * - 0 on success. - * - Negative on error. - */ -int rte_openlog_stream(FILE *f); - -/** - * Retrieve the stream used by the logging system (see rte_openlog_stream() - * to change it). - * - * @return - * Pointer to the stream. - */ -FILE *rte_log_get_stream(void); - -/** - * Set the global log level. - * - * After this call, logs with a level lower or equal than the level - * passed as argument will be displayed. - * - * @param level - * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). - */ -void rte_log_set_global_level(uint32_t level); - -/** - * Get the global log level. - * - * @return - * The current global log level. - */ -uint32_t rte_log_get_global_level(void); - -/** - * Get the log level for a given type. - * - * @param logtype - * The log type identifier. - * @return - * 0 on success, a negative value if logtype is invalid. - */ -int rte_log_get_level(uint32_t logtype); - -/** - * For a given `logtype`, check if a log with `loglevel` can be printed. - * - * @param logtype - * The log type identifier - * @param loglevel - * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). - * @return - * Returns 'true' if log can be printed and 'false' if it can't. - */ -bool rte_log_can_log(uint32_t logtype, uint32_t loglevel); - -/** - * Set the log level for a given type based on globbing pattern. - * - * @param pattern - * The globbing pattern identifying the log type. - * @param level - * The level to be set. - * @return - * 0 on success, a negative value if level is invalid. - */ -int rte_log_set_level_pattern(const char *pattern, uint32_t level); - -/** - * Set the log level for a given type based on regular expression. - * - * @param regex - * The regular expression identifying the log type. - * @param level - * The level to be set. - * @return - * 0 on success, a negative value if level is invalid. - */ -int rte_log_set_level_regexp(const char *regex, uint32_t level); - -/** - * Set the log level for a given type. - * - * @param logtype - * The log type identifier. - * @param level - * The level to be set. - * @return - * 0 on success, a negative value if logtype or level is invalid. - */ -int rte_log_set_level(uint32_t logtype, uint32_t level); - -/** - * Get the current loglevel for the message being processed. - * - * Before calling the user-defined stream for logging, the log - * subsystem sets a per-lcore variable containing the loglevel and the - * logtype of the message being processed. This information can be - * accessed by the user-defined log output function through this - * function. - * - * @return - * The loglevel of the message being processed. - */ -int rte_log_cur_msg_loglevel(void); - -/** - * Get the current logtype for the message being processed. - * - * Before calling the user-defined stream for logging, the log - * subsystem sets a per-lcore variable containing the loglevel and the - * logtype of the message being processed. This information can be - * accessed by the user-defined log output function through this - * function. - * - * @return - * The logtype of the message being processed. - */ -int rte_log_cur_msg_logtype(void); - -/** - * Register a dynamic log type - * - * If a log is already registered with the same type, the returned value - * is the same than the previous one. - * - * @param name - * The string identifying the log type. - * @return - * - >0: success, the returned value is the log type identifier. - * - (-ENOMEM): cannot allocate memory. - */ -int rte_log_register(const char *name); - -/** - * Register a dynamic log type and try to pick its level from EAL options - * - * rte_log_register() is called inside. If successful, the function tries - * to search for matching regexp in the list of EAL log level options and - * pick the level from the last matching entry. If nothing can be applied - * from the list, the level will be set to the user-defined default value. - * - * @param name - * Name for the log type to be registered - * @param level_def - * Fallback level to be set if the global list has no matching options - * @return - * - >=0: the newly registered log type - * - <0: rte_log_register() error value - */ -int rte_log_register_type_and_pick_level(const char *name, uint32_t level_def); - -/** - * Dump name of each logtype, one per line. - * - * @param out - * Stream where the list is sent. - * @param prefix - * String preceding each logtype in the output. - */ -void rte_log_list_types(FILE *out, const char *prefix); - -/** - * Dump log information. - * - * Dump the global level and the registered log types. - * - * @param f - * The output stream where the dump should be sent. - */ -void rte_log_dump(FILE *f); - -/** - * Generates a log message. - * - * The message will be sent in the stream defined by the previous call - * to rte_openlog_stream(). - * - * The level argument determines if the log should be displayed or - * not, depending on the loglevel settings. - * - * The preferred alternative is the RTE_LOG() because it adds the - * level and type in the logged string. - * - * @param level - * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). - * @param logtype - * The log type, for example, RTE_LOGTYPE_EAL. - * @param format - * The format string, as in printf(3), followed by the variable arguments - * required by the format. - * @return - * - 0: Success. - * - Negative on error. - */ -int rte_log(uint32_t level, uint32_t logtype, const char *format, ...) -#ifdef __GNUC__ -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) - __rte_cold -#endif -#endif - __rte_format_printf(3, 4); - -/** - * Generates a log message. - * - * The message will be sent in the stream defined by the previous call - * to rte_openlog_stream(). - * - * The level argument determines if the log should be displayed or - * not, depending on the loglevel settings. A trailing - * newline may be added if needed. - * - * The preferred alternative is the RTE_LOG() because it adds the - * level and type in the logged string. - * - * @param level - * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). - * @param logtype - * The log type, for example, RTE_LOGTYPE_EAL. - * @param format - * The format string, as in printf(3), followed by the variable arguments - * required by the format. - * @param ap - * The va_list of the variable arguments required by the format. - * @return - * - 0: Success. - * - Negative on error. - */ -int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) - __rte_format_printf(3, 0); - -/** - * Generates a log message. - * - * The RTE_LOG() is a helper that prefixes the string with the log level - * and type, and call rte_log(). - * - * @param l - * Log level. A value between EMERG (1) and DEBUG (8). The short name is - * expanded by the macro, so it cannot be an integer value. - * @param t - * The log type, for example, EAL. The short name is expanded by the - * macro, so it cannot be an integer value. - * @param ... - * The fmt string, as in printf(3), followed by the variable arguments - * required by the format. - * @return - * - 0: Success. - * - Negative on error. - */ -#define RTE_LOG(l, t, ...) \ - rte_log(RTE_LOG_ ## l, \ - RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) - -/** - * Generates a log message for data path. - * - * Similar to RTE_LOG(), except that it is removed at compilation time - * if the RTE_LOG_DP_LEVEL configuration option is lower than the log - * level argument. - * - * @param l - * Log level. A value between EMERG (1) and DEBUG (8). The short name is - * expanded by the macro, so it cannot be an integer value. - * @param t - * The log type, for example, EAL. The short name is expanded by the - * macro, so it cannot be an integer value. - * @param ... - * The fmt string, as in printf(3), followed by the variable arguments - * required by the format. - * @return - * - 0: Success. - * - Negative on error. - */ -#define RTE_LOG_DP(l, t, ...) \ - (void)((RTE_LOG_ ## l <= RTE_LOG_DP_LEVEL) ? \ - rte_log(RTE_LOG_ ## l, \ - RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ - 0) - -#define RTE_LOG_REGISTER_IMPL(type, name, level) \ -int type; \ -RTE_INIT(__##type) \ -{ \ - type = rte_log_register_type_and_pick_level(name, RTE_LOG_##level); \ - if (type < 0) \ - type = RTE_LOGTYPE_EAL; \ -} - -/** - * Register a dynamic log type in constructor context with its name and level. - * - * It is a wrapper macro for declaring the logtype, register the log and - * sets it's level in the constructor context. - * - * @param type - * The log type identifier - * @param name - * Name for the log type to be registered - * @param level - * Log level. A value between EMERG (1) and DEBUG (8). - */ -#define RTE_LOG_REGISTER(type, name, level) \ - RTE_LOG_REGISTER_IMPL(type, RTE_STR(name), level) - -/** - * This is an equivalent to RTE_LOG_REGISTER, but relying on the build system - * to select the right format for the logtype. - */ -#define RTE_LOG_REGISTER_DEFAULT(type, level) \ - RTE_LOG_REGISTER_IMPL(type, RTE_STR(RTE_LOG_DEFAULT_LOGTYPE), level) - -/** - * This is an equivalent to RTE_LOG_REGISTER, but relying on the build system - * to select the right prefix for the logtype. - */ -#define RTE_LOG_REGISTER_SUFFIX(type, suffix, level) \ - RTE_LOG_REGISTER_IMPL(type, \ - RTE_STR(RTE_LOG_DEFAULT_LOGTYPE) "." RTE_STR(suffix), level) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_LOG_H_ */ diff --git a/dpdk/lib/eal/linux/eal_log.c b/dpdk/lib/eal/linux/eal_log.c deleted file mode 100644 index d44416fd6..000000000 --- a/dpdk/lib/eal/linux/eal_log.c +++ /dev/null @@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#include -#include -#include - -#include - -#include "eal_log.h" - -/* - * default log function - */ -static ssize_t -console_log_write(__rte_unused void *c, const char *buf, size_t size) -{ - ssize_t ret; - - /* write on stderr */ - ret = fwrite(buf, 1, size, stderr); - fflush(stderr); - - /* Syslog error levels are from 0 to 7, so subtract 1 to convert */ - syslog(rte_log_cur_msg_loglevel() - 1, "%.*s", (int)size, buf); - - return ret; -} - -static int -console_log_close(__rte_unused void *c) -{ - closelog(); - return 0; -} - -static cookie_io_functions_t console_log_func = { - .write = console_log_write, - .close = console_log_close, -}; - -/* - * set the log to default function, called during eal init process, - * once memzones are available. - */ -int -eal_log_init(const char *id, int facility) -{ - FILE *log_stream; - - log_stream = fopencookie(NULL, "w+", console_log_func); - if (log_stream == NULL) - return -1; - - openlog(id, LOG_NDELAY | LOG_PID, facility); - - eal_log_set_default(log_stream); - - return 0; -} diff --git a/dpdk/lib/eal/windows/eal_log.c b/dpdk/lib/eal/windows/eal_log.c deleted file mode 100644 index d4ea47f1c..000000000 --- a/dpdk/lib/eal/windows/eal_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017-2018 Intel Corporation - */ - -#include -#include -#include "eal_log.h" - -/* set the log to default function, called during eal init process. */ -int -eal_log_init(__rte_unused const char *id, __rte_unused int facility) -{ - rte_openlog_stream(stderr); - - eal_log_set_default(stderr); - - return 0; -} diff --git a/dpdk/lib/eal/windows/fnmatch.c b/dpdk/lib/eal/windows/fnmatch.c deleted file mode 100644 index f622bf54c..000000000 --- a/dpdk/lib/eal/windows/fnmatch.c +++ /dev/null @@ -1,172 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. - * Compares a filename or pathname to a pattern. - */ - -#include -#include -#include - -#include "fnmatch.h" - -#define EOS '\0' - -static const char *rangematch(const char *, char, int); - -int -fnmatch(const char *pattern, const char *string, int flags) -{ - const char *stringstart; - char c, test; - - for (stringstart = string;;) - switch (c = *pattern++) { - case EOS: - if ((flags & FNM_LEADING_DIR) && *string == '/') - return (0); - return (*string == EOS ? 0 : FNM_NOMATCH); - case '?': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - ++string; - break; - case '*': - c = *pattern; - /* Collapse multiple stars. */ - while (c == '*') - c = *++pattern; - - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - /* Optimize for pattern with * at end or before /. */ - if (c == EOS) - if (flags & FNM_PATHNAME) - return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? - 0 : FNM_NOMATCH); - else - return (0); - else if (c == '/' && flags & FNM_PATHNAME) { - string = strchr(string, '/'); - if (string == NULL) - return (FNM_NOMATCH); - break; - } - - /* General case, use recursion. */ - while ((test = *string) != EOS) { - if (!fnmatch(pattern, string, - flags & ~FNM_PERIOD)) - return (0); - if (test == '/' && flags & FNM_PATHNAME) - break; - ++string; - } - return (FNM_NOMATCH); - case '[': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && flags & FNM_PATHNAME) - return (FNM_NOMATCH); - pattern = rangematch(pattern, *string, flags); - if (pattern == NULL) - return (FNM_NOMATCH); - ++string; - break; - case '\\': - if (!(flags & FNM_NOESCAPE)) { - c = *pattern++; - if (c == EOS) { - c = '\\'; - --pattern; - } - } - /* FALLTHROUGH */ - default: - if (c == *string) - ; - else if ((flags & FNM_CASEFOLD) && - (tolower((unsigned char)c) == - tolower((unsigned char)*string))) - ; - else if ((flags & FNM_PREFIX_DIRS) && *string == EOS && - ((c == '/' && string != stringstart) || - (string == stringstart+1 && *stringstart == '/'))) - return (0); - else - return (FNM_NOMATCH); - string++; - break; - } - /* NOTREACHED */ -} - -static const char * -rangematch(const char *pattern, char test, int flags) -{ - int negate, ok; - char c, c2; - - /* - * A bracket expression starting with an unquoted circumflex - * character produces unspecified results (IEEE 1003.2-1992, - * 3.13.2). This implementation treats it like '!', for - * consistency with the regular expression syntax. - * J.T. Conklin (conklin@ngai.kaleida.com) - */ - negate = (*pattern == '!' || *pattern == '^'); - if (negate) - ++pattern; - - if (flags & FNM_CASEFOLD) - test = tolower((unsigned char)test); - - for (ok = 0; (c = *pattern++) != ']';) { - if (c == '\\' && !(flags & FNM_NOESCAPE)) - c = *pattern++; - if (c == EOS) - return (NULL); - - if (flags & FNM_CASEFOLD) - c = tolower((unsigned char)c); - - c2 = *(pattern + 1); - if (*pattern == '-' && c2 != EOS && c2 != ']') { - pattern += 2; - if (c2 == '\\' && !(flags & FNM_NOESCAPE)) - c2 = *pattern++; - if (c2 == EOS) - return (NULL); - - if (flags & FNM_CASEFOLD) - c2 = tolower((unsigned char)c2); - - if ((unsigned char)c <= (unsigned char)test && - (unsigned char)test <= (unsigned char)c2) - ok = 1; - } else if (c == test) - ok = 1; - } - return (ok == negate ? NULL : pattern); -} diff --git a/dpdk/lib/ethdev/rte_ethdev_trace.h b/dpdk/lib/ethdev/rte_ethdev_trace.h deleted file mode 100644 index 1491c815c..000000000 --- a/dpdk/lib/ethdev/rte_ethdev_trace.h +++ /dev/null @@ -1,95 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2020 Marvell International Ltd. - */ - -#ifndef _RTE_ETHDEV_TRACE_H_ -#define _RTE_ETHDEV_TRACE_H_ - -/** - * @file - * - * API for ethdev trace support - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include "rte_ethdev.h" - -RTE_TRACE_POINT( - rte_ethdev_trace_configure, - RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t nb_rx_q, - uint16_t nb_tx_q, const struct rte_eth_conf *dev_conf, int rc), - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u16(nb_rx_q); - rte_trace_point_emit_u16(nb_tx_q); - rte_trace_point_emit_u32(dev_conf->link_speeds); - rte_trace_point_emit_u32(dev_conf->rxmode.mq_mode); - rte_trace_point_emit_u32(dev_conf->rxmode.mtu); - rte_trace_point_emit_u64(dev_conf->rxmode.offloads); - rte_trace_point_emit_u32(dev_conf->txmode.mq_mode); - rte_trace_point_emit_u64(dev_conf->txmode.offloads); - rte_trace_point_emit_u32(dev_conf->lpbk_mode); - rte_trace_point_emit_int(rc); -) - -RTE_TRACE_POINT( - rte_ethdev_trace_rxq_setup, - RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t rx_queue_id, - uint16_t nb_rx_desc, void *mp, - const struct rte_eth_rxconf *rx_conf, int rc), - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u16(rx_queue_id); - rte_trace_point_emit_u16(nb_rx_desc); - rte_trace_point_emit_ptr(mp); - rte_trace_point_emit_u8(rx_conf->rx_thresh.pthresh); - rte_trace_point_emit_u8(rx_conf->rx_thresh.hthresh); - rte_trace_point_emit_u8(rx_conf->rx_thresh.wthresh); - rte_trace_point_emit_u8(rx_conf->rx_drop_en); - rte_trace_point_emit_u8(rx_conf->rx_deferred_start); - rte_trace_point_emit_u64(rx_conf->offloads); - rte_trace_point_emit_int(rc); -) - -RTE_TRACE_POINT( - rte_ethdev_trace_txq_setup, - RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t tx_queue_id, - uint16_t nb_tx_desc, const struct rte_eth_txconf *tx_conf), - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_u16(tx_queue_id); - rte_trace_point_emit_u16(nb_tx_desc); - rte_trace_point_emit_u8(tx_conf->tx_thresh.pthresh); - rte_trace_point_emit_u8(tx_conf->tx_thresh.hthresh); - rte_trace_point_emit_u8(tx_conf->tx_thresh.wthresh); - rte_trace_point_emit_u8(tx_conf->tx_deferred_start); - rte_trace_point_emit_u16(tx_conf->tx_free_thresh); - rte_trace_point_emit_u64(tx_conf->offloads); -) - -RTE_TRACE_POINT( - rte_ethdev_trace_start, - RTE_TRACE_POINT_ARGS(uint16_t port_id), - rte_trace_point_emit_u16(port_id); -) - -RTE_TRACE_POINT( - rte_ethdev_trace_stop, - RTE_TRACE_POINT_ARGS(uint16_t port_id, int ret), - rte_trace_point_emit_u16(port_id); - rte_trace_point_emit_int(ret); -) - -RTE_TRACE_POINT( - rte_ethdev_trace_close, - RTE_TRACE_POINT_ARGS(uint16_t port_id), - rte_trace_point_emit_u16(port_id); -) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_ETHDEV_TRACE_H_ */ diff --git a/dpdk/lib/flow_classify/meson.build b/dpdk/lib/flow_classify/meson.build deleted file mode 100644 index 3bb861c68..000000000 --- a/dpdk/lib/flow_classify/meson.build +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -if is_windows - build = false - reason = 'not supported on Windows' - subdir_done() -endif - -sources = files('rte_flow_classify.c', 'rte_flow_classify_parse.c') -headers = files('rte_flow_classify.h') -deps += ['net', 'table'] diff --git a/dpdk/lib/flow_classify/rte_flow_classify.c b/dpdk/lib/flow_classify/rte_flow_classify.c deleted file mode 100644 index 60ca319f2..000000000 --- a/dpdk/lib/flow_classify/rte_flow_classify.c +++ /dev/null @@ -1,670 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#include -#include -#include "rte_flow_classify_parse.h" -#include - -static uint32_t unique_id = 1; - -enum rte_flow_classify_table_type table_type - = RTE_FLOW_CLASSIFY_TABLE_TYPE_NONE; - -struct rte_flow_classify_table_entry { - /* meta-data for classify rule */ - uint32_t rule_id; - - /* Flow action */ - struct classify_action action; -}; - -struct rte_cls_table { - /* Input parameters */ - struct rte_table_ops ops; - uint32_t entry_size; - enum rte_flow_classify_table_type type; - - /* Handle to the low-level table object */ - void *h_table; -}; - -#define RTE_FLOW_CLASSIFIER_MAX_NAME_SZ 256 - -struct rte_flow_classifier { - /* Input parameters */ - char name[RTE_FLOW_CLASSIFIER_MAX_NAME_SZ]; - int socket_id; - - /* Internal */ - /* ntuple_filter */ - struct rte_eth_ntuple_filter ntuple_filter; - - /* classifier tables */ - struct rte_cls_table tables[RTE_FLOW_CLASSIFY_TABLE_MAX]; - uint32_t table_mask; - uint32_t num_tables; - - uint16_t nb_pkts; - struct rte_flow_classify_table_entry - *entries[RTE_PORT_IN_BURST_SIZE_MAX]; -} __rte_cache_aligned; - -enum { - PROTO_FIELD_IPV4, - SRC_FIELD_IPV4, - DST_FIELD_IPV4, - SRCP_FIELD_IPV4, - DSTP_FIELD_IPV4, - NUM_FIELDS_IPV4 -}; - -struct acl_keys { - struct rte_table_acl_rule_add_params key_add; /* add key */ - struct rte_table_acl_rule_delete_params key_del; /* delete key */ -}; - -struct classify_rules { - enum rte_flow_classify_rule_type type; - union { - struct rte_flow_classify_ipv4_5tuple ipv4_5tuple; - } u; -}; - -struct rte_flow_classify_rule { - uint32_t id; /* unique ID of classify rule */ - enum rte_flow_classify_table_type tbl_type; /* rule table */ - struct classify_rules rules; /* union of rules */ - union { - struct acl_keys key; - } u; - int key_found; /* rule key found in table */ - struct rte_flow_classify_table_entry entry; /* rule meta data */ - void *entry_ptr; /* handle to the table entry for rule meta data */ -}; - -int -rte_flow_classify_validate( - struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_flow_error *error) -{ - struct rte_flow_item *items; - parse_filter_t parse_filter; - uint32_t item_num = 0; - uint32_t i = 0; - int ret; - - if (error == NULL) - return -EINVAL; - - if (cls == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: rte_flow_classifier parameter is NULL\n", - __func__); - return -EINVAL; - } - - if (!attr) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR, - NULL, "NULL attribute."); - return -EINVAL; - } - - if (!pattern) { - rte_flow_error_set(error, - EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM, - NULL, "NULL pattern."); - return -EINVAL; - } - - if (!actions) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_NUM, - NULL, "NULL action."); - return -EINVAL; - } - - memset(&cls->ntuple_filter, 0, sizeof(cls->ntuple_filter)); - - /* Get the non-void item number of pattern */ - while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) { - if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID) - item_num++; - i++; - } - item_num++; - - items = malloc(item_num * sizeof(struct rte_flow_item)); - if (!items) { - rte_flow_error_set(error, ENOMEM, - RTE_FLOW_ERROR_TYPE_ITEM_NUM, - NULL, "No memory for pattern items."); - return -ENOMEM; - } - - memset(items, 0, item_num * sizeof(struct rte_flow_item)); - classify_pattern_skip_void_item(items, pattern); - - parse_filter = classify_find_parse_filter_func(items); - if (!parse_filter) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - pattern, "Unsupported pattern"); - free(items); - return -EINVAL; - } - - ret = parse_filter(attr, items, actions, &cls->ntuple_filter, error); - free(items); - return ret; -} - - -#define uint32_t_to_char(ip, a, b, c, d) do {\ - *a = (unsigned char)(ip >> 24 & 0xff);\ - *b = (unsigned char)(ip >> 16 & 0xff);\ - *c = (unsigned char)(ip >> 8 & 0xff);\ - *d = (unsigned char)(ip & 0xff);\ - } while (0) - -static inline void -print_acl_ipv4_key_add(struct rte_table_acl_rule_add_params *key) -{ - unsigned char a, b, c, d; - - printf("%s: 0x%02hhx/0x%hhx ", __func__, - key->field_value[PROTO_FIELD_IPV4].value.u8, - key->field_value[PROTO_FIELD_IPV4].mask_range.u8); - - uint32_t_to_char(key->field_value[SRC_FIELD_IPV4].value.u32, - &a, &b, &c, &d); - printf(" %hhu.%hhu.%hhu.%hhu/0x%x ", a, b, c, d, - key->field_value[SRC_FIELD_IPV4].mask_range.u32); - - uint32_t_to_char(key->field_value[DST_FIELD_IPV4].value.u32, - &a, &b, &c, &d); - printf("%hhu.%hhu.%hhu.%hhu/0x%x ", a, b, c, d, - key->field_value[DST_FIELD_IPV4].mask_range.u32); - - printf("%hu : 0x%x %hu : 0x%x", - key->field_value[SRCP_FIELD_IPV4].value.u16, - key->field_value[SRCP_FIELD_IPV4].mask_range.u16, - key->field_value[DSTP_FIELD_IPV4].value.u16, - key->field_value[DSTP_FIELD_IPV4].mask_range.u16); - - printf(" priority: 0x%x\n", key->priority); -} - -static inline void -print_acl_ipv4_key_delete(struct rte_table_acl_rule_delete_params *key) -{ - unsigned char a, b, c, d; - - printf("%s: 0x%02hhx/0x%hhx ", __func__, - key->field_value[PROTO_FIELD_IPV4].value.u8, - key->field_value[PROTO_FIELD_IPV4].mask_range.u8); - - uint32_t_to_char(key->field_value[SRC_FIELD_IPV4].value.u32, - &a, &b, &c, &d); - printf(" %hhu.%hhu.%hhu.%hhu/0x%x ", a, b, c, d, - key->field_value[SRC_FIELD_IPV4].mask_range.u32); - - uint32_t_to_char(key->field_value[DST_FIELD_IPV4].value.u32, - &a, &b, &c, &d); - printf("%hhu.%hhu.%hhu.%hhu/0x%x ", a, b, c, d, - key->field_value[DST_FIELD_IPV4].mask_range.u32); - - printf("%hu : 0x%x %hu : 0x%x\n", - key->field_value[SRCP_FIELD_IPV4].value.u16, - key->field_value[SRCP_FIELD_IPV4].mask_range.u16, - key->field_value[DSTP_FIELD_IPV4].value.u16, - key->field_value[DSTP_FIELD_IPV4].mask_range.u16); -} - -static int -rte_flow_classifier_check_params(struct rte_flow_classifier_params *params) -{ - if (params == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: Incorrect value for parameter params\n", __func__); - return -EINVAL; - } - - /* name */ - if (params->name == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: Incorrect value for parameter name\n", __func__); - return -EINVAL; - } - - /* socket */ - if (params->socket_id < 0) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: Incorrect value for parameter socket_id\n", - __func__); - return -EINVAL; - } - - return 0; -} - -struct rte_flow_classifier * -rte_flow_classifier_create(struct rte_flow_classifier_params *params) -{ - struct rte_flow_classifier *cls; - int ret; - - RTE_FLOW_CLASSIFY_LOG(WARNING, - "WARNING: flow_classify is deprecated and will be removed in DPDK 23.11\n"); - - /* Check input parameters */ - ret = rte_flow_classifier_check_params(params); - if (ret != 0) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: flow classifier params check failed (%d)\n", - __func__, ret); - return NULL; - } - - /* Allocate memory for the flow classifier */ - cls = rte_zmalloc_socket("FLOW_CLASSIFIER", - sizeof(struct rte_flow_classifier), - RTE_CACHE_LINE_SIZE, params->socket_id); - - if (cls == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: flow classifier memory allocation failed\n", - __func__); - return NULL; - } - - /* Save input parameters */ - strlcpy(cls->name, params->name, RTE_FLOW_CLASSIFIER_MAX_NAME_SZ); - - cls->socket_id = params->socket_id; - - return cls; -} - -static void -rte_flow_classify_table_free(struct rte_cls_table *table) -{ - if (table->ops.f_free != NULL) - table->ops.f_free(table->h_table); -} - -int -rte_flow_classifier_free(struct rte_flow_classifier *cls) -{ - uint32_t i; - - /* Check input parameters */ - if (cls == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: rte_flow_classifier parameter is NULL\n", - __func__); - return -EINVAL; - } - - /* Free tables */ - for (i = 0; i < cls->num_tables; i++) { - struct rte_cls_table *table = &cls->tables[i]; - - rte_flow_classify_table_free(table); - } - - /* Free flow classifier memory */ - rte_free(cls); - - return 0; -} - -static int -rte_table_check_params(struct rte_flow_classifier *cls, - struct rte_flow_classify_table_params *params) -{ - if (cls == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: flow classifier parameter is NULL\n", - __func__); - return -EINVAL; - } - if (params == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, "%s: params parameter is NULL\n", - __func__); - return -EINVAL; - } - - /* ops */ - if (params->ops == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, "%s: params->ops is NULL\n", - __func__); - return -EINVAL; - } - - if (params->ops->f_create == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: f_create function pointer is NULL\n", __func__); - return -EINVAL; - } - - if (params->ops->f_lookup == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: f_lookup function pointer is NULL\n", __func__); - return -EINVAL; - } - - /* De we have room for one more table? */ - if (cls->num_tables == RTE_FLOW_CLASSIFY_TABLE_MAX) { - RTE_FLOW_CLASSIFY_LOG(ERR, - "%s: Incorrect value for num_tables parameter\n", - __func__); - return -EINVAL; - } - - return 0; -} - -int -rte_flow_classify_table_create(struct rte_flow_classifier *cls, - struct rte_flow_classify_table_params *params) -{ - struct rte_cls_table *table; - void *h_table; - uint32_t entry_size; - int ret; - - /* Check input arguments */ - ret = rte_table_check_params(cls, params); - if (ret != 0) - return ret; - - /* calculate table entry size */ - entry_size = sizeof(struct rte_flow_classify_table_entry); - - /* Create the table */ - h_table = params->ops->f_create(params->arg_create, cls->socket_id, - entry_size); - if (h_table == NULL) { - RTE_FLOW_CLASSIFY_LOG(ERR, "%s: Table creation failed\n", - __func__); - return -EINVAL; - } - - /* Commit current table to the classifier */ - table = &cls->tables[cls->num_tables]; - table->type = params->type; - cls->num_tables++; - - /* Save input parameters */ - memcpy(&table->ops, params->ops, sizeof(struct rte_table_ops)); - - /* Initialize table internal data structure */ - table->entry_size = entry_size; - table->h_table = h_table; - - return 0; -} - -static struct rte_flow_classify_rule * -allocate_acl_ipv4_5tuple_rule(struct rte_flow_classifier *cls) -{ - struct rte_flow_classify_rule *rule; - - rule = malloc(sizeof(struct rte_flow_classify_rule)); - if (!rule) - return rule; - - memset(rule, 0, sizeof(struct rte_flow_classify_rule)); - rule->id = unique_id++; - rule->rules.type = RTE_FLOW_CLASSIFY_RULE_TYPE_IPV4_5TUPLE; - - /* key add values */ - rule->u.key.key_add.priority = cls->ntuple_filter.priority; - rule->u.key.key_add.field_value[PROTO_FIELD_IPV4].mask_range.u8 = - cls->ntuple_filter.proto_mask; - rule->u.key.key_add.field_value[PROTO_FIELD_IPV4].value.u8 = - cls->ntuple_filter.proto; - rule->rules.u.ipv4_5tuple.proto = cls->ntuple_filter.proto; - rule->rules.u.ipv4_5tuple.proto_mask = cls->ntuple_filter.proto_mask; - - rule->u.key.key_add.field_value[SRC_FIELD_IPV4].mask_range.u32 = - cls->ntuple_filter.src_ip_mask; - rule->u.key.key_add.field_value[SRC_FIELD_IPV4].value.u32 = - cls->ntuple_filter.src_ip; - rule->rules.u.ipv4_5tuple.src_ip_mask = cls->ntuple_filter.src_ip_mask; - rule->rules.u.ipv4_5tuple.src_ip = cls->ntuple_filter.src_ip; - - rule->u.key.key_add.field_value[DST_FIELD_IPV4].mask_range.u32 = - cls->ntuple_filter.dst_ip_mask; - rule->u.key.key_add.field_value[DST_FIELD_IPV4].value.u32 = - cls->ntuple_filter.dst_ip; - rule->rules.u.ipv4_5tuple.dst_ip_mask = cls->ntuple_filter.dst_ip_mask; - rule->rules.u.ipv4_5tuple.dst_ip = cls->ntuple_filter.dst_ip; - - rule->u.key.key_add.field_value[SRCP_FIELD_IPV4].mask_range.u16 = - cls->ntuple_filter.src_port_mask; - rule->u.key.key_add.field_value[SRCP_FIELD_IPV4].value.u16 = - cls->ntuple_filter.src_port; - rule->rules.u.ipv4_5tuple.src_port_mask = - cls->ntuple_filter.src_port_mask; - rule->rules.u.ipv4_5tuple.src_port = cls->ntuple_filter.src_port; - - rule->u.key.key_add.field_value[DSTP_FIELD_IPV4].mask_range.u16 = - cls->ntuple_filter.dst_port_mask; - rule->u.key.key_add.field_value[DSTP_FIELD_IPV4].value.u16 = - cls->ntuple_filter.dst_port; - rule->rules.u.ipv4_5tuple.dst_port_mask = - cls->ntuple_filter.dst_port_mask; - rule->rules.u.ipv4_5tuple.dst_port = cls->ntuple_filter.dst_port; - - if (rte_log_can_log(librte_flow_classify_logtype, RTE_LOG_DEBUG)) - print_acl_ipv4_key_add(&rule->u.key.key_add); - - /* key delete values */ - memcpy(&rule->u.key.key_del.field_value[PROTO_FIELD_IPV4], - &rule->u.key.key_add.field_value[PROTO_FIELD_IPV4], - NUM_FIELDS_IPV4 * sizeof(struct rte_acl_field)); - - if (rte_log_can_log(librte_flow_classify_logtype, RTE_LOG_DEBUG)) - print_acl_ipv4_key_delete(&rule->u.key.key_del); - - return rule; -} - -struct rte_flow_classify_rule * -rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - int *key_found, - struct rte_flow_error *error) -{ - struct rte_flow_classify_rule *rule; - struct rte_flow_classify_table_entry *table_entry; - struct classify_action *action; - uint32_t i; - int ret; - - if (!error) - return NULL; - - if (key_found == NULL) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "NULL key_found."); - return NULL; - } - - /* parse attr, pattern and actions */ - ret = rte_flow_classify_validate(cls, attr, pattern, actions, error); - if (ret < 0) - return NULL; - - switch (table_type) { - case RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE: - rule = allocate_acl_ipv4_5tuple_rule(cls); - if (!rule) - return NULL; - rule->tbl_type = table_type; - cls->table_mask |= table_type; - break; - default: - return NULL; - } - - action = classify_get_flow_action(); - table_entry = &rule->entry; - table_entry->rule_id = rule->id; - table_entry->action.action_mask = action->action_mask; - - /* Copy actions */ - if (action->action_mask & (1LLU << RTE_FLOW_ACTION_TYPE_COUNT)) { - memcpy(&table_entry->action.act.counter, &action->act.counter, - sizeof(table_entry->action.act.counter)); - } - if (action->action_mask & (1LLU << RTE_FLOW_ACTION_TYPE_MARK)) { - memcpy(&table_entry->action.act.mark, &action->act.mark, - sizeof(table_entry->action.act.mark)); - } - - for (i = 0; i < cls->num_tables; i++) { - struct rte_cls_table *table = &cls->tables[i]; - - if (table->type == table_type) { - if (table->ops.f_add != NULL) { - ret = table->ops.f_add( - table->h_table, - &rule->u.key.key_add, - &rule->entry, - &rule->key_found, - &rule->entry_ptr); - if (ret) { - free(rule); - return NULL; - } - - *key_found = rule->key_found; - } - - return rule; - } - } - free(rule); - return NULL; -} - -int -rte_flow_classify_table_entry_delete(struct rte_flow_classifier *cls, - struct rte_flow_classify_rule *rule) -{ - uint32_t i; - int ret = -EINVAL; - - if (!cls || !rule) - return ret; - enum rte_flow_classify_table_type tbl_type = rule->tbl_type; - - for (i = 0; i < cls->num_tables; i++) { - struct rte_cls_table *table = &cls->tables[i]; - - if (table->type == tbl_type) { - if (table->ops.f_delete != NULL) { - ret = table->ops.f_delete(table->h_table, - &rule->u.key.key_del, - &rule->key_found, - &rule->entry); - if (ret == 0) - free(rule); - return ret; - } - } - } - return ret; -} - -static int -flow_classifier_lookup(struct rte_flow_classifier *cls, - struct rte_cls_table *table, - struct rte_mbuf **pkts, - const uint16_t nb_pkts) -{ - int ret = -EINVAL; - uint64_t pkts_mask; - uint64_t lookup_hit_mask; - - pkts_mask = RTE_LEN2MASK(nb_pkts, uint64_t); - ret = table->ops.f_lookup(table->h_table, - pkts, pkts_mask, &lookup_hit_mask, - (void **)cls->entries); - - if (!ret && lookup_hit_mask) - cls->nb_pkts = nb_pkts; - else - cls->nb_pkts = 0; - - return ret; -} - -static int -action_apply(struct rte_flow_classifier *cls, - struct rte_flow_classify_rule *rule, - struct rte_flow_classify_stats *stats) -{ - struct rte_flow_classify_ipv4_5tuple_stats *ntuple_stats; - struct rte_flow_classify_table_entry *entry = &rule->entry; - uint64_t count = 0; - uint32_t action_mask = entry->action.action_mask; - int i, ret = -EINVAL; - - if (action_mask & (1LLU << RTE_FLOW_ACTION_TYPE_COUNT)) { - for (i = 0; i < cls->nb_pkts; i++) { - if (rule->id == cls->entries[i]->rule_id) - count++; - } - if (count) { - ret = 0; - ntuple_stats = stats->stats; - ntuple_stats->counter1 = count; - ntuple_stats->ipv4_5tuple = rule->rules.u.ipv4_5tuple; - } - } - return ret; -} - -int -rte_flow_classifier_query(struct rte_flow_classifier *cls, - struct rte_mbuf **pkts, - const uint16_t nb_pkts, - struct rte_flow_classify_rule *rule, - struct rte_flow_classify_stats *stats) -{ - enum rte_flow_classify_table_type tbl_type; - uint32_t i; - int ret = -EINVAL; - - if (!cls || !rule || !stats || !pkts || nb_pkts == 0) - return ret; - - tbl_type = rule->tbl_type; - for (i = 0; i < cls->num_tables; i++) { - struct rte_cls_table *table = &cls->tables[i]; - - if (table->type == tbl_type) { - ret = flow_classifier_lookup(cls, table, - pkts, nb_pkts); - if (!ret) { - ret = action_apply(cls, rule, stats); - return ret; - } - } - } - return ret; -} - -RTE_LOG_REGISTER_DEFAULT(librte_flow_classify_logtype, INFO); diff --git a/dpdk/lib/flow_classify/rte_flow_classify.h b/dpdk/lib/flow_classify/rte_flow_classify.h deleted file mode 100644 index 39512b620..000000000 --- a/dpdk/lib/flow_classify/rte_flow_classify.h +++ /dev/null @@ -1,284 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#ifndef _RTE_FLOW_CLASSIFY_H_ -#define _RTE_FLOW_CLASSIFY_H_ - -/** - * @file - * - * RTE Flow Classify Library. - * - * @warning - * @b EXPERIMENTAL: - * All functions in this file may be changed or removed without prior notice. - * - * This library provides flow record information with some measured properties. - * - * Application should define the flow and measurement criteria (action) for it. - * - * The Library doesn't maintain any flow records itself, instead flow - * information is returned to upper layer only for given packets. - * - * It is application's responsibility to call rte_flow_classifier_query() - * for a burst of packets, just after receiving them or before transmitting - * them. - * Application should provide the flow type interested in, measurement to apply - * to that flow in rte_flow_classify_table_entry_add() API, and should provide - * the rte_flow_classifier object and storage to put results in for the - * rte_flow_classifier_query() API. - * - * Usage: - * - application calls rte_flow_classifier_create() to create an - * rte_flow_classifier object. - * - application calls rte_flow_classify_table_create() to create a table - * in the rte_flow_classifier object. - * - application calls rte_flow_classify_table_entry_add() to add a rule to - * the table in the rte_flow_classifier object. - * - application calls rte_flow_classifier_query() in a polling manner, - * preferably after rte_eth_rx_burst(). This will cause the library to - * match packet information to flow information with some measurements. - * - rte_flow_classifier object can be destroyed when it is no longer needed - * with rte_flow_classifier_free() - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern int librte_flow_classify_logtype; - -#define RTE_FLOW_CLASSIFY_LOG(level, ...) \ - rte_log(RTE_LOG_ ## level, \ - librte_flow_classify_logtype, \ - RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__,), \ - __func__, \ - RTE_FMT_TAIL(__VA_ARGS__,))) - -#ifndef RTE_FLOW_CLASSIFY_TABLE_MAX -#define RTE_FLOW_CLASSIFY_TABLE_MAX 32 -#endif - -/** Opaque data type for flow classifier */ -struct rte_flow_classifier; - -/** Opaque data type for flow classify rule */ -struct rte_flow_classify_rule; - -/** Flow classify rule type */ -enum rte_flow_classify_rule_type { - /** no type */ - RTE_FLOW_CLASSIFY_RULE_TYPE_NONE, - /** IPv4 5tuple type */ - RTE_FLOW_CLASSIFY_RULE_TYPE_IPV4_5TUPLE, -}; - -/** Flow classify table type */ -enum rte_flow_classify_table_type { - /** No type */ - RTE_FLOW_CLASSIFY_TABLE_TYPE_NONE = 1 << 0, - /** ACL IP4 5TUPLE */ - RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE = 1 << 1, - /** ACL VLAN IP4 5TUPLE */ - RTE_FLOW_CLASSIFY_TABLE_ACL_VLAN_IP4_5TUPLE = 1 << 2, - /** ACL QinQ IP4 5TUPLE */ - RTE_FLOW_CLASSIFY_TABLE_ACL_QINQ_IP4_5TUPLE = 1 << 3, - -}; - -/** Parameters for flow classifier creation */ -struct rte_flow_classifier_params { - /** flow classifier name */ - const char *name; - - /** CPU socket ID where memory for the flow classifier and its */ - /** elements (tables) should be allocated */ - int socket_id; -}; - -/** Parameters for table creation */ -struct rte_flow_classify_table_params { - /** Table operations (specific to each table type) */ - struct rte_table_ops *ops; - - /** Opaque param to be passed to the table create operation */ - void *arg_create; - - /** Classifier table type */ - enum rte_flow_classify_table_type type; -}; - -/** IPv4 5-tuple data */ -struct rte_flow_classify_ipv4_5tuple { - uint32_t dst_ip; /**< Destination IP address in big endian. */ - uint32_t dst_ip_mask; /**< Mask of destination IP address. */ - uint32_t src_ip; /**< Source IP address in big endian. */ - uint32_t src_ip_mask; /**< Mask of destination IP address. */ - uint16_t dst_port; /**< Destination port in big endian. */ - uint16_t dst_port_mask; /**< Mask of destination port. */ - uint16_t src_port; /**< Source Port in big endian. */ - uint16_t src_port_mask; /**< Mask of source port. */ - uint8_t proto; /**< L4 protocol. */ - uint8_t proto_mask; /**< Mask of L4 protocol. */ -}; - -/** - * Flow stats - * - * For the count action, stats can be returned by the query API. - * - * Storage for stats is provided by application. - */ -struct rte_flow_classify_stats { - void *stats; -}; - -struct rte_flow_classify_ipv4_5tuple_stats { - /** count of packets that match IPv4 5tuple pattern */ - uint64_t counter1; - /** IPv4 5tuple data */ - struct rte_flow_classify_ipv4_5tuple ipv4_5tuple; -}; - -/** - * Flow classifier create - * - * @param params - * Parameters for flow classifier creation - * @return - * Handle to flow classifier instance on success or NULL otherwise - */ -__rte_experimental -struct rte_flow_classifier * -rte_flow_classifier_create(struct rte_flow_classifier_params *params); - -/** - * Flow classifier free - * - * @param cls - * Handle to flow classifier instance - * @return - * 0 on success, error code otherwise - */ -__rte_experimental -int -rte_flow_classifier_free(struct rte_flow_classifier *cls); - -/** - * Flow classify table create - * - * @param cls - * Handle to flow classifier instance - * @param params - * Parameters for flow_classify table creation - * @return - * 0 on success, error code otherwise - */ -__rte_experimental -int -rte_flow_classify_table_create(struct rte_flow_classifier *cls, - struct rte_flow_classify_table_params *params); - -/** - * Flow classify validate - * - * @param cls - * Handle to flow classifier instance - * @param[in] attr - * Flow rule attributes - * @param[in] pattern - * Pattern specification (list terminated by the END pattern item). - * @param[in] actions - * Associated actions (list terminated by the END pattern item). - * @param[out] error - * Perform verbose error reporting if not NULL. Structure - * initialised in case of error only. - * @return - * 0 on success, error code otherwise - */ -__rte_experimental -int -rte_flow_classify_validate(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_flow_error *error); - -/** - * Add a flow classify rule to the flow_classifier table. - * - * @param[in] cls - * Flow classifier handle - * @param[in] attr - * Flow rule attributes - * @param[in] pattern - * Pattern specification (list terminated by the END pattern item). - * @param[in] actions - * Associated actions (list terminated by the END pattern item). - * @param[out] key_found - * returns 1 if rule present already, 0 otherwise. - * @param[out] error - * Perform verbose error reporting if not NULL. Structure - * initialised in case of error only. - * @return - * A valid handle in case of success, NULL otherwise. - */ -__rte_experimental -struct rte_flow_classify_rule * -rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls, - const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - int *key_found, - struct rte_flow_error *error); - -/** - * Delete a flow classify rule from the flow_classifier table. - * - * @param[in] cls - * Flow classifier handle - * @param[in] rule - * Flow classify rule - * @return - * 0 on success, error code otherwise. - */ -__rte_experimental -int -rte_flow_classify_table_entry_delete(struct rte_flow_classifier *cls, - struct rte_flow_classify_rule *rule); - -/** - * Query flow classifier for given rule. - * - * @param[in] cls - * Flow classifier handle - * @param[in] pkts - * Pointer to packets to process - * @param[in] nb_pkts - * Number of packets to process - * @param[in] rule - * Flow classify rule - * @param[in] stats - * Flow classify stats - * - * @return - * 0 on success, error code otherwise. - */ -__rte_experimental -int -rte_flow_classifier_query(struct rte_flow_classifier *cls, - struct rte_mbuf **pkts, - const uint16_t nb_pkts, - struct rte_flow_classify_rule *rule, - struct rte_flow_classify_stats *stats); - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_FLOW_CLASSIFY_H_ */ diff --git a/dpdk/lib/flow_classify/rte_flow_classify_parse.c b/dpdk/lib/flow_classify/rte_flow_classify_parse.c deleted file mode 100644 index 345d129d3..000000000 --- a/dpdk/lib/flow_classify/rte_flow_classify_parse.c +++ /dev/null @@ -1,532 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#include -#include "rte_flow_classify_parse.h" - -struct classify_valid_pattern { - enum rte_flow_item_type *items; - parse_filter_t parse_filter; -}; - -static struct classify_action action; - -/* Pattern for IPv4 5-tuple UDP filter */ -static enum rte_flow_item_type pattern_ntuple_1[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_UDP, - RTE_FLOW_ITEM_TYPE_END, -}; - -/* Pattern for IPv4 5-tuple TCP filter */ -static enum rte_flow_item_type pattern_ntuple_2[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_TCP, - RTE_FLOW_ITEM_TYPE_END, -}; - -/* Pattern for IPv4 5-tuple SCTP filter */ -static enum rte_flow_item_type pattern_ntuple_3[] = { - RTE_FLOW_ITEM_TYPE_ETH, - RTE_FLOW_ITEM_TYPE_IPV4, - RTE_FLOW_ITEM_TYPE_SCTP, - RTE_FLOW_ITEM_TYPE_END, -}; - -static int -classify_parse_ntuple_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_ntuple_filter *filter, - struct rte_flow_error *error); - -static struct classify_valid_pattern classify_supported_patterns[] = { - /* ntuple */ - { pattern_ntuple_1, classify_parse_ntuple_filter }, - { pattern_ntuple_2, classify_parse_ntuple_filter }, - { pattern_ntuple_3, classify_parse_ntuple_filter }, -}; - -struct classify_action * -classify_get_flow_action(void) -{ - return &action; -} - -/* Find the first VOID or non-VOID item pointer */ -const struct rte_flow_item * -classify_find_first_item(const struct rte_flow_item *item, bool is_void) -{ - bool is_find; - - while (item->type != RTE_FLOW_ITEM_TYPE_END) { - if (is_void) - is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID; - else - is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID; - if (is_find) - break; - item++; - } - return item; -} - -/* Skip all VOID items of the pattern */ -void -classify_pattern_skip_void_item(struct rte_flow_item *items, - const struct rte_flow_item *pattern) -{ - uint32_t cpy_count = 0; - const struct rte_flow_item *pb = pattern, *pe = pattern; - - for (;;) { - /* Find a non-void item first */ - pb = classify_find_first_item(pb, false); - if (pb->type == RTE_FLOW_ITEM_TYPE_END) { - pe = pb; - break; - } - - /* Find a void item */ - pe = classify_find_first_item(pb + 1, true); - - cpy_count = pe - pb; - rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count); - - items += cpy_count; - - if (pe->type == RTE_FLOW_ITEM_TYPE_END) { - pb = pe; - break; - } - } - /* Copy the END item. */ - rte_memcpy(items, pe, sizeof(struct rte_flow_item)); -} - -/* Check if the pattern matches a supported item type array */ -static bool -classify_match_pattern(enum rte_flow_item_type *item_array, - struct rte_flow_item *pattern) -{ - struct rte_flow_item *item = pattern; - - while ((*item_array == item->type) && - (*item_array != RTE_FLOW_ITEM_TYPE_END)) { - item_array++; - item++; - } - - return (*item_array == RTE_FLOW_ITEM_TYPE_END && - item->type == RTE_FLOW_ITEM_TYPE_END); -} - -/* Find if there's parse filter function matched */ -parse_filter_t -classify_find_parse_filter_func(struct rte_flow_item *pattern) -{ - parse_filter_t parse_filter = NULL; - uint8_t i = 0; - - for (; i < RTE_DIM(classify_supported_patterns); i++) { - if (classify_match_pattern(classify_supported_patterns[i].items, - pattern)) { - parse_filter = - classify_supported_patterns[i].parse_filter; - break; - } - } - - return parse_filter; -} - -#define FLOW_RULE_MIN_PRIORITY 8 -#define FLOW_RULE_MAX_PRIORITY 0 - -#define NEXT_ITEM_OF_PATTERN(item, pattern, index)\ - do {\ - item = pattern + index;\ - while (item->type == RTE_FLOW_ITEM_TYPE_VOID) {\ - index++;\ - item = pattern + index;\ - } \ - } while (0) - -#define NEXT_ITEM_OF_ACTION(act, actions, index)\ - do {\ - act = actions + index;\ - while (act->type == RTE_FLOW_ACTION_TYPE_VOID) {\ - index++;\ - act = actions + index;\ - } \ - } while (0) - -/** - * Please aware there's an assumption for all the parsers. - * rte_flow_item is using big endian, rte_flow_attr and - * rte_flow_action are using CPU order. - * Because the pattern is used to describe the packets, - * normally the packets should use network order. - */ - -/** - * Parse the rule to see if it is a n-tuple rule. - * And get the n-tuple filter info BTW. - * pattern: - * The first not void item can be ETH or IPV4. - * The second not void item must be IPV4 if the first one is ETH. - * The third not void item must be UDP or TCP. - * The next not void item must be END. - * action: - * The first not void action should be QUEUE. - * The next not void action should be END. - * pattern example: - * ITEM Spec Mask - * ETH NULL NULL - * IPV4 src_addr 192.168.1.20 0xFFFFFFFF - * dst_addr 192.167.3.50 0xFFFFFFFF - * next_proto_id 17 0xFF - * UDP/TCP/ src_port 80 0xFFFF - * SCTP dst_port 80 0xFFFF - * END - * other members in mask and spec should set to 0x00. - * item->last should be NULL. - */ -static int -classify_parse_ntuple_filter(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_ntuple_filter *filter, - struct rte_flow_error *error) -{ - const struct rte_flow_item *item; - const struct rte_flow_action *act; - const struct rte_flow_item_ipv4 *ipv4_spec; - const struct rte_flow_item_ipv4 *ipv4_mask; - const struct rte_flow_item_tcp *tcp_spec; - const struct rte_flow_item_tcp *tcp_mask; - const struct rte_flow_item_udp *udp_spec; - const struct rte_flow_item_udp *udp_mask; - const struct rte_flow_item_sctp *sctp_spec; - const struct rte_flow_item_sctp *sctp_mask; - const struct rte_flow_action_count *count; - const struct rte_flow_action_mark *mark_spec; - uint32_t index; - - /* parse pattern */ - index = 0; - - /* the first not void item can be MAC or IPv4 */ - NEXT_ITEM_OF_PATTERN(item, pattern, index); - - if (item->type != RTE_FLOW_ITEM_TYPE_ETH && - item->type != RTE_FLOW_ITEM_TYPE_IPV4) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - /* Skip Ethernet */ - if (item->type == RTE_FLOW_ITEM_TYPE_ETH) { - /*Not supported last point for range*/ - if (item->last) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - item, - "Not supported last point for range"); - return -EINVAL; - - } - /* if the first item is MAC, the content should be NULL */ - if (item->spec || item->mask) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "Not supported by ntuple filter"); - return -EINVAL; - } - /* check if the next not void item is IPv4 */ - index++; - NEXT_ITEM_OF_PATTERN(item, pattern, index); - if (item->type != RTE_FLOW_ITEM_TYPE_IPV4) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "Not supported by ntuple filter"); - return -EINVAL; - } - } - - /* get the IPv4 info */ - if (!item->spec || !item->mask) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Invalid ntuple mask"); - return -EINVAL; - } - /*Not supported last point for range*/ - if (item->last) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - item, "Not supported last point for range"); - return -EINVAL; - - } - - ipv4_mask = item->mask; - /** - * Only support src & dst addresses, protocol, - * others should be masked. - */ - if (ipv4_mask->hdr.version_ihl || - ipv4_mask->hdr.type_of_service || - ipv4_mask->hdr.total_length || - ipv4_mask->hdr.packet_id || - ipv4_mask->hdr.fragment_offset || - ipv4_mask->hdr.time_to_live || - ipv4_mask->hdr.hdr_checksum) { - rte_flow_error_set(error, - EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - filter->dst_ip_mask = ipv4_mask->hdr.dst_addr; - filter->src_ip_mask = ipv4_mask->hdr.src_addr; - filter->proto_mask = ipv4_mask->hdr.next_proto_id; - - ipv4_spec = item->spec; - filter->dst_ip = ipv4_spec->hdr.dst_addr; - filter->src_ip = ipv4_spec->hdr.src_addr; - filter->proto = ipv4_spec->hdr.next_proto_id; - - /* check if the next not void item is TCP or UDP or SCTP */ - index++; - NEXT_ITEM_OF_PATTERN(item, pattern, index); - if (item->type != RTE_FLOW_ITEM_TYPE_TCP && - item->type != RTE_FLOW_ITEM_TYPE_UDP && - item->type != RTE_FLOW_ITEM_TYPE_SCTP) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - /* get the TCP/UDP info */ - if (!item->spec || !item->mask) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Invalid ntuple mask"); - return -EINVAL; - } - - /*Not supported last point for range*/ - if (item->last) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - item, "Not supported last point for range"); - return -EINVAL; - - } - - if (item->type == RTE_FLOW_ITEM_TYPE_TCP) { - tcp_mask = item->mask; - - /** - * Only support src & dst ports, tcp flags, - * others should be masked. - */ - if (tcp_mask->hdr.sent_seq || - tcp_mask->hdr.recv_ack || - tcp_mask->hdr.data_off || - tcp_mask->hdr.rx_win || - tcp_mask->hdr.cksum || - tcp_mask->hdr.tcp_urp) { - memset(filter, 0, - sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - filter->dst_port_mask = tcp_mask->hdr.dst_port; - filter->src_port_mask = tcp_mask->hdr.src_port; - if (tcp_mask->hdr.tcp_flags == 0xFF) { - filter->flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; - } else if (!tcp_mask->hdr.tcp_flags) { - filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG; - } else { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - tcp_spec = item->spec; - filter->dst_port = tcp_spec->hdr.dst_port; - filter->src_port = tcp_spec->hdr.src_port; - filter->tcp_flags = tcp_spec->hdr.tcp_flags; - } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { - udp_mask = item->mask; - - /** - * Only support src & dst ports, - * others should be masked. - */ - if (udp_mask->hdr.dgram_len || - udp_mask->hdr.dgram_cksum) { - memset(filter, 0, - sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - filter->dst_port_mask = udp_mask->hdr.dst_port; - filter->src_port_mask = udp_mask->hdr.src_port; - - udp_spec = item->spec; - filter->dst_port = udp_spec->hdr.dst_port; - filter->src_port = udp_spec->hdr.src_port; - } else { - sctp_mask = item->mask; - - /** - * Only support src & dst ports, - * others should be masked. - */ - if (sctp_mask->hdr.tag || - sctp_mask->hdr.cksum) { - memset(filter, 0, - sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - filter->dst_port_mask = sctp_mask->hdr.dst_port; - filter->src_port_mask = sctp_mask->hdr.src_port; - - sctp_spec = item->spec; - filter->dst_port = sctp_spec->hdr.dst_port; - filter->src_port = sctp_spec->hdr.src_port; - } - - /* check if the next not void item is END */ - index++; - NEXT_ITEM_OF_PATTERN(item, pattern, index); - if (item->type != RTE_FLOW_ITEM_TYPE_END) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "Not supported by ntuple filter"); - return -EINVAL; - } - - table_type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE; - - /* parse attr */ - /* must be input direction */ - if (!attr->ingress) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, - attr, "Only support ingress."); - return -EINVAL; - } - - /* not supported */ - if (attr->egress) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, - attr, "Not support egress."); - return -EINVAL; - } - - if (attr->priority > 0xFFFF) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, - attr, "Error priority."); - return -EINVAL; - } - filter->priority = (uint16_t)attr->priority; - if (attr->priority > FLOW_RULE_MIN_PRIORITY) - filter->priority = FLOW_RULE_MAX_PRIORITY; - - /* parse action */ - index = 0; - - /** - * n-tuple only supports count and Mark, - * check if the first not void action is COUNT or MARK. - */ - memset(&action, 0, sizeof(action)); - NEXT_ITEM_OF_ACTION(act, actions, index); - switch (act->type) { - case RTE_FLOW_ACTION_TYPE_COUNT: - action.action_mask |= 1LLU << RTE_FLOW_ACTION_TYPE_COUNT; - count = act->conf; - memcpy(&action.act.counter, count, sizeof(action.act.counter)); - break; - case RTE_FLOW_ACTION_TYPE_MARK: - action.action_mask |= 1LLU << RTE_FLOW_ACTION_TYPE_MARK; - mark_spec = act->conf; - memcpy(&action.act.mark, mark_spec, sizeof(action.act.mark)); - break; - default: - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, act, - "Invalid action."); - return -EINVAL; - } - - /* check if the next not void item is MARK or COUNT or END */ - index++; - NEXT_ITEM_OF_ACTION(act, actions, index); - switch (act->type) { - case RTE_FLOW_ACTION_TYPE_COUNT: - action.action_mask |= 1LLU << RTE_FLOW_ACTION_TYPE_COUNT; - count = act->conf; - memcpy(&action.act.counter, count, sizeof(action.act.counter)); - break; - case RTE_FLOW_ACTION_TYPE_MARK: - action.action_mask |= 1LLU << RTE_FLOW_ACTION_TYPE_MARK; - mark_spec = act->conf; - memcpy(&action.act.mark, mark_spec, sizeof(action.act.mark)); - break; - case RTE_FLOW_ACTION_TYPE_END: - return 0; - default: - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, act, - "Invalid action."); - return -EINVAL; - } - - /* check if the next not void item is END */ - index++; - NEXT_ITEM_OF_ACTION(act, actions, index); - if (act->type != RTE_FLOW_ACTION_TYPE_END) { - memset(filter, 0, sizeof(struct rte_eth_ntuple_filter)); - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, act, - "Invalid action."); - return -EINVAL; - } - - return 0; -} diff --git a/dpdk/lib/flow_classify/rte_flow_classify_parse.h b/dpdk/lib/flow_classify/rte_flow_classify_parse.h deleted file mode 100644 index 7943efc0d..000000000 --- a/dpdk/lib/flow_classify/rte_flow_classify_parse.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation - */ - -#ifndef _RTE_FLOW_CLASSIFY_PARSE_H_ -#define _RTE_FLOW_CLASSIFY_PARSE_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern enum rte_flow_classify_table_type table_type; - -struct classify_action { - /* Flow action mask */ - uint64_t action_mask; - - struct action { - /** Integer value to return with packets */ - struct rte_flow_action_mark mark; - /** Flow rule counter */ - struct rte_flow_query_count counter; - } act; -}; - -typedef int (*parse_filter_t)(const struct rte_flow_attr *attr, - const struct rte_flow_item pattern[], - const struct rte_flow_action actions[], - struct rte_eth_ntuple_filter *filter, - struct rte_flow_error *error); - -/* Skip all VOID items of the pattern */ -void -classify_pattern_skip_void_item(struct rte_flow_item *items, - const struct rte_flow_item *pattern); - -/* Find the first VOID or non-VOID item pointer */ -const struct rte_flow_item * -classify_find_first_item(const struct rte_flow_item *item, bool is_void); - - -/* Find if there's parse filter function matched */ -parse_filter_t -classify_find_parse_filter_func(struct rte_flow_item *pattern); - -/* get action data */ -struct classify_action * -classify_get_flow_action(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_FLOW_CLASSIFY_PARSE_H_ */ diff --git a/dpdk/lib/flow_classify/version.map b/dpdk/lib/flow_classify/version.map deleted file mode 100644 index 49bc25c6a..000000000 --- a/dpdk/lib/flow_classify/version.map +++ /dev/null @@ -1,13 +0,0 @@ -EXPERIMENTAL { - global: - - rte_flow_classifier_create; - rte_flow_classifier_free; - rte_flow_classifier_query; - rte_flow_classify_table_create; - rte_flow_classify_table_entry_add; - rte_flow_classify_table_entry_delete; - rte_flow_classify_validate; - - local: *; -}; diff --git a/dpdk/lib/kni/meson.build b/dpdk/lib/kni/meson.build deleted file mode 100644 index 8a71d8ba6..000000000 --- a/dpdk/lib/kni/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel Corporation - -if is_windows - build = false - reason = 'not supported on Windows' - subdir_done() -endif - -if not is_linux or not dpdk_conf.get('RTE_ARCH_64') - build = false - reason = 'only supported on 64-bit Linux' -endif -sources = files('rte_kni.c') -headers = files('rte_kni.h', 'rte_kni_common.h') -deps += ['ethdev', 'pci'] diff --git a/dpdk/lib/kni/rte_kni.c b/dpdk/lib/kni/rte_kni.c deleted file mode 100644 index bfa6a001f..000000000 --- a/dpdk/lib/kni/rte_kni.c +++ /dev/null @@ -1,843 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef RTE_EXEC_ENV_LINUX -#error "KNI is not supported" -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rte_kni_fifo.h" - -#define MAX_MBUF_BURST_NUM 32 - -/* Maximum number of ring entries */ -#define KNI_FIFO_COUNT_MAX 1024 -#define KNI_FIFO_SIZE (KNI_FIFO_COUNT_MAX * sizeof(void *) + \ - sizeof(struct rte_kni_fifo)) - -#define KNI_REQUEST_MBUF_NUM_MAX 32 - -#define KNI_MEM_CHECK(cond, fail) do { if (cond) goto fail; } while (0) - -#define KNI_MZ_NAME_FMT "kni_info_%s" -#define KNI_TX_Q_MZ_NAME_FMT "kni_tx_%s" -#define KNI_RX_Q_MZ_NAME_FMT "kni_rx_%s" -#define KNI_ALLOC_Q_MZ_NAME_FMT "kni_alloc_%s" -#define KNI_FREE_Q_MZ_NAME_FMT "kni_free_%s" -#define KNI_REQ_Q_MZ_NAME_FMT "kni_req_%s" -#define KNI_RESP_Q_MZ_NAME_FMT "kni_resp_%s" -#define KNI_SYNC_ADDR_MZ_NAME_FMT "kni_sync_%s" - -TAILQ_HEAD(rte_kni_list, rte_tailq_entry); - -static struct rte_tailq_elem rte_kni_tailq = { - .name = "RTE_KNI", -}; -EAL_REGISTER_TAILQ(rte_kni_tailq) - -/** - * KNI context - */ -struct rte_kni { - char name[RTE_KNI_NAMESIZE]; /**< KNI interface name */ - uint16_t group_id; /**< Group ID of KNI devices */ - uint32_t slot_id; /**< KNI pool slot ID */ - struct rte_mempool *pktmbuf_pool; /**< pkt mbuf mempool */ - unsigned int mbuf_size; /**< mbuf size */ - - const struct rte_memzone *m_tx_q; /**< TX queue memzone */ - const struct rte_memzone *m_rx_q; /**< RX queue memzone */ - const struct rte_memzone *m_alloc_q;/**< Alloc queue memzone */ - const struct rte_memzone *m_free_q; /**< Free queue memzone */ - - struct rte_kni_fifo *tx_q; /**< TX queue */ - struct rte_kni_fifo *rx_q; /**< RX queue */ - struct rte_kni_fifo *alloc_q; /**< Allocated mbufs queue */ - struct rte_kni_fifo *free_q; /**< To be freed mbufs queue */ - - const struct rte_memzone *m_req_q; /**< Request queue memzone */ - const struct rte_memzone *m_resp_q; /**< Response queue memzone */ - const struct rte_memzone *m_sync_addr;/**< Sync addr memzone */ - - /* For request & response */ - struct rte_kni_fifo *req_q; /**< Request queue */ - struct rte_kni_fifo *resp_q; /**< Response queue */ - void *sync_addr; /**< Req/Resp Mem address */ - - struct rte_kni_ops ops; /**< operations for request */ -}; - -enum kni_ops_status { - KNI_REQ_NO_REGISTER = 0, - KNI_REQ_REGISTERED, -}; - -static void kni_free_mbufs(struct rte_kni *kni); -static void kni_allocate_mbufs(struct rte_kni *kni); - -static volatile int kni_fd = -1; - -/* Shall be called before any allocation happens */ -int -rte_kni_init(unsigned int max_kni_ifaces __rte_unused) -{ - RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) - if (rte_eal_iova_mode() != RTE_IOVA_PA) { - RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n"); - return -1; - } -#endif - - /* Check FD and open */ - if (kni_fd < 0) { - kni_fd = open("/dev/" KNI_DEVICE, O_RDWR); - if (kni_fd < 0) { - RTE_LOG(ERR, KNI, - "Can not open /dev/%s\n", KNI_DEVICE); - return -1; - } - } - - return 0; -} - -static struct rte_kni * -__rte_kni_get(const char *name) -{ - struct rte_kni *kni; - struct rte_tailq_entry *te; - struct rte_kni_list *kni_list; - - kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list); - - TAILQ_FOREACH(te, kni_list, next) { - kni = te->data; - if (strncmp(name, kni->name, RTE_KNI_NAMESIZE) == 0) - break; - } - - if (te == NULL) - kni = NULL; - - return kni; -} - -static int -kni_reserve_mz(struct rte_kni *kni) -{ - char mz_name[RTE_MEMZONE_NAMESIZE]; - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_TX_Q_MZ_NAME_FMT, kni->name); - kni->m_tx_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_tx_q == NULL, tx_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_RX_Q_MZ_NAME_FMT, kni->name); - kni->m_rx_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_rx_q == NULL, rx_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_ALLOC_Q_MZ_NAME_FMT, kni->name); - kni->m_alloc_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_alloc_q == NULL, alloc_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_FREE_Q_MZ_NAME_FMT, kni->name); - kni->m_free_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_free_q == NULL, free_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_REQ_Q_MZ_NAME_FMT, kni->name); - kni->m_req_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_req_q == NULL, req_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_RESP_Q_MZ_NAME_FMT, kni->name); - kni->m_resp_q = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_resp_q == NULL, resp_q_fail); - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_SYNC_ADDR_MZ_NAME_FMT, kni->name); - kni->m_sync_addr = rte_memzone_reserve(mz_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, - RTE_MEMZONE_IOVA_CONTIG); - KNI_MEM_CHECK(kni->m_sync_addr == NULL, sync_addr_fail); - - return 0; - -sync_addr_fail: - rte_memzone_free(kni->m_resp_q); -resp_q_fail: - rte_memzone_free(kni->m_req_q); -req_q_fail: - rte_memzone_free(kni->m_free_q); -free_q_fail: - rte_memzone_free(kni->m_alloc_q); -alloc_q_fail: - rte_memzone_free(kni->m_rx_q); -rx_q_fail: - rte_memzone_free(kni->m_tx_q); -tx_q_fail: - return -1; -} - -static void -kni_release_mz(struct rte_kni *kni) -{ - rte_memzone_free(kni->m_tx_q); - rte_memzone_free(kni->m_rx_q); - rte_memzone_free(kni->m_alloc_q); - rte_memzone_free(kni->m_free_q); - rte_memzone_free(kni->m_req_q); - rte_memzone_free(kni->m_resp_q); - rte_memzone_free(kni->m_sync_addr); -} - -struct rte_kni * -rte_kni_alloc(struct rte_mempool *pktmbuf_pool, - const struct rte_kni_conf *conf, - struct rte_kni_ops *ops) -{ - int ret; - struct rte_kni_device_info dev_info; - struct rte_kni *kni; - struct rte_tailq_entry *te; - struct rte_kni_list *kni_list; - - if (!pktmbuf_pool || !conf || !conf->name[0]) - return NULL; - - /* Check if KNI subsystem has been initialized */ - if (kni_fd < 0) { - RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); - return NULL; - } - - rte_mcfg_tailq_write_lock(); - - kni = __rte_kni_get(conf->name); - if (kni != NULL) { - RTE_LOG(ERR, KNI, "KNI already exists\n"); - goto unlock; - } - - te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0); - if (te == NULL) { - RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n"); - goto unlock; - } - - kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE); - if (kni == NULL) { - RTE_LOG(ERR, KNI, "KNI memory allocation failed\n"); - goto kni_fail; - } - - strlcpy(kni->name, conf->name, RTE_KNI_NAMESIZE); - - if (ops) - memcpy(&kni->ops, ops, sizeof(struct rte_kni_ops)); - else - kni->ops.port_id = UINT16_MAX; - - memset(&dev_info, 0, sizeof(dev_info)); - dev_info.core_id = conf->core_id; - dev_info.force_bind = conf->force_bind; - dev_info.group_id = conf->group_id; - dev_info.mbuf_size = conf->mbuf_size; - dev_info.mtu = conf->mtu; - dev_info.min_mtu = conf->min_mtu; - dev_info.max_mtu = conf->max_mtu; - - memcpy(dev_info.mac_addr, conf->mac_addr, RTE_ETHER_ADDR_LEN); - - strlcpy(dev_info.name, conf->name, RTE_KNI_NAMESIZE); - - ret = kni_reserve_mz(kni); - if (ret < 0) - goto mz_fail; - - /* TX RING */ - kni->tx_q = kni->m_tx_q->addr; - kni_fifo_init(kni->tx_q, KNI_FIFO_COUNT_MAX); - dev_info.tx_phys = kni->m_tx_q->iova; - - /* RX RING */ - kni->rx_q = kni->m_rx_q->addr; - kni_fifo_init(kni->rx_q, KNI_FIFO_COUNT_MAX); - dev_info.rx_phys = kni->m_rx_q->iova; - - /* ALLOC RING */ - kni->alloc_q = kni->m_alloc_q->addr; - kni_fifo_init(kni->alloc_q, KNI_FIFO_COUNT_MAX); - dev_info.alloc_phys = kni->m_alloc_q->iova; - - /* FREE RING */ - kni->free_q = kni->m_free_q->addr; - kni_fifo_init(kni->free_q, KNI_FIFO_COUNT_MAX); - dev_info.free_phys = kni->m_free_q->iova; - - /* Request RING */ - kni->req_q = kni->m_req_q->addr; - kni_fifo_init(kni->req_q, KNI_FIFO_COUNT_MAX); - dev_info.req_phys = kni->m_req_q->iova; - - /* Response RING */ - kni->resp_q = kni->m_resp_q->addr; - kni_fifo_init(kni->resp_q, KNI_FIFO_COUNT_MAX); - dev_info.resp_phys = kni->m_resp_q->iova; - - /* Req/Resp sync mem area */ - kni->sync_addr = kni->m_sync_addr->addr; - dev_info.sync_va = kni->m_sync_addr->addr; - dev_info.sync_phys = kni->m_sync_addr->iova; - - kni->pktmbuf_pool = pktmbuf_pool; - kni->group_id = conf->group_id; - kni->mbuf_size = conf->mbuf_size; - - dev_info.iova_mode = (rte_eal_iova_mode() == RTE_IOVA_VA) ? 1 : 0; - - ret = ioctl(kni_fd, RTE_KNI_IOCTL_CREATE, &dev_info); - if (ret < 0) - goto ioctl_fail; - - te->data = kni; - - kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list); - TAILQ_INSERT_TAIL(kni_list, te, next); - - rte_mcfg_tailq_write_unlock(); - - /* Allocate mbufs and then put them into alloc_q */ - kni_allocate_mbufs(kni); - - return kni; - -ioctl_fail: - kni_release_mz(kni); -mz_fail: - rte_free(kni); -kni_fail: - rte_free(te); -unlock: - rte_mcfg_tailq_write_unlock(); - - return NULL; -} - -static void -kni_free_fifo(struct rte_kni_fifo *fifo) -{ - int ret; - struct rte_mbuf *pkt; - - do { - ret = kni_fifo_get(fifo, (void **)&pkt, 1); - if (ret) - rte_pktmbuf_free(pkt); - } while (ret); -} - -static void * -va2pa(struct rte_mbuf *m) -{ - return (void *)((unsigned long)m - - ((unsigned long)m->buf_addr - (unsigned long)rte_mbuf_iova_get(m))); -} - -static void * -va2pa_all(struct rte_mbuf *mbuf) -{ - void *phy_mbuf = va2pa(mbuf); - struct rte_mbuf *next = mbuf->next; - while (next) { - mbuf->next = va2pa(next); - mbuf = next; - next = mbuf->next; - } - return phy_mbuf; -} - -static void -obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj, - unsigned obj_idx __rte_unused) -{ - struct rte_mbuf *m = obj; - void *mbuf_phys = opaque; - - if (va2pa(m) == mbuf_phys) - rte_pktmbuf_free(m); -} - -static void -kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo) -{ - void *mbuf_phys; - int ret; - - do { - ret = kni_fifo_get(fifo, &mbuf_phys, 1); - if (ret) - rte_mempool_obj_iter(mp, obj_free, mbuf_phys); - } while (ret); -} - -int -rte_kni_release(struct rte_kni *kni) -{ - struct rte_tailq_entry *te; - struct rte_kni_list *kni_list; - struct rte_kni_device_info dev_info; - uint32_t retry = 5; - - if (!kni) - return -1; - - kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list); - - rte_mcfg_tailq_write_lock(); - - TAILQ_FOREACH(te, kni_list, next) { - if (te->data == kni) - break; - } - - if (te == NULL) - goto unlock; - - strlcpy(dev_info.name, kni->name, sizeof(dev_info.name)); - if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) { - RTE_LOG(ERR, KNI, "Fail to release kni device\n"); - goto unlock; - } - - TAILQ_REMOVE(kni_list, te, next); - - rte_mcfg_tailq_write_unlock(); - - /* mbufs in all fifo should be released, except request/response */ - - /* wait until all rxq packets processed by kernel */ - while (kni_fifo_count(kni->rx_q) && retry--) - usleep(1000); - - if (kni_fifo_count(kni->rx_q)) - RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); - - kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); - kni_free_fifo(kni->tx_q); - kni_free_fifo(kni->free_q); - - kni_release_mz(kni); - - rte_free(kni); - - rte_free(te); - - return 0; - -unlock: - rte_mcfg_tailq_write_unlock(); - - return -1; -} - -/* default callback for request of configuring device mac address */ -static int -kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) -{ - int ret = 0; - - if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); - return -EINVAL; - } - - RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id); - - ret = rte_eth_dev_default_mac_addr_set(port_id, - (struct rte_ether_addr *)mac_addr); - if (ret < 0) - RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n", - port_id); - - return ret; -} - -/* default callback for request of configuring promiscuous mode */ -static int -kni_config_promiscusity(uint16_t port_id, uint8_t to_on) -{ - int ret; - - if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); - return -EINVAL; - } - - RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", - port_id, to_on); - - if (to_on) - ret = rte_eth_promiscuous_enable(port_id); - else - ret = rte_eth_promiscuous_disable(port_id); - - if (ret != 0) - RTE_LOG(ERR, KNI, - "Failed to %s promiscuous mode for port %u: %s\n", - to_on ? "enable" : "disable", port_id, - rte_strerror(-ret)); - - return ret; -} - -/* default callback for request of configuring allmulticast mode */ -static int -kni_config_allmulticast(uint16_t port_id, uint8_t to_on) -{ - int ret; - - if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); - return -EINVAL; - } - - RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n", - port_id, to_on); - - if (to_on) - ret = rte_eth_allmulticast_enable(port_id); - else - ret = rte_eth_allmulticast_disable(port_id); - if (ret != 0) - RTE_LOG(ERR, KNI, - "Failed to %s allmulticast mode for port %u: %s\n", - to_on ? "enable" : "disable", port_id, - rte_strerror(-ret)); - - return ret; -} - -int -rte_kni_handle_request(struct rte_kni *kni) -{ - unsigned int ret; - struct rte_kni_request *req = NULL; - - if (kni == NULL) - return -1; - - /* Get request mbuf */ - ret = kni_fifo_get(kni->req_q, (void **)&req, 1); - if (ret != 1) - return 0; /* It is OK of can not getting the request mbuf */ - - if (req != kni->sync_addr) { - RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req); - return -1; - } - - /* Analyze the request and call the relevant actions for it */ - switch (req->req_id) { - case RTE_KNI_REQ_CHANGE_MTU: /* Change MTU */ - if (kni->ops.change_mtu) - req->result = kni->ops.change_mtu(kni->ops.port_id, - req->new_mtu); - break; - case RTE_KNI_REQ_CFG_NETWORK_IF: /* Set network interface up/down */ - if (kni->ops.config_network_if) - req->result = kni->ops.config_network_if(kni->ops.port_id, - req->if_up); - break; - case RTE_KNI_REQ_CHANGE_MAC_ADDR: /* Change MAC Address */ - if (kni->ops.config_mac_address) - req->result = kni->ops.config_mac_address( - kni->ops.port_id, req->mac_addr); - else if (kni->ops.port_id != UINT16_MAX) - req->result = kni_config_mac_address( - kni->ops.port_id, req->mac_addr); - break; - case RTE_KNI_REQ_CHANGE_PROMISC: /* Change PROMISCUOUS MODE */ - if (kni->ops.config_promiscusity) - req->result = kni->ops.config_promiscusity( - kni->ops.port_id, req->promiscusity); - else if (kni->ops.port_id != UINT16_MAX) - req->result = kni_config_promiscusity( - kni->ops.port_id, req->promiscusity); - break; - case RTE_KNI_REQ_CHANGE_ALLMULTI: /* Change ALLMULTICAST MODE */ - if (kni->ops.config_allmulticast) - req->result = kni->ops.config_allmulticast( - kni->ops.port_id, req->allmulti); - else if (kni->ops.port_id != UINT16_MAX) - req->result = kni_config_allmulticast( - kni->ops.port_id, req->allmulti); - break; - default: - RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); - req->result = -EINVAL; - break; - } - - /* if needed, construct response buffer and put it back to resp_q */ - if (!req->async) - ret = kni_fifo_put(kni->resp_q, (void **)&req, 1); - else - ret = 1; - if (ret != 1) { - RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n"); - return -1; /* It is an error of can't putting the mbuf back */ - } - - return 0; -} - -unsigned -rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) -{ - num = RTE_MIN(kni_fifo_free_count(kni->rx_q), num); - void *phy_mbufs[num]; - unsigned int ret; - unsigned int i; - - for (i = 0; i < num; i++) - phy_mbufs[i] = va2pa_all(mbufs[i]); - - ret = kni_fifo_put(kni->rx_q, phy_mbufs, num); - - /* Get mbufs from free_q and then free them */ - kni_free_mbufs(kni); - - return ret; -} - -unsigned -rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) -{ - unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); - - /* If buffers removed or alloc_q is empty, allocate mbufs and then put them into alloc_q */ - if (ret || (kni_fifo_count(kni->alloc_q) == 0)) - kni_allocate_mbufs(kni); - - return ret; -} - -static void -kni_free_mbufs(struct rte_kni *kni) -{ - int i, ret; - struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM]; - - ret = kni_fifo_get(kni->free_q, (void **)pkts, MAX_MBUF_BURST_NUM); - if (likely(ret > 0)) { - for (i = 0; i < ret; i++) - rte_pktmbuf_free(pkts[i]); - } -} - -static void -kni_allocate_mbufs(struct rte_kni *kni) -{ - int i, ret; - struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM]; - void *phys[MAX_MBUF_BURST_NUM]; - int allocq_free; - - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pool) != - offsetof(struct rte_kni_mbuf, pool)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_addr) != - offsetof(struct rte_kni_mbuf, buf_addr)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, next) != - offsetof(struct rte_kni_mbuf, next)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) != - offsetof(struct rte_kni_mbuf, data_off)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) != - offsetof(struct rte_kni_mbuf, data_len)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) != - offsetof(struct rte_kni_mbuf, pkt_len)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) != - offsetof(struct rte_kni_mbuf, ol_flags)); - - /* Check if pktmbuf pool has been configured */ - if (kni->pktmbuf_pool == NULL) { - RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n"); - return; - } - - allocq_free = kni_fifo_free_count(kni->alloc_q); - allocq_free = (allocq_free > MAX_MBUF_BURST_NUM) ? - MAX_MBUF_BURST_NUM : allocq_free; - for (i = 0; i < allocq_free; i++) { - pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); - if (unlikely(pkts[i] == NULL)) { - /* Out of memory */ - RTE_LOG(ERR, KNI, "Out of memory\n"); - break; - } - phys[i] = va2pa(pkts[i]); - } - - /* No pkt mbuf allocated */ - if (i <= 0) - return; - - ret = kni_fifo_put(kni->alloc_q, phys, i); - - /* Check if any mbufs not put into alloc_q, and then free them */ - if (ret >= 0 && ret < i && ret < MAX_MBUF_BURST_NUM) { - int j; - - for (j = ret; j < i; j++) - rte_pktmbuf_free(pkts[j]); - } -} - -struct rte_kni * -rte_kni_get(const char *name) -{ - struct rte_kni *kni; - - if (name == NULL || name[0] == '\0') - return NULL; - - rte_mcfg_tailq_read_lock(); - - kni = __rte_kni_get(name); - - rte_mcfg_tailq_read_unlock(); - - return kni; -} - -const char * -rte_kni_get_name(const struct rte_kni *kni) -{ - return kni->name; -} - -static enum kni_ops_status -kni_check_request_register(struct rte_kni_ops *ops) -{ - /* check if KNI request ops has been registered*/ - if (ops == NULL) - return KNI_REQ_NO_REGISTER; - - if (ops->change_mtu == NULL - && ops->config_network_if == NULL - && ops->config_mac_address == NULL - && ops->config_promiscusity == NULL - && ops->config_allmulticast == NULL) - return KNI_REQ_NO_REGISTER; - - return KNI_REQ_REGISTERED; -} - -int -rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops) -{ - enum kni_ops_status req_status; - - if (ops == NULL) { - RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n"); - return -1; - } - - if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); - return -1; - } - - req_status = kni_check_request_register(&kni->ops); - if (req_status == KNI_REQ_REGISTERED) { - RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n"); - return -1; - } - - memcpy(&kni->ops, ops, sizeof(struct rte_kni_ops)); - return 0; -} - -int -rte_kni_unregister_handlers(struct rte_kni *kni) -{ - if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); - return -1; - } - - memset(&kni->ops, 0, sizeof(struct rte_kni_ops)); - - return 0; -} - -int -rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) -{ - char path[64]; - char old_carrier[2]; - const char *new_carrier; - int old_linkup; - int fd, ret; - - if (kni == NULL) - return -1; - - snprintf(path, sizeof(path), "/sys/devices/virtual/net/%s/carrier", - kni->name); - - fd = open(path, O_RDWR); - if (fd == -1) { - RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path); - return -1; - } - - ret = read(fd, old_carrier, 2); - if (ret < 1) { - close(fd); - return -1; - } - old_linkup = (old_carrier[0] == '1'); - - if (old_linkup == (int)linkup) - goto out; - - new_carrier = linkup ? "1" : "0"; - ret = write(fd, new_carrier, 1); - if (ret < 1) { - RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path); - close(fd); - return -1; - } -out: - close(fd); - return old_linkup; -} - -void -rte_kni_close(void) -{ - if (kni_fd < 0) - return; - - close(kni_fd); - kni_fd = -1; -} diff --git a/dpdk/lib/kni/rte_kni.h b/dpdk/lib/kni/rte_kni.h deleted file mode 100644 index 1e508acc8..000000000 --- a/dpdk/lib/kni/rte_kni.h +++ /dev/null @@ -1,269 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef _RTE_KNI_H_ -#define _RTE_KNI_H_ - -/** - * @file - * RTE KNI - * - * The KNI library provides the ability to create and destroy kernel NIC - * interfaces that may be used by the RTE application to receive/transmit - * packets from/to Linux kernel net interfaces. - * - * This library provides two APIs to burst receive packets from KNI interfaces, - * and burst transmit packets to KNI interfaces. - */ - -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct rte_kni; -struct rte_mbuf; - -/** - * Structure which has the function pointers for KNI interface. - */ -struct rte_kni_ops { - uint16_t port_id; /* Port ID */ - - /* Pointer to function of changing MTU */ - int (*change_mtu)(uint16_t port_id, unsigned int new_mtu); - - /* Pointer to function of configuring network interface */ - int (*config_network_if)(uint16_t port_id, uint8_t if_up); - - /* Pointer to function of configuring mac address */ - int (*config_mac_address)(uint16_t port_id, uint8_t mac_addr[]); - - /* Pointer to function of configuring promiscuous mode */ - int (*config_promiscusity)(uint16_t port_id, uint8_t to_on); - - /* Pointer to function of configuring allmulticast mode */ - int (*config_allmulticast)(uint16_t port_id, uint8_t to_on); -}; - -/** - * Structure for configuring KNI device. - */ -struct rte_kni_conf { - /* - * KNI name which will be used in relevant network device. - * Let the name as short as possible, as it will be part of - * memzone name. - */ - char name[RTE_KNI_NAMESIZE]; - uint32_t core_id; /* Core ID to bind kernel thread on */ - uint16_t group_id; /* Group ID */ - unsigned mbuf_size; /* mbuf size */ - struct rte_pci_addr addr; /* deprecated */ - struct rte_pci_id id; /* deprecated */ - - __extension__ - uint8_t force_bind : 1; /* Flag to bind kernel thread */ - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; /* MAC address assigned to KNI */ - uint16_t mtu; - uint16_t min_mtu; - uint16_t max_mtu; -}; - -/** - * Initialize and preallocate KNI subsystem - * - * This function is to be executed on the main lcore only, after EAL - * initialization and before any KNI interface is attempted to be - * allocated - * - * @param max_kni_ifaces - * The maximum number of KNI interfaces that can coexist concurrently - * - * @return - * - 0 indicates success. - * - negative value indicates failure. - */ -int rte_kni_init(unsigned int max_kni_ifaces); - - -/** - * Allocate KNI interface according to the port id, mbuf size, mbuf pool, - * configurations and callbacks for kernel requests.The KNI interface created - * in the kernel space is the net interface the traditional Linux application - * talking to. - * - * The rte_kni_alloc shall not be called before rte_kni_init() has been - * called. rte_kni_alloc is thread safe. - * - * The mempool should have capacity of more than "2 x KNI_FIFO_COUNT_MAX" - * elements for each KNI interface allocated. - * - * @param pktmbuf_pool - * The mempool for allocating mbufs for packets. - * @param conf - * The pointer to the configurations of the KNI device. - * @param ops - * The pointer to the callbacks for the KNI kernel requests. - * - * @return - * - The pointer to the context of a KNI interface. - * - NULL indicate error. - */ -struct rte_kni *rte_kni_alloc(struct rte_mempool *pktmbuf_pool, - const struct rte_kni_conf *conf, struct rte_kni_ops *ops); - -/** - * Release KNI interface according to the context. It will also release the - * paired KNI interface in kernel space. All processing on the specific KNI - * context need to be stopped before calling this interface. - * - * rte_kni_release is thread safe. - * - * @param kni - * The pointer to the context of an existent KNI interface. - * - * @return - * - 0 indicates success. - * - negative value indicates failure. - */ -int rte_kni_release(struct rte_kni *kni); - -/** - * It is used to handle the request mbufs sent from kernel space. - * Then analyzes it and calls the specific actions for the specific requests. - * Finally constructs the response mbuf and puts it back to the resp_q. - * - * @param kni - * The pointer to the context of an existent KNI interface. - * - * @return - * - 0 - * - negative value indicates failure. - */ -int rte_kni_handle_request(struct rte_kni *kni); - -/** - * Retrieve a burst of packets from a KNI interface. The retrieved packets are - * stored in rte_mbuf structures whose pointers are supplied in the array of - * mbufs, and the maximum number is indicated by num. It handles allocating - * the mbufs for KNI interface alloc queue. - * - * @param kni - * The KNI interface context. - * @param mbufs - * The array to store the pointers of mbufs. - * @param num - * The maximum number per burst. - * - * @return - * The actual number of packets retrieved. - */ -unsigned rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, - unsigned num); - -/** - * Send a burst of packets to a KNI interface. The packets to be sent out are - * stored in rte_mbuf structures whose pointers are supplied in the array of - * mbufs, and the maximum number is indicated by num. It handles the freeing of - * the mbufs in the free queue of KNI interface. - * - * @param kni - * The KNI interface context. - * @param mbufs - * The array to store the pointers of mbufs. - * @param num - * The maximum number per burst. - * - * @return - * The actual number of packets sent. - */ -unsigned rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, - unsigned num); - -/** - * Get the KNI context of its name. - * - * @param name - * pointer to the KNI device name. - * - * @return - * On success: Pointer to KNI interface. - * On failure: NULL. - */ -struct rte_kni *rte_kni_get(const char *name); - -/** - * Get the name given to a KNI device - * - * @param kni - * The KNI instance to query - * @return - * The pointer to the KNI name - */ -const char *rte_kni_get_name(const struct rte_kni *kni); - -/** - * Register KNI request handling for a specified port,and it can - * be called by primary process or secondary process. - * - * @param kni - * pointer to struct rte_kni. - * @param ops - * pointer to struct rte_kni_ops. - * - * @return - * On success: 0 - * On failure: -1 - */ -int rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops); - -/** - * Unregister KNI request handling for a specified port. - * - * @param kni - * pointer to struct rte_kni. - * - * @return - * On success: 0 - * On failure: -1 - */ -int rte_kni_unregister_handlers(struct rte_kni *kni); - -/** - * Update link carrier state for KNI port. - * - * Update the linkup/linkdown state of a KNI interface in the kernel. - * - * @param kni - * pointer to struct rte_kni. - * @param linkup - * New link state: - * 0 for linkdown. - * > 0 for linkup. - * - * @return - * On failure: -1 - * Previous link state == linkdown: 0 - * Previous link state == linkup: 1 - */ -__rte_experimental -int -rte_kni_update_link(struct rte_kni *kni, unsigned int linkup); - -/** - * Close KNI device. - */ -void rte_kni_close(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_KNI_H_ */ diff --git a/dpdk/lib/kni/rte_kni_common.h b/dpdk/lib/kni/rte_kni_common.h deleted file mode 100644 index 8d3ee0fa4..000000000 --- a/dpdk/lib/kni/rte_kni_common.h +++ /dev/null @@ -1,147 +0,0 @@ -/* SPDX-License-Identifier: (BSD-3-Clause OR LGPL-2.1) */ -/* - * Copyright(c) 2007-2014 Intel Corporation. - */ - -#ifndef _RTE_KNI_COMMON_H_ -#define _RTE_KNI_COMMON_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __KERNEL__ -#include -#include -#define RTE_STD_C11 -#else -#include -#include -#endif - -/* - * KNI name is part of memzone name. Must not exceed IFNAMSIZ. - */ -#define RTE_KNI_NAMESIZE 16 - -#define RTE_CACHE_LINE_MIN_SIZE 64 - -/* - * Request id. - */ -enum rte_kni_req_id { - RTE_KNI_REQ_UNKNOWN = 0, - RTE_KNI_REQ_CHANGE_MTU, - RTE_KNI_REQ_CFG_NETWORK_IF, - RTE_KNI_REQ_CHANGE_MAC_ADDR, - RTE_KNI_REQ_CHANGE_PROMISC, - RTE_KNI_REQ_CHANGE_ALLMULTI, - RTE_KNI_REQ_MAX, -}; - -/* - * Structure for KNI request. - */ -struct rte_kni_request { - uint32_t req_id; /**< Request id */ - RTE_STD_C11 - union { - uint32_t new_mtu; /**< New MTU */ - uint8_t if_up; /**< 1: interface up, 0: interface down */ - uint8_t mac_addr[6]; /**< MAC address for interface */ - uint8_t promiscusity;/**< 1: promisc mode enable, 0: disable */ - uint8_t allmulti; /**< 1: all-multicast mode enable, 0: disable */ - }; - int32_t async : 1; /**< 1: request is asynchronous */ - int32_t result; /**< Result for processing request */ -} __attribute__((__packed__)); - -/* - * Fifo struct mapped in a shared memory. It describes a circular buffer FIFO - * Write and read should wrap around. Fifo is empty when write == read - * Writing should never overwrite the read position - */ -struct rte_kni_fifo { -#ifdef RTE_USE_C11_MEM_MODEL - unsigned write; /**< Next position to be written*/ - unsigned read; /**< Next position to be read */ -#else - volatile unsigned write; /**< Next position to be written*/ - volatile unsigned read; /**< Next position to be read */ -#endif - unsigned len; /**< Circular buffer length */ - unsigned elem_size; /**< Pointer size - for 32/64 bit OS */ - void *volatile buffer[]; /**< The buffer contains mbuf pointers */ -}; - -/* - * The kernel image of the rte_mbuf struct, with only the relevant fields. - * Padding is necessary to assure the offsets of these fields - */ -struct rte_kni_mbuf { - void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); - uint64_t buf_iova; - uint16_t data_off; /**< Start address of data in segment buffer. */ - char pad1[2]; - uint16_t nb_segs; /**< Number of segments. */ - char pad4[2]; - uint64_t ol_flags; /**< Offload features. */ - char pad2[4]; - uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ - uint16_t data_len; /**< Amount of data in segment buffer. */ - char pad3[14]; - void *pool; - - /* fields on second cache line */ - __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE))) - void *next; /**< Physical address of next mbuf in kernel. */ -}; - -/* - * Struct used to create a KNI device. Passed to the kernel in IOCTL call - */ - -struct rte_kni_device_info { - char name[RTE_KNI_NAMESIZE]; /**< Network device name for KNI */ - - phys_addr_t tx_phys; - phys_addr_t rx_phys; - phys_addr_t alloc_phys; - phys_addr_t free_phys; - - /* Used by Ethtool */ - phys_addr_t req_phys; - phys_addr_t resp_phys; - phys_addr_t sync_phys; - void * sync_va; - - /* mbuf mempool */ - void * mbuf_va; - phys_addr_t mbuf_phys; - - uint16_t group_id; /**< Group ID */ - uint32_t core_id; /**< core ID to bind for kernel thread */ - - __extension__ - uint8_t force_bind : 1; /**< Flag for kernel thread binding */ - - /* mbuf size */ - unsigned mbuf_size; - unsigned int mtu; - unsigned int min_mtu; - unsigned int max_mtu; - uint8_t mac_addr[6]; - uint8_t iova_mode; -}; - -#define KNI_DEVICE "kni" - -#define RTE_KNI_IOCTL_TEST _IOWR(0, 1, int) -#define RTE_KNI_IOCTL_CREATE _IOWR(0, 2, struct rte_kni_device_info) -#define RTE_KNI_IOCTL_RELEASE _IOWR(0, 3, struct rte_kni_device_info) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_KNI_COMMON_H_ */ diff --git a/dpdk/lib/kni/rte_kni_fifo.h b/dpdk/lib/kni/rte_kni_fifo.h deleted file mode 100644 index d2ec82fe8..000000000 --- a/dpdk/lib/kni/rte_kni_fifo.h +++ /dev/null @@ -1,117 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - - - -/** - * @internal when c11 memory model enabled use c11 atomic memory barrier. - * when under non c11 memory model use rte_smp_* memory barrier. - * - * @param src - * Pointer to the source data. - * @param dst - * Pointer to the destination data. - * @param value - * Data value. - */ -#ifdef RTE_USE_C11_MEM_MODEL -#define __KNI_LOAD_ACQUIRE(src) ({ \ - __atomic_load_n((src), __ATOMIC_ACQUIRE); \ - }) -#define __KNI_STORE_RELEASE(dst, value) do { \ - __atomic_store_n((dst), value, __ATOMIC_RELEASE); \ - } while(0) -#else -#define __KNI_LOAD_ACQUIRE(src) ({ \ - typeof (*(src)) val = *(src); \ - rte_smp_rmb(); \ - val; \ - }) -#define __KNI_STORE_RELEASE(dst, value) do { \ - *(dst) = value; \ - rte_smp_wmb(); \ - } while(0) -#endif - -/** - * Initializes the kni fifo structure - */ -static void -kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size) -{ - /* Ensure size is power of 2 */ - if (size & (size - 1)) - rte_panic("KNI fifo size must be power of 2\n"); - - fifo->write = 0; - fifo->read = 0; - fifo->len = size; - fifo->elem_size = sizeof(void *); -} - -/** - * Adds num elements into the fifo. Return the number actually written - */ -static inline unsigned -kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num) -{ - unsigned i = 0; - unsigned fifo_write = fifo->write; - unsigned new_write = fifo_write; - unsigned fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); - - for (i = 0; i < num; i++) { - new_write = (new_write + 1) & (fifo->len - 1); - - if (new_write == fifo_read) - break; - fifo->buffer[fifo_write] = data[i]; - fifo_write = new_write; - } - __KNI_STORE_RELEASE(&fifo->write, fifo_write); - return i; -} - -/** - * Get up to num elements from the fifo. Return the number actually read - */ -static inline unsigned -kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num) -{ - unsigned i = 0; - unsigned new_read = fifo->read; - unsigned fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); - - for (i = 0; i < num; i++) { - if (new_read == fifo_write) - break; - - data[i] = fifo->buffer[new_read]; - new_read = (new_read + 1) & (fifo->len - 1); - } - __KNI_STORE_RELEASE(&fifo->read, new_read); - return i; -} - -/** - * Get the num of elements in the fifo - */ -static inline uint32_t -kni_fifo_count(struct rte_kni_fifo *fifo) -{ - unsigned fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); - unsigned fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); - return (fifo->len + fifo_write - fifo_read) & (fifo->len - 1); -} - -/** - * Get the num of available elements in the fifo - */ -static inline uint32_t -kni_fifo_free_count(struct rte_kni_fifo *fifo) -{ - uint32_t fifo_write = __KNI_LOAD_ACQUIRE(&fifo->write); - uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read); - return (fifo_read - fifo_write - 1) & (fifo->len - 1); -} diff --git a/dpdk/lib/kni/version.map b/dpdk/lib/kni/version.map deleted file mode 100644 index 83bbbe880..000000000 --- a/dpdk/lib/kni/version.map +++ /dev/null @@ -1,24 +0,0 @@ -DPDK_23 { - global: - - rte_kni_alloc; - rte_kni_close; - rte_kni_get; - rte_kni_get_name; - rte_kni_handle_request; - rte_kni_init; - rte_kni_register_handlers; - rte_kni_release; - rte_kni_rx_burst; - rte_kni_tx_burst; - rte_kni_unregister_handlers; - - local: *; -}; - -EXPERIMENTAL { - global: - - # updated in v21.08 - rte_kni_update_link; -}; diff --git a/dpdk/lib/mempool/rte_mempool_trace.h b/dpdk/lib/mempool/rte_mempool_trace.h deleted file mode 100644 index 087c913c8..000000000 --- a/dpdk/lib/mempool/rte_mempool_trace.h +++ /dev/null @@ -1,175 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(C) 2020 Marvell International Ltd. - */ - -#ifndef _RTE_MEMPOOL_TRACE_H_ -#define _RTE_MEMPOOL_TRACE_H_ - -/** - * @file - * - * APIs for mempool trace support - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "rte_mempool.h" - -#include -#include - -RTE_TRACE_POINT( - rte_mempool_trace_create, - RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, - uint32_t elt_size, uint32_t cache_size, - uint32_t private_data_size, void *mp_init, void *mp_init_arg, - void *obj_init, void *obj_init_arg, uint32_t flags, - struct rte_mempool *mempool), - rte_trace_point_emit_string(name); - rte_trace_point_emit_u32(nb_elts); - rte_trace_point_emit_u32(elt_size); - rte_trace_point_emit_u32(cache_size); - rte_trace_point_emit_u32(private_data_size); - rte_trace_point_emit_ptr(mp_init); - rte_trace_point_emit_ptr(mp_init_arg); - rte_trace_point_emit_ptr(obj_init); - rte_trace_point_emit_ptr(obj_init_arg); - rte_trace_point_emit_u32(flags); - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_i32(mempool->ops_index); -) - -RTE_TRACE_POINT( - rte_mempool_trace_create_empty, - RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, - uint32_t elt_size, uint32_t cache_size, - uint32_t private_data_size, uint32_t flags, - struct rte_mempool *mempool), - rte_trace_point_emit_string(name); - rte_trace_point_emit_u32(nb_elts); - rte_trace_point_emit_u32(elt_size); - rte_trace_point_emit_u32(cache_size); - rte_trace_point_emit_u32(private_data_size); - rte_trace_point_emit_u32(flags); - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_i32(mempool->ops_index); -) - -RTE_TRACE_POINT( - rte_mempool_trace_free, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); -) - -RTE_TRACE_POINT( - rte_mempool_trace_populate_iova, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool, void *vaddr, - rte_iova_t iova, size_t len, void *free_cb, void *opaque), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); - rte_trace_point_emit_ptr(vaddr); - rte_trace_point_emit_u64(iova); - rte_trace_point_emit_size_t(len); - rte_trace_point_emit_ptr(free_cb); - rte_trace_point_emit_ptr(opaque); -) - -RTE_TRACE_POINT( - rte_mempool_trace_populate_virt, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool, void *addr, - size_t len, size_t pg_sz, void *free_cb, void *opaque), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); - rte_trace_point_emit_ptr(addr); - rte_trace_point_emit_size_t(len); - rte_trace_point_emit_size_t(pg_sz); - rte_trace_point_emit_ptr(free_cb); - rte_trace_point_emit_ptr(opaque); -) - -RTE_TRACE_POINT( - rte_mempool_trace_populate_default, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); -) - -RTE_TRACE_POINT( - rte_mempool_trace_populate_anon, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); -) - -RTE_TRACE_POINT( - rte_mempool_trace_cache_create, - RTE_TRACE_POINT_ARGS(uint32_t size, int socket_id, - struct rte_mempool_cache *cache), - rte_trace_point_emit_u32(size); - rte_trace_point_emit_i32(socket_id); - rte_trace_point_emit_ptr(cache); - rte_trace_point_emit_u32(cache->len); - rte_trace_point_emit_u32(cache->flushthresh); -) - -RTE_TRACE_POINT( - rte_mempool_trace_cache_free, - RTE_TRACE_POINT_ARGS(void *cache), - rte_trace_point_emit_ptr(cache); -) - -RTE_TRACE_POINT( - rte_mempool_trace_get_page_size, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool, size_t pg_sz), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); - rte_trace_point_emit_size_t(pg_sz); -) - -RTE_TRACE_POINT( - rte_mempool_trace_ops_populate, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool, uint32_t max_objs, - void *vaddr, uint64_t iova, size_t len, void *obj_cb, - void *obj_cb_arg), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); - rte_trace_point_emit_u32(max_objs); - rte_trace_point_emit_ptr(vaddr); - rte_trace_point_emit_u64(iova); - rte_trace_point_emit_size_t(len); - rte_trace_point_emit_ptr(obj_cb); - rte_trace_point_emit_ptr(obj_cb_arg); -) - -RTE_TRACE_POINT( - rte_mempool_trace_ops_alloc, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); -) - -RTE_TRACE_POINT( - rte_mempool_trace_ops_free, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); -) - -RTE_TRACE_POINT( - rte_mempool_trace_set_ops_byname, - RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool, const char *name, - void *pool_config), - rte_trace_point_emit_ptr(mempool); - rte_trace_point_emit_string(mempool->name); - rte_trace_point_emit_string(name); - rte_trace_point_emit_ptr(pool_config); -) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTE_MEMPOOL_TRACE_H_ */ diff --git a/dpdk/lib/port/rte_port_kni.c b/dpdk/lib/port/rte_port_kni.c deleted file mode 100644 index 1c7a6cb20..000000000 --- a/dpdk/lib/port/rte_port_kni.c +++ /dev/null @@ -1,515 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016 Ethan Zhuang . - * Copyright(c) 2016 Intel Corporation. - */ -#include - -#include -#include - -#include "rte_port_kni.h" - -/* - * Port KNI Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_KNI_READER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_KNI_READER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_KNI_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_KNI_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_kni_reader { - struct rte_port_in_stats stats; - - struct rte_kni *kni; -}; - -static void * -rte_port_kni_reader_create(void *params, int socket_id) -{ - struct rte_port_kni_reader_params *conf = - params; - struct rte_port_kni_reader *port; - - /* Check input parameters */ - if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); - return NULL; - } - - /* Initialization */ - port->kni = conf->kni; - - return port; -} - -static int -rte_port_kni_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_kni_reader *p = - port; - uint16_t rx_pkt_cnt; - - rx_pkt_cnt = rte_kni_rx_burst(p->kni, pkts, n_pkts); - RTE_PORT_KNI_READER_STATS_PKTS_IN_ADD(p, rx_pkt_cnt); - return rx_pkt_cnt; -} - -static int -rte_port_kni_reader_free(void *port) -{ - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int rte_port_kni_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_kni_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port KNI Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_KNI_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_KNI_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_kni_writer { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - struct rte_kni *kni; -}; - -static void * -rte_port_kni_writer_create(void *params, int socket_id) -{ - struct rte_port_kni_writer_params *conf = - params; - struct rte_port_kni_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); - return NULL; - } - - /* Initialization */ - port->kni = conf->kni; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - return port; -} - -static inline void -send_burst(struct rte_port_kni_writer *p) -{ - uint32_t nb_tx; - - nb_tx = rte_kni_tx_burst(p->kni, p->tx_buf, p->tx_buf_count); - - RTE_PORT_KNI_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for (; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_kni_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_kni_writer *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_kni_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_kni_writer *p = - port; - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = __builtin_popcountll(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) - send_burst(p); - - RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - n_pkts_ok = rte_kni_tx_burst(p->kni, pkts, n_pkts); - - RTE_PORT_KNI_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok); - for (; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - - rte_pktmbuf_free(pkt); - } - } else { - for (; pkts_mask;) { - uint32_t pkt_index = __builtin_ctzll(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst(p); - } - - return 0; -} - -static int -rte_port_kni_writer_flush(void *port) -{ - struct rte_port_kni_writer *p = - port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_kni_writer_free(void *port) -{ - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); - return -EINVAL; - } - - rte_port_kni_writer_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_kni_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_kni_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port KNI Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_kni_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - uint64_t n_retries; - struct rte_kni *kni; -}; - -static void * -rte_port_kni_writer_nodrop_create(void *params, int socket_id) -{ - struct rte_port_kni_writer_nodrop_params *conf = - params; - struct rte_port_kni_writer_nodrop *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); - return NULL; - } - - /* Initialization */ - port->kni = conf->kni; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - /* - * When n_retries is 0 it means that we should wait for every packet to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static inline void -send_burst_nodrop(struct rte_port_kni_writer_nodrop *p) -{ - uint32_t nb_tx = 0, i; - - nb_tx = rte_kni_tx_burst(p->kni, p->tx_buf, p->tx_buf_count); - - /* We sent all the packets in a first try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_tx += rte_kni_tx_burst(p->kni, - p->tx_buf + nb_tx, - p->tx_buf_count - nb_tx); - - /* We sent all the packets in more than one try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - } - - /* We didn't send the packets in maximum allowed attempts */ - RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_kni_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_kni_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_kni_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_kni_writer_nodrop *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = __builtin_popcountll(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) - send_burst_nodrop(p); - - RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - n_pkts_ok = rte_kni_tx_burst(p->kni, pkts, n_pkts); - - if (n_pkts_ok >= n_pkts) - return 0; - - /* - * If we didn't manage to send all packets in single burst, move - * remaining packets to the buffer and call send burst. - */ - for (; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - p->tx_buf[p->tx_buf_count++] = pkt; - } - send_burst_nodrop(p); - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = __builtin_ctzll(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_KNI_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - } - - return 0; -} - -static int -rte_port_kni_writer_nodrop_flush(void *port) -{ - struct rte_port_kni_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_kni_writer_nodrop_free(void *port) -{ - if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); - return -EINVAL; - } - - rte_port_kni_writer_nodrop_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_kni_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_kni_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - - -/* - * Summary of port operations - */ -struct rte_port_in_ops rte_port_kni_reader_ops = { - .f_create = rte_port_kni_reader_create, - .f_free = rte_port_kni_reader_free, - .f_rx = rte_port_kni_reader_rx, - .f_stats = rte_port_kni_reader_stats_read, -}; - -struct rte_port_out_ops rte_port_kni_writer_ops = { - .f_create = rte_port_kni_writer_create, - .f_free = rte_port_kni_writer_free, - .f_tx = rte_port_kni_writer_tx, - .f_tx_bulk = rte_port_kni_writer_tx_bulk, - .f_flush = rte_port_kni_writer_flush, - .f_stats = rte_port_kni_writer_stats_read, -}; - -struct rte_port_out_ops rte_port_kni_writer_nodrop_ops = { - .f_create = rte_port_kni_writer_nodrop_create, - .f_free = rte_port_kni_writer_nodrop_free, - .f_tx = rte_port_kni_writer_nodrop_tx, - .f_tx_bulk = rte_port_kni_writer_nodrop_tx_bulk, - .f_flush = rte_port_kni_writer_nodrop_flush, - .f_stats = rte_port_kni_writer_nodrop_stats_read, -}; diff --git a/dpdk/lib/port/rte_port_kni.h b/dpdk/lib/port/rte_port_kni.h deleted file mode 100644 index 35c625380..000000000 --- a/dpdk/lib/port/rte_port_kni.h +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016 Ethan Zhuang . - * Copyright(c) 2016 Intel Corporation. - */ - -#ifndef __INCLUDE_RTE_PORT_KNI_H__ -#define __INCLUDE_RTE_PORT_KNI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * RTE Port KNI Interface - * - * kni_reader: input port built on top of pre-initialized KNI interface - * kni_writer: output port built on top of pre-initialized KNI interface - * - ***/ - -#include - - -#include "rte_port.h" - -/** kni_reader port parameters */ -struct rte_port_kni_reader_params { - /** KNI interface reference */ - struct rte_kni *kni; -}; - -/** kni_reader port operations */ -extern struct rte_port_in_ops rte_port_kni_reader_ops; - - -/** kni_writer port parameters */ -struct rte_port_kni_writer_params { - /** KNI interface reference */ - struct rte_kni *kni; - /** Burst size to KNI interface. */ - uint32_t tx_burst_sz; -}; - -/** kni_writer port operations */ -extern struct rte_port_out_ops rte_port_kni_writer_ops; - -/** kni_writer_nodrop port parameters */ -struct rte_port_kni_writer_nodrop_params { - /** KNI interface reference */ - struct rte_kni *kni; - /** Burst size to KNI interface. */ - uint32_t tx_burst_sz; - /** Maximum number of retries, 0 for no limit */ - uint32_t n_retries; -}; - -/** kni_writer_nodrop port operations */ -extern struct rte_port_out_ops rte_port_kni_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dpdk/lib/power/rte_power_empty_poll.c b/dpdk/lib/power/rte_power_empty_poll.c deleted file mode 100644 index 4a4db5124..000000000 --- a/dpdk/lib/power/rte_power_empty_poll.c +++ /dev/null @@ -1,529 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2018 Intel Corporation - */ - -#include - -#include -#include -#include - -#include "rte_power.h" -#include "rte_power_empty_poll.h" - -#define INTERVALS_PER_SECOND 100 /* (10ms) */ -#define SECONDS_TO_TRAIN_FOR 2 -#define DEFAULT_MED_TO_HIGH_PERCENT_THRESHOLD 70 -#define DEFAULT_HIGH_TO_MED_PERCENT_THRESHOLD 30 -#define DEFAULT_CYCLES_PER_PACKET 800 - -static struct ep_params *ep_params; -static uint32_t med_to_high_threshold = DEFAULT_MED_TO_HIGH_PERCENT_THRESHOLD; -static uint32_t high_to_med_threshold = DEFAULT_HIGH_TO_MED_PERCENT_THRESHOLD; - -static uint32_t avail_freqs[RTE_MAX_LCORE][NUM_FREQS]; - -static uint32_t total_avail_freqs[RTE_MAX_LCORE]; - -static uint32_t freq_index[NUM_FREQ]; - -static uint32_t -get_freq_index(enum freq_val index) -{ - return freq_index[index]; -} - - -static int -set_power_freq(int lcore_id, enum freq_val freq, bool specific_freq) -{ - int err = 0; - uint32_t power_freq_index; - if (!specific_freq) - power_freq_index = get_freq_index(freq); - else - power_freq_index = freq; - - err = rte_power_set_freq(lcore_id, power_freq_index); - - return err; -} - - -static __rte_always_inline void -exit_training_state(struct priority_worker *poll_stats) -{ - RTE_SET_USED(poll_stats); -} - -static __rte_always_inline void -enter_training_state(struct priority_worker *poll_stats) -{ - poll_stats->iter_counter = 0; - poll_stats->cur_freq = LOW; - poll_stats->queue_state = TRAINING; -} - -static __rte_always_inline void -enter_normal_state(struct priority_worker *poll_stats) -{ - /* Clear the averages arrays and strs */ - memset(poll_stats->edpi_av, 0, sizeof(poll_stats->edpi_av)); - poll_stats->ec = 0; - - poll_stats->cur_freq = MED; - poll_stats->iter_counter = 0; - poll_stats->threshold_ctr = 0; - poll_stats->queue_state = MED_NORMAL; - RTE_LOG(INFO, POWER, "Set the power freq to MED\n"); - set_power_freq(poll_stats->lcore_id, MED, false); - - poll_stats->thresh[MED].threshold_percent = med_to_high_threshold; - poll_stats->thresh[HGH].threshold_percent = high_to_med_threshold; -} - -static __rte_always_inline void -enter_busy_state(struct priority_worker *poll_stats) -{ - memset(poll_stats->edpi_av, 0, sizeof(poll_stats->edpi_av)); - poll_stats->ec = 0; - - poll_stats->cur_freq = HGH; - poll_stats->iter_counter = 0; - poll_stats->threshold_ctr = 0; - poll_stats->queue_state = HGH_BUSY; - set_power_freq(poll_stats->lcore_id, HGH, false); -} - -static __rte_always_inline void -enter_purge_state(struct priority_worker *poll_stats) -{ - poll_stats->iter_counter = 0; - poll_stats->queue_state = LOW_PURGE; -} - -static __rte_always_inline void -set_state(struct priority_worker *poll_stats, - enum queue_state new_state) -{ - enum queue_state old_state = poll_stats->queue_state; - if (old_state != new_state) { - - /* Call any old state exit functions */ - if (old_state == TRAINING) - exit_training_state(poll_stats); - - /* Call any new state entry functions */ - if (new_state == TRAINING) - enter_training_state(poll_stats); - if (new_state == MED_NORMAL) - enter_normal_state(poll_stats); - if (new_state == HGH_BUSY) - enter_busy_state(poll_stats); - if (new_state == LOW_PURGE) - enter_purge_state(poll_stats); - } -} - -static __rte_always_inline void -set_policy(struct priority_worker *poll_stats, - struct ep_policy *policy) -{ - set_state(poll_stats, policy->state); - - if (policy->state == TRAINING) - return; - - poll_stats->thresh[MED_NORMAL].base_edpi = policy->med_base_edpi; - poll_stats->thresh[HGH_BUSY].base_edpi = policy->hgh_base_edpi; - - poll_stats->thresh[MED_NORMAL].trained = true; - poll_stats->thresh[HGH_BUSY].trained = true; - -} - -static void -update_training_stats(struct priority_worker *poll_stats, - uint32_t freq, - bool specific_freq, - uint32_t max_train_iter) -{ - RTE_SET_USED(specific_freq); - - uint64_t p0_empty_deq; - - if (poll_stats->cur_freq == freq && - poll_stats->thresh[freq].trained == false) { - if (poll_stats->thresh[freq].cur_train_iter == 0) { - - set_power_freq(poll_stats->lcore_id, - freq, specific_freq); - - poll_stats->empty_dequeues_prev = - poll_stats->empty_dequeues; - - poll_stats->thresh[freq].cur_train_iter++; - - return; - } else if (poll_stats->thresh[freq].cur_train_iter - <= max_train_iter) { - - p0_empty_deq = poll_stats->empty_dequeues - - poll_stats->empty_dequeues_prev; - - poll_stats->empty_dequeues_prev = - poll_stats->empty_dequeues; - - poll_stats->thresh[freq].base_edpi += p0_empty_deq; - poll_stats->thresh[freq].cur_train_iter++; - - } else { - if (poll_stats->thresh[freq].trained == false) { - poll_stats->thresh[freq].base_edpi = - poll_stats->thresh[freq].base_edpi / - max_train_iter; - - /* Add on a factor of 0.05% - * this should remove any - * false negatives when the system is 0% busy - */ - poll_stats->thresh[freq].base_edpi += - poll_stats->thresh[freq].base_edpi / 2000; - - poll_stats->thresh[freq].trained = true; - poll_stats->cur_freq++; - - } - } - } -} - -static __rte_always_inline uint32_t -update_stats(struct priority_worker *poll_stats) -{ - uint64_t tot_edpi = 0; - uint32_t j, percent; - - struct priority_worker *s = poll_stats; - - uint64_t cur_edpi = s->empty_dequeues - s->empty_dequeues_prev; - - s->empty_dequeues_prev = s->empty_dequeues; - - if (s->thresh[s->cur_freq].base_edpi < cur_edpi) { - - /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cur_edpi is too large " - "cur edpi %"PRId64" " - "base edpi %"PRId64"\n", - cur_edpi, - s->thresh[s->cur_freq].base_edpi); - /* Value to make us fail need debug log*/ - return 1000UL; - } - - s->edpi_av[s->ec++ % BINS_AV] = cur_edpi; - - for (j = 0; j < BINS_AV; j++) { - tot_edpi += s->edpi_av[j]; - } - - tot_edpi = tot_edpi / BINS_AV; - - percent = 100 - (uint32_t)(((float)tot_edpi / - (float)s->thresh[s->cur_freq].base_edpi) * 100); - - return (uint32_t)percent; -} - - -static __rte_always_inline void -update_stats_normal(struct priority_worker *poll_stats) -{ - uint32_t percent; - - if (poll_stats->thresh[poll_stats->cur_freq].base_edpi == 0) { - - enum freq_val cur_freq = poll_stats->cur_freq; - - /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n", - cur_freq, - poll_stats->thresh[cur_freq].base_edpi); - return; - } - - percent = update_stats(poll_stats); - - if (percent > 100) { - /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n"); - return; - } - - if (poll_stats->cur_freq == LOW) - RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n"); - else if (poll_stats->cur_freq == MED) { - - if (percent > - poll_stats->thresh[MED].threshold_percent) { - - if (poll_stats->threshold_ctr < INTERVALS_PER_SECOND) - poll_stats->threshold_ctr++; - else { - set_state(poll_stats, HGH_BUSY); - RTE_LOG(INFO, POWER, "MOVE to HGH\n"); - } - - } else { - /* reset */ - poll_stats->threshold_ctr = 0; - } - - } else if (poll_stats->cur_freq == HGH) { - - if (percent < - poll_stats->thresh[HGH].threshold_percent) { - - if (poll_stats->threshold_ctr < INTERVALS_PER_SECOND) - poll_stats->threshold_ctr++; - else { - set_state(poll_stats, MED_NORMAL); - RTE_LOG(INFO, POWER, "MOVE to MED\n"); - } - } else { - /* reset */ - poll_stats->threshold_ctr = 0; - } - - } -} - -static int -empty_poll_training(struct priority_worker *poll_stats, - uint32_t max_train_iter) -{ - - if (poll_stats->iter_counter < INTERVALS_PER_SECOND) { - poll_stats->iter_counter++; - return 0; - } - - - update_training_stats(poll_stats, - LOW, - false, - max_train_iter); - - update_training_stats(poll_stats, - MED, - false, - max_train_iter); - - update_training_stats(poll_stats, - HGH, - false, - max_train_iter); - - - if (poll_stats->thresh[LOW].trained == true - && poll_stats->thresh[MED].trained == true - && poll_stats->thresh[HGH].trained == true) { - - set_state(poll_stats, MED_NORMAL); - - RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n", - poll_stats->thresh[LOW].base_edpi); - - RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n", - poll_stats->thresh[MED].base_edpi); - - - RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n", - poll_stats->thresh[HGH].base_edpi); - - RTE_LOG(INFO, POWER, "Training is Complete for %d\n", - poll_stats->lcore_id); - } - - return 0; -} - -void -rte_empty_poll_detection(struct rte_timer *tim, void *arg) -{ - - uint32_t i; - - struct priority_worker *poll_stats; - - RTE_SET_USED(tim); - - RTE_SET_USED(arg); - - for (i = 0; i < NUM_NODES; i++) { - - poll_stats = &(ep_params->wrk_data.wrk_stats[i]); - - if (rte_lcore_is_enabled(poll_stats->lcore_id) == 0) - continue; - - switch (poll_stats->queue_state) { - case(TRAINING): - empty_poll_training(poll_stats, - ep_params->max_train_iter); - break; - - case(HGH_BUSY): - case(MED_NORMAL): - update_stats_normal(poll_stats); - break; - - case(LOW_PURGE): - break; - default: - break; - - } - - } - -} - -int -rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, - struct ep_policy *policy) -{ - uint32_t i; - /* Allocate the ep_params structure */ - ep_params = rte_zmalloc_socket(NULL, - sizeof(struct ep_params), - 0, - rte_socket_id()); - - if (!ep_params) - return -1; - - if (freq_tlb == NULL) { - freq_index[LOW] = 14; - freq_index[MED] = 9; - freq_index[HGH] = 1; - } else { - freq_index[LOW] = freq_tlb[LOW]; - freq_index[MED] = freq_tlb[MED]; - freq_index[HGH] = freq_tlb[HGH]; - } - - RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n"); - - /* Train for pre-defined period */ - ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR; - - struct stats_data *w = &ep_params->wrk_data; - - *eptr = ep_params; - - /* initialize all wrk_stats state */ - for (i = 0; i < NUM_NODES; i++) { - - if (rte_lcore_is_enabled(i) == 0) - continue; - /*init the freqs table */ - total_avail_freqs[i] = rte_power_freqs(i, - avail_freqs[i], - NUM_FREQS); - - RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n", - total_avail_freqs[i], - i); - - if (get_freq_index(LOW) > total_avail_freqs[i]) - return -1; - - if (rte_get_main_lcore() != i) { - w->wrk_stats[i].lcore_id = i; - set_policy(&w->wrk_stats[i], policy); - } - } - - return 0; -} - -void -rte_power_empty_poll_stat_free(void) -{ - - RTE_LOG(INFO, POWER, "Close the Empty Poll\n"); - - rte_free(ep_params); -} - -int -rte_power_empty_poll_stat_update(unsigned int lcore_id) -{ - struct priority_worker *poll_stats; - - if (lcore_id >= NUM_NODES) - return -1; - - poll_stats = &(ep_params->wrk_data.wrk_stats[lcore_id]); - - if (poll_stats->lcore_id == 0) - poll_stats->lcore_id = lcore_id; - - poll_stats->empty_dequeues++; - - return 0; -} - -int -rte_power_poll_stat_update(unsigned int lcore_id, uint8_t nb_pkt) -{ - - struct priority_worker *poll_stats; - - if (lcore_id >= NUM_NODES) - return -1; - - poll_stats = &(ep_params->wrk_data.wrk_stats[lcore_id]); - - if (poll_stats->lcore_id == 0) - poll_stats->lcore_id = lcore_id; - - poll_stats->num_dequeue_pkts += nb_pkt; - - return 0; -} - - -uint64_t -rte_power_empty_poll_stat_fetch(unsigned int lcore_id) -{ - struct priority_worker *poll_stats; - - if (lcore_id >= NUM_NODES) - return -1; - - poll_stats = &(ep_params->wrk_data.wrk_stats[lcore_id]); - - if (poll_stats->lcore_id == 0) - poll_stats->lcore_id = lcore_id; - - return poll_stats->empty_dequeues; -} - -uint64_t -rte_power_poll_stat_fetch(unsigned int lcore_id) -{ - struct priority_worker *poll_stats; - - if (lcore_id >= NUM_NODES) - return -1; - - poll_stats = &(ep_params->wrk_data.wrk_stats[lcore_id]); - - if (poll_stats->lcore_id == 0) - poll_stats->lcore_id = lcore_id; - - return poll_stats->num_dequeue_pkts; -} diff --git a/dpdk/lib/power/rte_power_empty_poll.h b/dpdk/lib/power/rte_power_empty_poll.h deleted file mode 100644 index b9819337e..000000000 --- a/dpdk/lib/power/rte_power_empty_poll.h +++ /dev/null @@ -1,223 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2018 Intel Corporation - */ - -#ifndef _RTE_EMPTY_POLL_H -#define _RTE_EMPTY_POLL_H - -/** - * @file - * RTE Power Management - */ -#include -#include - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define NUM_FREQS RTE_MAX_LCORE_FREQS - -#define BINS_AV 4 /* Has to be ^2 */ - -#define DROP (NUM_DIRECTIONS * NUM_DEVICES) - -#define NUM_PRIORITIES 2 - -#define NUM_NODES 256 /* Max core number*/ - -/* Processor Power State */ -enum freq_val { - LOW, - MED, - HGH, - NUM_FREQ = NUM_FREQS -}; - - -/* Queue Polling State */ -enum queue_state { - TRAINING, /* NO TRAFFIC */ - MED_NORMAL, /* MED */ - HGH_BUSY, /* HIGH */ - LOW_PURGE, /* LOW */ -}; - -/* Queue Stats */ -struct freq_threshold { - - uint64_t base_edpi; - bool trained; - uint32_t threshold_percent; - uint32_t cur_train_iter; -}; - -/* Each Worker Thread Empty Poll Stats */ -struct priority_worker { - - /* Current dequeue and throughput counts */ - /* These 2 are written to by the worker threads */ - /* So keep them on their own cache line */ - uint64_t empty_dequeues; - uint64_t num_dequeue_pkts; - - enum queue_state queue_state; - - uint64_t empty_dequeues_prev; - - /* Used for training only */ - struct freq_threshold thresh[NUM_FREQ]; - enum freq_val cur_freq; - - /* bucket arrays to calculate the averages */ - /* edpi mean empty poll counter difference per interval */ - uint64_t edpi_av[BINS_AV]; - /* empty poll counter */ - uint32_t ec; - - uint32_t lcore_id; - uint32_t iter_counter; - uint32_t threshold_ctr; - uint32_t display_ctr; - uint8_t dev_id; - -} __rte_cache_aligned; - - -struct stats_data { - - struct priority_worker wrk_stats[NUM_NODES]; - - /* flag to stop rx threads processing packets until training over */ - bool start_rx; - -}; - -/* Empty Poll Parameters */ -struct ep_params { - - /* Timer related stuff */ - uint64_t interval_ticks; - uint32_t max_train_iter; - - struct rte_timer timer0; - struct stats_data wrk_data; -}; - - -/* Sample App Init information */ -struct ep_policy { - - uint64_t med_base_edpi; - uint64_t hgh_base_edpi; - - enum queue_state state; -}; - - - -/** - * Initialize the power management system. - * - * @param eptr - * the structure of empty poll configuration - * @param freq_tlb - * the power state/frequency mapping table - * @param policy - * the initialization policy from sample app - * - * @return - * - 0 on success. - * - Negative on error. - */ -__rte_experimental -int -rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, - struct ep_policy *policy); - -/** - * Free the resource hold by power management system. - */ -__rte_experimental -void -rte_power_empty_poll_stat_free(void); - -/** - * Update specific core empty poll counter - * It's not thread safe. - * - * @param lcore_id - * lcore id - * - * @return - * - 0 on success. - * - Negative on error. - */ -__rte_experimental -int -rte_power_empty_poll_stat_update(unsigned int lcore_id); - -/** - * Update specific core valid poll counter, not thread safe. - * - * @param lcore_id - * lcore id. - * @param nb_pkt - * The packet number of one valid poll. - * - * @return - * - 0 on success. - * - Negative on error. - */ -__rte_experimental -int -rte_power_poll_stat_update(unsigned int lcore_id, uint8_t nb_pkt); - -/** - * Fetch specific core empty poll counter. - * - * @param lcore_id - * lcore id - * - * @return - * Current lcore empty poll counter value. - */ -__rte_experimental -uint64_t -rte_power_empty_poll_stat_fetch(unsigned int lcore_id); - -/** - * Fetch specific core valid poll counter. - * - * @param lcore_id - * lcore id - * - * @return - * Current lcore valid poll counter value. - */ -__rte_experimental -uint64_t -rte_power_poll_stat_fetch(unsigned int lcore_id); - -/** - * Empty poll state change detection function - * - * @param tim - * The timer structure - * @param arg - * The customized parameter - */ -__rte_experimental -void -rte_empty_poll_detection(struct rte_timer *tim, void *arg); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dpdk/lib/power/rte_power_intel_uncore.c b/dpdk/lib/power/rte_power_intel_uncore.c deleted file mode 100644 index 7193b8651..000000000 --- a/dpdk/lib/power/rte_power_intel_uncore.c +++ /dev/null @@ -1,454 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#include -#include -#include - -#include - -#include "rte_power_intel_uncore.h" -#include "power_common.h" - -#define MAX_UNCORE_FREQS 64 -#define MAX_NUMA_DIE 8 -#define BUS_FREQ 100000 -#define FILTER_LENGTH 18 -#define PACKAGE_FILTER "package_%02u_die_*" -#define DIE_FILTER "package_%02u_die_%02u" -#define INTEL_UNCORE_FREQUENCY_DIR "/sys/devices/system/cpu/intel_uncore_frequency" -#define POWER_GOVERNOR_PERF "performance" -#define POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ \ - "/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/max_freq_khz" -#define POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ \ - "/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/min_freq_khz" -#define POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ \ - "/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/initial_max_freq_khz" -#define POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ \ - "/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/initial_min_freq_khz" - - -struct uncore_power_info { - unsigned int die; /* Core die id */ - unsigned int pkg; /* Package id */ - uint32_t freqs[MAX_UNCORE_FREQS]; /* Frequency array */ - uint32_t nb_freqs; /* Number of available freqs */ - FILE *f_cur_min; /* FD of scaling_min */ - FILE *f_cur_max; /* FD of scaling_max */ - uint32_t curr_idx; /* Freq index in freqs array */ - uint32_t org_min_freq; /* Original min freq of uncore */ - uint32_t org_max_freq; /* Original max freq of uncore */ - uint32_t init_max_freq; /* System max uncore freq */ - uint32_t init_min_freq; /* System min uncore freq */ -} __rte_cache_aligned; - -static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES][MAX_NUMA_DIE]; - -static int -set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) -{ - uint32_t target_uncore_freq, curr_max_freq; - int ret; - - if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { - RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which " - "should be less than %u\n", idx, ui->nb_freqs); - return -1; - } - - target_uncore_freq = ui->freqs[idx]; - - /* check current max freq, so that the value to be flushed first - * can be accurately recorded - */ - open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, - ui->pkg, ui->die); - if (ui->f_cur_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", - POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); - return -1; - } - ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq); - if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", - POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); - fclose(ui->f_cur_max); - return -1; - } - - /* check this value first before fprintf value to f_cur_max, so value isn't overwritten */ - if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); - return -1; - } - - if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); - return -1; - } - - POWER_DEBUG_TRACE("Uncore frequency '%u' to be set for pkg %02u die %02u\n", - target_uncore_freq, ui->pkg, ui->die); - - /* write the minimum value first if the target freq is less than current max */ - if (target_uncore_freq <= curr_max_freq) { - fflush(ui->f_cur_min); - fflush(ui->f_cur_max); - } else { - fflush(ui->f_cur_max); - fflush(ui->f_cur_min); - } - ui->curr_idx = idx; - - return 0; -} - -/* - * Fopen the sys file for the future setting of the uncore die frequency. - */ -static int -power_init_for_setting_uncore_freq(struct uncore_power_info *ui) -{ - FILE *f_base_min = NULL, *f_base_max = NULL, *f_min = NULL, *f_max = NULL; - uint32_t base_min_freq = 0, base_max_freq = 0, min_freq = 0, max_freq = 0; - int ret; - - /* open and read all uncore sys files */ - /* Base max */ - open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ, - ui->pkg, ui->die); - if (f_base_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", - POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); - goto err; - } - ret = read_core_sysfs_u32(f_base_max, &base_max_freq); - if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", - POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); - goto err; - } - - /* Base min */ - open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ, - ui->pkg, ui->die); - if (f_base_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", - POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); - goto err; - } - if (f_base_min != NULL) { - ret = read_core_sysfs_u32(f_base_min, &base_min_freq); - if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", - POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); - goto err; - } - } - - /* Curr min */ - open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ, - ui->pkg, ui->die); - if (f_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", - POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); - goto err; - } - if (f_min != NULL) { - ret = read_core_sysfs_u32(f_min, &min_freq); - if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", - POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); - goto err; - } - } - - /* Curr max */ - open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, - ui->pkg, ui->die); - if (f_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", - POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); - goto err; - } - if (f_max != NULL) { - ret = read_core_sysfs_u32(f_max, &max_freq); - if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", - POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); - goto err; - } - } - - /* assign file handles */ - ui->f_cur_min = f_min; - ui->f_cur_max = f_max; - /* save current min + max freq's so that they can be restored on exit */ - ui->org_min_freq = min_freq; - ui->org_max_freq = max_freq; - ui->init_max_freq = base_max_freq; - ui->init_min_freq = base_min_freq; - - fclose(f_base_min); - fclose(f_base_max); - /* f_min and f_max are stored, no need to close */ - - return 0; - -err: - if (f_base_min != NULL) - fclose(f_base_min); - if (f_base_max != NULL) - fclose(f_base_max); - if (f_min != NULL) - fclose(f_min); - if (f_max != NULL) - fclose(f_max); - return -1; -} - -/* - * Get the available uncore frequencies of the specific die by reading the - * sys file. - */ -static int -power_get_available_uncore_freqs(struct uncore_power_info *ui) -{ - int ret = -1; - uint32_t i, num_uncore_freqs = 0; - - num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1; - if (num_uncore_freqs >= MAX_UNCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n", - num_uncore_freqs); - goto out; - } - - /* Generate the uncore freq bucket array. */ - for (i = 0; i < num_uncore_freqs; i++) - ui->freqs[i] = ui->init_max_freq - (i) * BUS_FREQ; - - ui->nb_freqs = num_uncore_freqs; - - ret = 0; - - POWER_DEBUG_TRACE("%d frequency(s) of pkg %02u die %02u are available\n", - num_uncore_freqs, ui->pkg, ui->die); - -out: - return ret; -} - -static int -check_pkg_die_values(unsigned int pkg, unsigned int die) -{ - unsigned int max_pkgs, max_dies; - max_pkgs = rte_power_uncore_get_num_pkgs(); - if (max_pkgs == 0) - return -1; - if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n", - pkg, max_pkgs); - return -1; - } - - max_dies = rte_power_uncore_get_num_dies(pkg); - if (max_dies == 0) - return -1; - if (die >= max_dies) { - RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n", - die, max_dies); - return -1; - } - - return 0; -} - -int -rte_power_uncore_init(unsigned int pkg, unsigned int die) -{ - struct uncore_power_info *ui; - - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - ui = &uncore_info[pkg][die]; - ui->die = die; - ui->pkg = pkg; - - /* Init for setting uncore die frequency */ - if (power_init_for_setting_uncore_freq(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for " - "pkg %02u die %02u\n", pkg, die); - return -1; - } - - /* Get the available frequencies */ - if (power_get_available_uncore_freqs(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of " - "pkg %02u die %02u\n", pkg, die); - return -1; - } - - return 0; -} - -int -rte_power_uncore_exit(unsigned int pkg, unsigned int die) -{ - struct uncore_power_info *ui; - - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - ui = &uncore_info[pkg][die]; - - if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); - return -1; - } - - if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); - return -1; - } - - fflush(ui->f_cur_min); - fflush(ui->f_cur_max); - - /* Close FD of setting freq */ - fclose(ui->f_cur_min); - fclose(ui->f_cur_max); - ui->f_cur_min = NULL; - ui->f_cur_max = NULL; - - return 0; -} - -uint32_t -rte_power_get_uncore_freq(unsigned int pkg, unsigned int die) -{ - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - return uncore_info[pkg][die].curr_idx; -} - -int -rte_power_set_uncore_freq(unsigned int pkg, unsigned int die, uint32_t index) -{ - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - return set_uncore_freq_internal(&(uncore_info[pkg][die]), index); -} - -int -rte_power_uncore_freq_max(unsigned int pkg, unsigned int die) -{ - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - return set_uncore_freq_internal(&(uncore_info[pkg][die]), 0); -} - - -int -rte_power_uncore_freq_min(unsigned int pkg, unsigned int die) -{ - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - struct uncore_power_info *ui = &uncore_info[pkg][die]; - - return set_uncore_freq_internal(&(uncore_info[pkg][die]), ui->nb_freqs - 1); -} - -int -rte_power_uncore_get_num_freqs(unsigned int pkg, unsigned int die) -{ - int ret = check_pkg_die_values(pkg, die); - if (ret < 0) - return -1; - - return uncore_info[pkg][die].nb_freqs; -} - -unsigned int -rte_power_uncore_get_num_pkgs(void) -{ - DIR *d; - struct dirent *dir; - unsigned int count = 0; - char filter[FILTER_LENGTH]; - - d = opendir(INTEL_UNCORE_FREQUENCY_DIR); - if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); - return 0; - } - - /* search by incrementing file name for max pkg file value */ - while ((dir = readdir(d)) != NULL) { - snprintf(filter, FILTER_LENGTH, PACKAGE_FILTER, count); - /* make sure filter string is in file name (don't include hidden files) */ - if (fnmatch(filter, dir->d_name, 0) == 0) - count++; - } - - closedir(d); - - return count; -} - -unsigned int -rte_power_uncore_get_num_dies(unsigned int pkg) -{ - DIR *d; - struct dirent *dir; - unsigned int count = 0, max_pkgs; - char filter[FILTER_LENGTH]; - - max_pkgs = rte_power_uncore_get_num_pkgs(); - if (max_pkgs == 0) - return 0; - if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Invalid package number\n"); - return 0; - } - - d = opendir(INTEL_UNCORE_FREQUENCY_DIR); - if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); - return 0; - } - - /* search by incrementing file name for max die file value */ - while ((dir = readdir(d)) != NULL) { - snprintf(filter, FILTER_LENGTH, DIE_FILTER, pkg, count); - /* make sure filter string is in file name (don't include hidden files) */ - if (fnmatch(filter, dir->d_name, 0) == 0) - count++; - } - - closedir(d); - - return count; -} diff --git a/dpdk/lib/power/rte_power_intel_uncore.h b/dpdk/lib/power/rte_power_intel_uncore.h deleted file mode 100644 index 0bd9f193a..000000000 --- a/dpdk/lib/power/rte_power_intel_uncore.h +++ /dev/null @@ -1,211 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2022 Intel Corporation - */ - -#ifndef RTE_POWER_INTEL_UNCORE_H -#define RTE_POWER_INTEL_UNCORE_H - -/** - * @file - * RTE Intel Uncore Frequency Management - */ - -#include -#include "rte_power.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Initialize uncore frequency management for specific die on a package. - * It will get the available frequencies and prepare to set new die frequencies. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * - 0 on success. - * - Negative on error. - */ -__rte_experimental -int -rte_power_uncore_init(unsigned int pkg, unsigned int die); - -/** - * Exit uncore frequency management on a specific die on a package. - * It will restore uncore min and* max values to previous values - * before initialization of API. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * - 0 on success. - * - Negative on error. - */ -__rte_experimental -int -rte_power_uncore_exit(unsigned int pkg, unsigned int die); - -/** - * Return the current index of available frequencies of a specific die on a package. - * It should be protected outside of this function for threadsafe. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * The current index of available frequencies. - * If error, it will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)'. - */ -__rte_experimental -uint32_t -rte_power_get_uncore_freq(unsigned int pkg, unsigned int die); - -/** - * Set minimum and maximum uncore frequency for specified die on a package - * to specified index value. - * It should be protected outside of this function for threadsafe. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * @param index - * The index of available frequencies. - * - * @return - * - 1 on success with frequency changed. - * - 0 on success without frequency changed. - * - Negative on error. - */ -__rte_experimental -int -rte_power_set_uncore_freq(unsigned int pkg, unsigned int die, uint32_t index); - -/** - * Set minimum and maximum uncore frequency for specified die on a package - * to maximum value according to the available frequencies. - * It should be protected outside of this function for threadsafe. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * - 1 on success with frequency changed. - * - 0 on success without frequency changed. - * - Negative on error. - */ -__rte_experimental -int -rte_power_uncore_freq_max(unsigned int pkg, unsigned int die); - -/** - * Set minimum and maximum uncore frequency for specified die on a package - * to minimum value according to the available frequencies. - * It should be protected outside of this function for threadsafe. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * - 1 on success with frequency changed. - * - 0 on success without frequency changed. - * - Negative on error. - */ -__rte_experimental -int -rte_power_uncore_freq_min(unsigned int pkg, unsigned int die); - -/** - * Return the list length of available frequencies in the index array. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * @param die - * Die number. - * Each package can have several dies connected together via the uncore mesh. - * - * @return - * - The number of available index's in frequency array. - * - Negative on error. - */ -__rte_experimental -int -rte_power_uncore_get_num_freqs(unsigned int pkg, unsigned int die); - -/** - * Return the number of packages (CPUs) on a system - * by parsing the uncore sysfs directory. - * - * This function should NOT be called in the fast path. - * - * @return - * - Zero on error. - * - Number of package on system on success. - */ -__rte_experimental -unsigned int -rte_power_uncore_get_num_pkgs(void); - -/** - * Return the number of dies for pakckages (CPUs) specified - * from parsing the uncore sysfs directory. - * - * This function should NOT be called in the fast path. - * - * @param pkg - * Package number. - * Each physical CPU in a system is referred to as a package. - * - * @return - * - Zero on error. - * - Number of dies for package on sucecss. - */ -__rte_experimental -unsigned int -rte_power_uncore_get_num_dies(unsigned int pkg); - -#ifdef __cplusplus -} -#endif - -#endif /* RTE_POWER_INTEL_UNCORE_H */