1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
8 #include <rte_bus_pci.h>
9 #include <rte_ethdev.h>
11 #include <rte_malloc.h>
14 #include <rte_sched.h>
15 #include <rte_ethdev_driver.h>
16 #include <rte_spinlock.h>
19 #include <rte_rawdev.h>
20 #include <rte_rawdev_pmd.h>
21 #include <rte_bus_ifpga.h>
22 #include <ifpga_logs.h>
24 #include "ipn3ke_rawdev_api.h"
25 #include "ipn3ke_flow.h"
26 #include "ipn3ke_logs.h"
27 #include "ipn3ke_ethdev.h"
29 static int ipn3ke_rpst_scan_num;
30 static pthread_t ipn3ke_rpst_scan_thread;
32 /** Double linked list of representor port. */
33 TAILQ_HEAD(ipn3ke_rpst_list, ipn3ke_rpst);
35 static struct ipn3ke_rpst_list ipn3ke_rpst_list =
36 TAILQ_HEAD_INITIALIZER(ipn3ke_rpst_list);
38 static rte_spinlock_t ipn3ke_link_notify_list_lk = RTE_SPINLOCK_INITIALIZER;
41 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst);
44 ipn3ke_rpst_dev_infos_get(struct rte_eth_dev *ethdev,
45 struct rte_eth_dev_info *dev_info)
47 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
48 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
50 dev_info->speed_capa =
51 (hw->retimer.mac_type ==
52 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) ?
54 ((hw->retimer.mac_type ==
55 IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) ?
57 ETH_LINK_SPEED_AUTONEG);
59 dev_info->max_rx_queues = 1;
60 dev_info->max_tx_queues = 1;
61 dev_info->min_rx_bufsize = IPN3KE_AFU_BUF_SIZE_MIN;
62 dev_info->max_rx_pktlen = IPN3KE_AFU_FRAME_SIZE_MAX;
63 dev_info->max_mac_addrs = hw->port_num;
64 dev_info->max_vfs = 0;
65 dev_info->default_txconf = (struct rte_eth_txconf) {
68 dev_info->rx_queue_offload_capa = 0;
69 dev_info->rx_offload_capa =
70 DEV_RX_OFFLOAD_VLAN_STRIP |
71 DEV_RX_OFFLOAD_QINQ_STRIP |
72 DEV_RX_OFFLOAD_IPV4_CKSUM |
73 DEV_RX_OFFLOAD_UDP_CKSUM |
74 DEV_RX_OFFLOAD_TCP_CKSUM |
75 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
76 DEV_RX_OFFLOAD_VLAN_EXTEND |
77 DEV_RX_OFFLOAD_VLAN_FILTER |
78 DEV_RX_OFFLOAD_JUMBO_FRAME;
80 dev_info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE;
81 dev_info->tx_offload_capa =
82 DEV_TX_OFFLOAD_VLAN_INSERT |
83 DEV_TX_OFFLOAD_QINQ_INSERT |
84 DEV_TX_OFFLOAD_IPV4_CKSUM |
85 DEV_TX_OFFLOAD_UDP_CKSUM |
86 DEV_TX_OFFLOAD_TCP_CKSUM |
87 DEV_TX_OFFLOAD_SCTP_CKSUM |
88 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
89 DEV_TX_OFFLOAD_TCP_TSO |
90 DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
91 DEV_TX_OFFLOAD_GRE_TNL_TSO |
92 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
93 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
94 DEV_TX_OFFLOAD_MULTI_SEGS |
95 dev_info->tx_queue_offload_capa;
98 RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
99 RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
101 dev_info->switch_info.name = ethdev->device->name;
102 dev_info->switch_info.domain_id = rpst->switch_domain_id;
103 dev_info->switch_info.port_id = rpst->port_id;
109 ipn3ke_rpst_dev_configure(__rte_unused struct rte_eth_dev *dev)
115 ipn3ke_rpst_dev_start(struct rte_eth_dev *dev)
117 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
118 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
119 struct rte_rawdev *rawdev;
122 char attr_name[IPN3KE_RAWDEV_ATTR_LEN_MAX];
126 memset(attr_name, 0, sizeof(attr_name));
127 snprintf(attr_name, IPN3KE_RAWDEV_ATTR_LEN_MAX, "%s",
129 rawdev->dev_ops->attr_get(rawdev, attr_name, &base_mac);
130 rte_ether_addr_copy((struct rte_ether_addr *)&base_mac,
133 rte_ether_addr_copy(&rpst->mac_addr, &dev->data->mac_addrs[0]);
134 dev->data->mac_addrs->addr_bytes[RTE_ETHER_ADDR_LEN - 1] =
135 (uint8_t)rpst->port_id + 1;
137 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
138 /* Set mac address */
139 rte_memcpy(((char *)(&val)),
140 (char *)&dev->data->mac_addrs->addr_bytes[0],
142 (*hw->f_mac_write)(hw,
144 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
147 rte_memcpy(((char *)(&val)),
148 (char *)&dev->data->mac_addrs->addr_bytes[4],
150 (*hw->f_mac_write)(hw,
152 IPN3KE_MAC_PRIMARY_MAC_ADDR1,
156 /* Enable the TX path */
157 ipn3ke_xmac_tx_enable(hw, rpst->port_id, 0);
159 /* Disables source address override */
160 ipn3ke_xmac_smac_ovd_dis(hw, rpst->port_id, 0);
162 /* Enable the RX path */
163 ipn3ke_xmac_rx_enable(hw, rpst->port_id, 0);
165 /* Clear line side TX statistics counters */
166 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 0);
168 /* Clear line side RX statistics counters */
169 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 0);
171 /* Clear NIC side TX statistics counters */
172 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 1);
174 /* Clear NIC side RX statistics counters */
175 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 1);
176 } else if (hw->retimer.mac_type ==
177 IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
178 /* Clear line side TX statistics counters */
179 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 0);
181 /* Clear line side RX statistics counters */
182 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 0);
184 /* Clear NIC side TX statistics counters */
185 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 1);
187 /* Clear NIC side RX statistics counters */
188 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 1);
191 ipn3ke_rpst_link_update(dev, 0);
197 ipn3ke_rpst_dev_stop(struct rte_eth_dev *dev)
199 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
200 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
202 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
203 /* Disable the TX path */
204 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
206 /* Disable the RX path */
207 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
212 ipn3ke_rpst_dev_close(struct rte_eth_dev *dev)
214 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
215 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
217 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
218 /* Disable the TX path */
219 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
221 /* Disable the RX path */
222 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
227 * Reset PF device only to re-initialize resources in PMD layer
230 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
232 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
233 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
235 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
236 /* Disable the TX path */
237 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
239 /* Disable the RX path */
240 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
247 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
248 __rte_unused uint16_t rx_queue_id)
254 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
255 __rte_unused uint16_t rx_queue_id)
261 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
262 __rte_unused uint16_t tx_queue_id)
268 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
269 __rte_unused uint16_t tx_queue_id)
275 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
276 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
277 __rte_unused unsigned int socket_id,
278 __rte_unused const struct rte_eth_rxconf *rx_conf,
279 __rte_unused struct rte_mempool *mp)
285 ipn3ke_rpst_rx_queue_release(__rte_unused void *rxq)
290 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
291 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
292 __rte_unused unsigned int socket_id,
293 __rte_unused const struct rte_eth_txconf *tx_conf)
299 ipn3ke_rpst_tx_queue_release(__rte_unused void *txq)
303 /* Statistics collected by each port, VSI, VEB, and S-channel */
304 struct ipn3ke_rpst_eth_stats {
305 uint64_t tx_bytes; /* gotc */
306 uint64_t tx_multicast; /* mptc */
307 uint64_t tx_broadcast; /* bptc */
308 uint64_t tx_unicast; /* uptc */
309 uint64_t tx_discards; /* tdpc */
310 uint64_t tx_errors; /* tepc */
311 uint64_t rx_bytes; /* gorc */
312 uint64_t rx_multicast; /* mprc */
313 uint64_t rx_broadcast; /* bprc */
314 uint64_t rx_unicast; /* uprc */
315 uint64_t rx_discards; /* rdpc */
316 uint64_t rx_unknown_protocol; /* rupp */
319 /* store statistics names and its offset in stats structure */
320 struct ipn3ke_rpst_xstats_name_offset {
321 char name[RTE_ETH_XSTATS_NAME_SIZE];
325 static const struct ipn3ke_rpst_xstats_name_offset
326 ipn3ke_rpst_stats_strings[] = {
327 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
329 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
331 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
333 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
335 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
337 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
339 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
341 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
343 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
344 rx_unknown_protocol)},
347 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
348 sizeof(ipn3ke_rpst_stats_strings[0]))
350 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
352 /* Statistics collected by the MAC */
353 struct ipn3ke_rpst_hw_port_stats {
354 /* eth stats collected by the port */
355 struct ipn3ke_rpst_eth_stats eth;
357 /* additional port specific stats */
358 uint64_t tx_dropped_link_down;
360 uint64_t illegal_bytes;
361 uint64_t error_bytes;
362 uint64_t mac_local_faults;
363 uint64_t mac_remote_faults;
364 uint64_t rx_length_errors;
365 uint64_t link_xon_rx;
366 uint64_t link_xoff_rx;
367 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
368 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
369 uint64_t link_xon_tx;
370 uint64_t link_xoff_tx;
371 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
372 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
373 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
375 uint64_t rx_size_65_127;
376 uint64_t rx_size_128_255;
377 uint64_t rx_size_256_511;
378 uint64_t rx_size_512_1023;
379 uint64_t rx_size_1024_1518;
380 uint64_t rx_size_big;
381 uint64_t rx_undersize;
382 uint64_t rx_fragments;
383 uint64_t rx_oversize;
386 uint64_t tx_size_65_127;
387 uint64_t tx_size_128_255;
388 uint64_t tx_size_256_511;
389 uint64_t tx_size_512_1023;
390 uint64_t tx_size_1024_1518;
391 uint64_t tx_size_1519_to_max;
392 uint64_t mac_short_packet_dropped;
393 uint64_t checksum_error;
394 /* flow director stats */
395 uint64_t fd_atr_match;
396 uint64_t fd_sb_match;
397 uint64_t fd_atr_tunnel_match;
398 uint32_t fd_atr_status;
399 uint32_t fd_sb_status;
401 uint32_t tx_lpi_status;
402 uint32_t rx_lpi_status;
403 uint64_t tx_lpi_count;
404 uint64_t rx_lpi_count;
407 static const struct ipn3ke_rpst_xstats_name_offset
408 ipn3ke_rpst_hw_port_strings[] = {
409 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
410 tx_dropped_link_down)},
411 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
413 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
415 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
417 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
419 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
421 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
423 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
425 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
427 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
429 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
431 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
433 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
435 {"rx_size_128_to_255_packets",
436 offsetof(struct ipn3ke_rpst_hw_port_stats,
438 {"rx_size_256_to_511_packets",
439 offsetof(struct ipn3ke_rpst_hw_port_stats,
441 {"rx_size_512_to_1023_packets",
442 offsetof(struct ipn3ke_rpst_hw_port_stats,
444 {"rx_size_1024_to_1518_packets",
445 offsetof(struct ipn3ke_rpst_hw_port_stats,
447 {"rx_size_1519_to_max_packets",
448 offsetof(struct ipn3ke_rpst_hw_port_stats,
450 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
452 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
454 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
455 mac_short_packet_dropped)},
456 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
458 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
460 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
462 {"tx_size_65_to_127_packets",
463 offsetof(struct ipn3ke_rpst_hw_port_stats,
465 {"tx_size_128_to_255_packets",
466 offsetof(struct ipn3ke_rpst_hw_port_stats,
468 {"tx_size_256_to_511_packets",
469 offsetof(struct ipn3ke_rpst_hw_port_stats,
471 {"tx_size_512_to_1023_packets",
472 offsetof(struct ipn3ke_rpst_hw_port_stats,
474 {"tx_size_1024_to_1518_packets",
475 offsetof(struct ipn3ke_rpst_hw_port_stats,
477 {"tx_size_1519_to_max_packets",
478 offsetof(struct ipn3ke_rpst_hw_port_stats,
479 tx_size_1519_to_max)},
480 {"rx_flow_director_atr_match_packets",
481 offsetof(struct ipn3ke_rpst_hw_port_stats,
483 {"rx_flow_director_sb_match_packets",
484 offsetof(struct ipn3ke_rpst_hw_port_stats,
486 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
488 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
490 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
492 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
496 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
497 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
499 static const struct ipn3ke_rpst_xstats_name_offset
500 ipn3ke_rpst_rxq_prio_strings[] = {
501 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
503 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
507 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
508 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
510 static const struct ipn3ke_rpst_xstats_name_offset
511 ipn3ke_rpst_txq_prio_strings[] = {
512 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
514 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
516 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
517 priority_xon_2_xoff)},
520 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
521 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
524 ipn3ke_rpst_xstats_calc_num(void)
526 return IPN3KE_RPST_ETH_XSTATS_CNT
527 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
528 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
529 * IPN3KE_RPST_PRIO_XSTATS_CNT)
530 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
531 * IPN3KE_RPST_PRIO_XSTATS_CNT);
535 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
538 uint32_t tmp = 0x00000001;
539 /* Bit[0]: Software can set this bit to the value of 1
540 * to reset all of the TX statistics registers at the same time.
541 * This bit is selfclearing.
543 (*hw->f_mac_write)(hw,
545 IPN3KE_25G_TX_STATISTICS_CONFIG,
549 while (tmp & 0x00000001) {
551 (*hw->f_mac_read)(hw,
553 IPN3KE_25G_TX_STATISTICS_CONFIG,
556 if (tmp & 0x00000001)
564 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
567 uint32_t tmp = 0x00000001;
568 /* Bit[0]: Software can set this bit to the value of 1
569 * to reset all of the RX statistics registers at the same time.
570 * This bit is selfclearing.
572 (*hw->f_mac_write)(hw,
574 IPN3KE_25G_RX_STATISTICS_CONFIG,
578 while (tmp & 0x00000001) {
580 (*hw->f_mac_read)(hw,
582 IPN3KE_25G_RX_STATISTICS_CONFIG,
585 if (tmp & 0x00000001)
593 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
598 /*Bit [0]: Set this register to 1 to clear all TX statistics
600 *The IP core clears this bit when all counters are cleared.
601 *Bits [31:1]: Reserved.
604 (*hw->f_mac_read)(hw,
606 IPN3KE_10G_TX_STATS_CLR,
610 (*hw->f_mac_write)(hw,
612 IPN3KE_10G_TX_STATS_CLR,
618 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
623 /*Bit [0]: Set this register to 1 to clear all RX statistics
625 *The IP core clears this bit when all counters are cleared.
626 *Bits [31:1]: Reserved
629 (*hw->f_mac_read)(hw,
631 IPN3KE_10G_RX_STATS_CLR,
635 (*hw->f_mac_write)(hw,
637 IPN3KE_10G_RX_STATS_CLR,
643 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
644 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
646 uint32_t statistics_lo = 0x00000000;
647 uint32_t statistics_hi = 0x00000000;
648 uint64_t statistics = 0x0000000000000000;
650 (*hw->f_mac_read)(hw,
656 (*hw->f_mac_read)(hw,
662 statistics += statistics_hi;
663 statistics = statistics << IPN3KE_REGISTER_WIDTH;
664 statistics += statistics_lo;
670 ipn3ke_rpst_read_25g_lineside_stats_registers
671 (struct ipn3ke_hw *hw,
673 struct ipn3ke_rpst_hw_port_stats *hw_stats)
678 memset(hw_stats, 0, sizeof(*hw_stats));
680 /*check Tx statistics is real time.
681 *if statistics has been paused, make it real time.
684 (*hw->f_mac_read)(hw,
686 IPN3KE_25G_TX_STATISTICS_CONFIG,
690 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
692 (*hw->f_mac_write)(hw,
694 IPN3KE_25G_TX_STATISTICS_CONFIG,
700 (*hw->f_mac_read)(hw,
702 IPN3KE_25G_TX_STATISTICS_STATUS,
705 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
707 (*hw->f_mac_read)(hw,
709 IPN3KE_25G_TX_STATISTICS_CONFIG,
713 (*hw->f_mac_write)(hw,
715 IPN3KE_25G_TX_STATISTICS_CONFIG,
720 /*check Rx statistics is real time.
721 *if statistics has been paused, make it real time.
724 (*hw->f_mac_read)(hw,
726 IPN3KE_25G_RX_STATISTICS_CONFIG,
729 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
731 (*hw->f_mac_write)(hw,
733 IPN3KE_25G_RX_STATISTICS_CONFIG,
739 (*hw->f_mac_read)(hw,
741 IPN3KE_25G_RX_STATISTICS_STATUS,
745 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
747 (*hw->f_mac_read)(hw,
749 IPN3KE_25G_RX_STATISTICS_CONFIG,
753 (*hw->f_mac_write)(hw,
755 IPN3KE_25G_RX_STATISTICS_CONFIG,
760 /* pause Tx counter to read the statistics */
762 (*hw->f_mac_read)(hw,
764 IPN3KE_25G_TX_STATISTICS_CONFIG,
768 (*hw->f_mac_write)(hw,
770 IPN3KE_25G_TX_STATISTICS_CONFIG,
774 /* pause Rx counter to read the statistics */
776 (*hw->f_mac_read)(hw,
778 IPN3KE_25G_RX_STATISTICS_CONFIG,
782 (*hw->f_mac_write)(hw,
784 IPN3KE_25G_RX_STATISTICS_CONFIG,
788 /*Number of transmitted frames less than 64 bytes
789 *and reporting a CRC error
791 statistics = ipn3ke_rpst_read_64bits_statistics_register(
792 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
793 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
795 hw_stats->eth.tx_errors += statistics;
796 hw_stats->crc_errors += statistics;
798 /*Number of transmitted oversized frames reporting a CRC error*/
799 statistics = ipn3ke_rpst_read_64bits_statistics_register(
800 IPN3KE_25G_CNTR_TX_JABBERS_LO,
801 IPN3KE_25G_CNTR_TX_JABBERS_HI,
803 hw_stats->eth.tx_errors += statistics;
804 hw_stats->crc_errors += statistics;
806 /* Number of transmitted packets with FCS errors */
807 statistics = ipn3ke_rpst_read_64bits_statistics_register(
808 IPN3KE_25G_CNTR_TX_FCS_LO,
809 IPN3KE_25G_CNTR_TX_FCS_HI,
811 hw_stats->eth.tx_errors += statistics;
812 hw_stats->checksum_error += statistics;
814 /*Number of transmitted frames with a frame of length at
815 *least 64 reporting a CRC error
817 statistics = ipn3ke_rpst_read_64bits_statistics_register(
818 IPN3KE_25G_CNTR_TX_CRCERR_LO,
819 IPN3KE_25G_CNTR_TX_CRCERR_HI,
821 hw_stats->eth.tx_errors += statistics;
822 hw_stats->crc_errors += statistics;
824 /*Number of errored multicast frames transmitted,
825 *excluding control frames
827 statistics = ipn3ke_rpst_read_64bits_statistics_register(
828 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
829 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
831 hw_stats->eth.tx_errors += statistics;
833 /*Number of errored broadcast frames transmitted,
834 *excluding control frames
836 statistics = ipn3ke_rpst_read_64bits_statistics_register(
837 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
838 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
840 hw_stats->eth.tx_errors += statistics;
842 /*Number of errored unicast frames transmitted,
843 *excluding control frames
845 statistics = ipn3ke_rpst_read_64bits_statistics_register(
846 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
847 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
849 hw_stats->eth.tx_errors += statistics;
851 /* Number of errored multicast control frames transmitted */
852 statistics = ipn3ke_rpst_read_64bits_statistics_register(
853 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
854 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
856 hw_stats->eth.tx_errors += statistics;
858 /* Number of errored broadcast control frames transmitted */
859 statistics = ipn3ke_rpst_read_64bits_statistics_register(
860 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
861 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
863 hw_stats->eth.tx_errors += statistics;
865 /* Number of errored unicast control frames transmitted */
866 statistics = ipn3ke_rpst_read_64bits_statistics_register(
867 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
868 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
870 hw_stats->eth.tx_errors += statistics;
872 /* Number of errored pause frames transmitted */
873 statistics = ipn3ke_rpst_read_64bits_statistics_register(
874 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
875 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
877 hw_stats->eth.tx_errors += statistics;
879 /*Number of 64-byte transmitted frames,
880 *including the CRC field but excluding the preamble
883 statistics = ipn3ke_rpst_read_64bits_statistics_register(
884 IPN3KE_25G_CNTR_TX_64B_LO,
885 IPN3KE_25G_CNTR_TX_64B_HI,
887 hw_stats->tx_size_64 += statistics;
889 /* Number of transmitted frames between 65 and 127 bytes */
890 statistics = ipn3ke_rpst_read_64bits_statistics_register(
891 IPN3KE_25G_CNTR_TX_65_127B_LO,
892 IPN3KE_25G_CNTR_TX_65_127B_HI,
894 hw_stats->tx_size_65_127 += statistics;
896 /* Number of transmitted frames between 128 and 255 bytes */
897 statistics = ipn3ke_rpst_read_64bits_statistics_register(
898 IPN3KE_25G_CNTR_TX_128_255B_LO,
899 IPN3KE_25G_CNTR_TX_128_255B_HI,
901 hw_stats->tx_size_128_255 += statistics;
903 /* Number of transmitted frames between 256 and 511 bytes */
904 statistics = ipn3ke_rpst_read_64bits_statistics_register(
905 IPN3KE_25G_CNTR_TX_256_511B_LO,
906 IPN3KE_25G_CNTR_TX_256_511B_HI,
908 hw_stats->tx_size_256_511 += statistics;
910 /* Number of transmitted frames between 512 and 1023 bytes */
911 statistics = ipn3ke_rpst_read_64bits_statistics_register(
912 IPN3KE_25G_CNTR_TX_512_1023B_LO,
913 IPN3KE_25G_CNTR_TX_512_1023B_HI,
915 hw_stats->tx_size_512_1023 += statistics;
917 /* Number of transmitted frames between 1024 and 1518 bytes */
918 statistics = ipn3ke_rpst_read_64bits_statistics_register(
919 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
920 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
922 hw_stats->tx_size_1024_1518 += statistics;
924 /*Number of transmitted frames of size between 1519 bytes
925 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
928 statistics = ipn3ke_rpst_read_64bits_statistics_register(
929 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
930 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
932 hw_stats->tx_size_1519_to_max += statistics;
934 /*Number of oversized frames (frames with more bytes than the
935 *number specified in the MAX_TX_SIZE_CONFIG register)
938 statistics = ipn3ke_rpst_read_64bits_statistics_register(
939 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
940 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
943 /*Number of valid multicast frames transmitted,
944 *excluding control frames
946 statistics = ipn3ke_rpst_read_64bits_statistics_register(
947 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
948 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
950 hw_stats->eth.tx_multicast += statistics;
952 /*Number of valid broadcast frames transmitted,
953 *excluding control frames
955 statistics = ipn3ke_rpst_read_64bits_statistics_register(
956 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
957 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
959 hw_stats->eth.tx_broadcast += statistics;
961 /*Number of valid unicast frames transmitted,
962 *excluding control frames
964 statistics = ipn3ke_rpst_read_64bits_statistics_register(
965 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
966 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
968 hw_stats->eth.tx_unicast += statistics;
970 /*Number of valid multicast frames transmitted,
971 *excluding data frames
973 statistics = ipn3ke_rpst_read_64bits_statistics_register(
974 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
975 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
977 hw_stats->eth.tx_multicast += statistics;
979 /*Number of valid broadcast frames transmitted,
980 *excluding data frames
982 statistics = ipn3ke_rpst_read_64bits_statistics_register(
983 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
984 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
986 hw_stats->eth.tx_broadcast += statistics;
988 /*Number of valid unicast frames transmitted,
989 *excluding data frames
991 statistics = ipn3ke_rpst_read_64bits_statistics_register(
992 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
993 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
995 hw_stats->eth.tx_unicast += statistics;
997 /* Number of valid pause frames transmitted */
998 statistics = ipn3ke_rpst_read_64bits_statistics_register(
999 IPN3KE_25G_CNTR_TX_PAUSE_LO,
1000 IPN3KE_25G_CNTR_TX_PAUSE_HI,
1003 /*Number of transmitted runt packets. The IP core does not
1004 *transmit frames of length less than nine bytes.
1005 *The IP core pads frames of length nine bytes to 64 bytes to
1006 *extend them to 64 bytes. Therefore, this counter does not
1007 *increment in normal operating conditions.
1009 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1010 IPN3KE_25G_CNTR_TX_RUNT_LO,
1011 IPN3KE_25G_CNTR_TX_RUNT_HI,
1014 /*Number of transmitted payload bytes in frames with no FCS,
1015 *undersized, oversized, or payload length errors.
1016 *If VLAN detection is turned off for the TX MAC (bit[1]
1017 *of the TX_MAC_CONTROL register at offset 0x40A has
1018 *the value of 1), the IP core counts the VLAN header bytes
1019 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1020 *as payload bytes. This register is compliant with
1021 *the requirements for aOctetsTransmittedOK in section
1022 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1024 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1025 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1026 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1028 hw_stats->eth.tx_bytes += statistics;
1030 /*Number of transmitted bytes in frames with no FCS, undersized,
1031 *oversized, or payload length errors. This register is
1032 *compliant with the requirements for ifOutOctets in RFC3635
1033 *(Managed Objects for Ethernet-like Interface Types)
1034 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1035 *Management Information Base (RMON)).
1037 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1038 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1039 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1042 /*Number of received frames less than 64 bytes
1043 *and reporting a CRC error
1045 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1046 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1047 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1049 hw_stats->eth.rx_discards += statistics;
1050 hw_stats->crc_errors += statistics;
1051 hw_stats->rx_length_errors += statistics;
1053 /* Number of received oversized frames reporting a CRC error */
1054 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1055 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1056 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1058 hw_stats->eth.rx_discards += statistics;
1059 hw_stats->crc_errors += statistics;
1060 hw_stats->rx_length_errors += statistics;
1062 /*Number of received packets with FCS errors.
1063 *This register maintains a count of the number of pulses
1064 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1066 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1067 IPN3KE_25G_CNTR_RX_FCS_LO,
1068 IPN3KE_25G_CNTR_RX_FCS_HI,
1070 hw_stats->eth.rx_discards += statistics;
1071 hw_stats->checksum_error += statistics;
1073 /*Number of received frames with a frame of length at least 64
1076 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1077 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1078 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1080 hw_stats->eth.rx_discards += statistics;
1081 hw_stats->crc_errors += statistics;
1083 /*Number of errored multicast frames received,
1084 *excluding control frames
1086 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1087 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1088 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1090 hw_stats->eth.rx_discards += statistics;
1092 /*Number of errored broadcast frames received,
1093 *excluding control frames
1095 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1096 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1097 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1099 hw_stats->eth.rx_discards += statistics;
1101 /*Number of errored unicast frames received,
1102 *excluding control frames
1104 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1105 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1106 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1108 hw_stats->eth.rx_discards += statistics;
1110 /* Number of errored multicast control frames received */
1111 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1112 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1113 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1115 hw_stats->eth.rx_discards += statistics;
1117 /* Number of errored broadcast control frames received */
1118 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1119 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1120 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1122 hw_stats->eth.rx_discards += statistics;
1124 /* Number of errored unicast control frames received */
1125 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1126 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1127 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1129 hw_stats->eth.rx_discards += statistics;
1131 /* Number of errored pause frames received */
1132 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1133 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1134 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1136 hw_stats->eth.rx_discards += statistics;
1138 /*Number of 64-byte received frames,
1139 *including the CRC field but excluding the preamble
1142 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1143 IPN3KE_25G_CNTR_RX_64B_LO,
1144 IPN3KE_25G_CNTR_RX_64B_HI,
1146 hw_stats->rx_size_64 += statistics;
1148 /*Number of received frames between 65 and 127 bytes */
1149 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1150 IPN3KE_25G_CNTR_RX_65_127B_LO,
1151 IPN3KE_25G_CNTR_RX_65_127B_HI,
1153 hw_stats->rx_size_65_127 += statistics;
1155 /*Number of received frames between 128 and 255 bytes
1157 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1158 IPN3KE_25G_CNTR_RX_128_255B_LO,
1159 IPN3KE_25G_CNTR_RX_128_255B_HI,
1161 hw_stats->rx_size_128_255 += statistics;
1163 /*Number of received frames between 256 and 511 bytes
1165 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1166 IPN3KE_25G_CNTR_RX_256_511B_LO,
1167 IPN3KE_25G_CNTR_RX_256_511B_HI,
1169 hw_stats->rx_size_256_511 += statistics;
1171 /*Number of received frames between 512 and 1023 bytes
1173 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1174 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1175 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1177 hw_stats->rx_size_512_1023 += statistics;
1179 /*Number of received frames between 1024 and 1518 bytes
1181 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1182 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1183 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1185 hw_stats->rx_size_1024_1518 += statistics;
1187 /*Number of received frames of size between 1519 bytes
1188 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1191 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1192 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1193 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1195 hw_stats->rx_size_big += statistics;
1197 /*Number of oversized frames (frames with more bytes
1198 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1201 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1202 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1203 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1205 hw_stats->rx_jabber += statistics;
1207 /*Number of valid multicast frames received,
1208 *excluding control frames
1210 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1211 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1212 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1214 hw_stats->eth.rx_multicast += statistics;
1216 /*Number of valid broadcast frames received,
1217 *excluding control frames
1219 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1220 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1221 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1223 hw_stats->eth.rx_broadcast += statistics;
1225 /*Number of valid unicast frames received,
1226 *excluding control frames
1228 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1229 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1230 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1232 hw_stats->eth.rx_unicast += statistics;
1234 /*Number of valid multicast frames received,
1235 *excluding data frames
1237 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1238 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1239 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1241 hw_stats->eth.rx_multicast += statistics;
1243 /*Number of valid broadcast frames received,
1244 *excluding data frames
1246 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1247 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1248 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1250 hw_stats->eth.rx_broadcast += statistics;
1252 /*Number of valid unicast frames received,
1253 *excluding data frames
1255 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1256 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1257 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1259 hw_stats->eth.rx_unicast += statistics;
1261 /*Number of received pause frames, with or without error
1263 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1264 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1265 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1268 /*Number of received runt packets. A runt is a packet of size
1269 *less than 64 bytes but greater than eight bytes.
1270 *If a packet is eight bytes or smaller, it is considered
1271 *a decoding error and not a runt frame, and the IP core
1272 *does not flag it nor count it as a runt.
1274 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1275 IPN3KE_25G_CNTR_RX_RUNT_LO,
1276 IPN3KE_25G_CNTR_RX_RUNT_HI,
1279 /*Number of received payload bytes in frames with no FCS,
1280 *undersized, oversized, or payload length errors.
1281 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1282 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1283 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1284 *8 bytes for stacked VLAN) as payload bytes.
1285 *This register is compliant with the requirements for
1286 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1289 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1290 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1291 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1293 hw_stats->eth.rx_bytes += statistics;
1295 /*Number of received bytes in frames with no FCS, undersized,
1296 *oversized, or payload length errors.
1297 *This register is compliant with the requirements for
1298 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1299 *Interface Types) and RX etherStatsOctets in RFC2819
1300 *(Remote Network Monitoring Management Information Base
1303 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1304 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1305 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1308 /*resume Tx counter to real time
1311 (*hw->f_mac_read)(hw,
1313 IPN3KE_25G_TX_STATISTICS_CONFIG,
1317 (*hw->f_mac_write)(hw,
1319 IPN3KE_25G_TX_STATISTICS_CONFIG,
1323 /*resume Rx counter to real time
1326 (*hw->f_mac_read)(hw,
1328 IPN3KE_25G_RX_STATISTICS_CONFIG,
1332 (*hw->f_mac_write)(hw,
1334 IPN3KE_25G_RX_STATISTICS_CONFIG,
1342 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1345 uint32_t tmp = 0x00000001;
1346 /* Bit[0]: Software can set this bit to the value of 1
1347 * to reset all of the TX statistics registers at the same time.
1348 * This bit is selfclearing.
1350 (*hw->f_mac_write)(hw,
1352 IPN3KE_25G_TX_STATISTICS_CONFIG,
1356 while (tmp & 0x00000001) {
1358 (*hw->f_mac_read)(hw,
1360 IPN3KE_25G_TX_STATISTICS_CONFIG,
1363 if (tmp & 0x00000001)
1371 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1374 uint32_t tmp = 0x00000001;
1375 /* Bit[0]: Software can set this bit to the value of 1
1376 * to reset all of the RX statistics registers at the same time.
1377 * This bit is selfclearing.
1379 (*hw->f_mac_write)(hw,
1381 IPN3KE_25G_RX_STATISTICS_CONFIG,
1385 while (tmp & 0x00000001) {
1387 (*hw->f_mac_read)(hw,
1389 IPN3KE_25G_RX_STATISTICS_CONFIG,
1392 if (tmp & 0x00000001)
1400 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1401 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1403 uint32_t statistics_lo = 0x00000000;
1404 uint32_t statistics_hi = 0x00000000;
1405 uint64_t statistics = 0x0000000000000000;
1407 (*hw->f_mac_read)(hw,
1412 (*hw->f_mac_read)(hw,
1417 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1418 statistics += statistics_hi;
1419 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1420 statistics += statistics_lo;
1425 ipn3ke_rpst_read_10g_lineside_stats_registers
1426 (struct ipn3ke_hw *hw,
1428 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1429 struct rte_eth_stats *stats)
1431 uint64_t statistics = 0;
1433 memset(hw_stats, 0, sizeof(*hw_stats));
1434 memset(stats, 0, sizeof(*stats));
1436 /*36-bit statistics counter that collects the number of frames
1437 *that are successfully transmitted, including control frames.
1439 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1440 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1441 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1443 stats->opackets = statistics;
1445 /*36-bit statistics counter that collects the number of frames
1446 *that are successfully received, including control frames.
1448 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1449 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1450 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1452 stats->ipackets = statistics;
1454 /*36-bit statistics counter that collects the number of frames
1455 *transmitted with error, including control frames.
1457 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1458 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1459 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1461 stats->oerrors = statistics;
1462 hw_stats->eth.tx_errors = statistics;
1464 /*36-bit statistics counter that collects the number of frames
1465 *received with error, including control frames.
1467 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1468 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1469 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1471 stats->ierrors = statistics;
1472 hw_stats->eth.rx_discards = statistics;
1474 /*36-bit statistics counter that collects the number
1475 *of RX frames with CRC error.
1477 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1478 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1479 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1481 hw_stats->crc_errors = statistics;
1483 /*64-bit statistics counter that collects the payload length,
1484 *including the bytes in control frames.
1485 *The payload length is the number of data and padding bytes
1487 *If the tx_vlan_detection[0] register bit is set to 1,
1488 *the VLAN and stacked VLAN tags are counted as part of
1491 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1492 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1493 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1495 stats->obytes = statistics;
1496 hw_stats->eth.tx_bytes = statistics;
1498 /*64-bit statistics counter that collects the payload length,
1499 *including the bytes in control frames.
1500 *The payload length is the number of data and padding bytes
1502 *If the rx_vlan_detection[0] register bit is set to 1,
1503 *the VLAN and stacked VLAN tags are counted as part of
1506 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1507 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1508 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1510 stats->ibytes = statistics;
1511 hw_stats->eth.rx_bytes = statistics;
1513 /*36-bit statistics counter that collects the number of
1514 *valid pause frames transmitted.
1516 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1517 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1518 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1521 /*36-bit statistics counter that collects the number of
1522 *valid pause frames received.
1524 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1525 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1526 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1529 /*36-bit statistics counter that collects the number of frames
1530 *transmitted that are invalid and with error.
1532 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1533 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1534 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1537 /*36-bit statistics counter that collects the number of frames
1538 *received that are invalid and with error.
1540 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1541 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1542 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1545 /*36-bit statistics counter that collects the number of
1546 *good unicast frames transmitted,
1547 *excluding control frames.
1549 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1550 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1551 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1553 hw_stats->eth.tx_unicast = statistics;
1555 /*36-bit statistics counter that collects the number of
1556 *good unicast frames received,
1557 *excluding control frames.
1559 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1560 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1561 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1563 hw_stats->eth.rx_unicast = statistics;
1565 /*36-bit statistics counter that collects the number of
1566 *unicast frames transmitted with error,
1567 *excluding control frames.
1569 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1570 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1571 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1574 /*36-bit statistics counter that collects the number of
1575 *unicast frames received with error,
1576 *excluding control frames.
1578 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1579 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1580 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1583 /*36-bit statistics counter that collects the number of
1584 *good multicast frames transmitted,
1585 *excluding control frames.
1587 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1588 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1589 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1591 hw_stats->eth.tx_multicast = statistics;
1593 /*36-bit statistics counter that collects the number of
1594 *good multicast frames received,
1595 *excluding control frames.
1597 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1598 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1599 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1601 hw_stats->eth.rx_multicast = statistics;
1603 /*36-bit statistics counter that collects the number of
1604 *multicast frames transmitted with error,
1605 *excluding control frames.
1607 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1608 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1609 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1612 /*36-bit statistics counter that collects the number
1613 *of multicast frames received with error,
1614 *excluding control frames.
1616 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1617 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1618 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1621 /*36-bit statistics counter that collects the number of
1622 *good broadcast frames transmitted,
1623 *excluding control frames.
1625 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1626 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1627 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1629 hw_stats->eth.tx_broadcast = statistics;
1631 /*36-bit statistics counter that collects the number of
1632 *good broadcast frames received,
1633 *excluding control frames.
1635 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1636 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1637 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1639 hw_stats->eth.rx_broadcast = statistics;
1641 /*36-bit statistics counter that collects the number
1642 *of broadcast frames transmitted with error,
1643 *excluding control frames.
1645 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1646 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1647 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1650 /*36-bit statistics counter that collects the number of
1651 *broadcast frames received with error,
1652 *excluding control frames.
1654 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1655 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1656 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1659 /*64-bit statistics counter that collects the total number of
1660 *octets transmitted.
1661 *This count includes good, errored, and invalid frames.
1663 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1664 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1665 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1668 /*64-bit statistics counter that collects the total number of
1670 *This count includes good, errored, and invalid frames.
1672 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1673 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1674 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1677 /*36-bit statistics counter that collects the total number of
1678 *good, errored, and invalid frames transmitted.
1680 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1681 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1682 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1685 /*36-bit statistics counter that collects the total number of
1686 *good, errored, and invalid frames received.
1688 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1689 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1690 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1693 /*36-bit statistics counter that collects the number of
1694 *undersized TX frames.
1696 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1697 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1698 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1701 /*36-bit statistics counter that collects the number of
1702 *undersized RX frames.
1704 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1705 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1706 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1708 hw_stats->rx_undersize = statistics;
1710 /*36-bit statistics counter that collects the number of
1711 *TX frames whose length exceeds the maximum frame length
1714 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1715 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1716 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1719 /*36-bit statistics counter that collects the number of
1720 *RX frames whose length exceeds the maximum frame length
1723 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1724 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1725 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1727 hw_stats->rx_oversize = statistics;
1729 /*36-bit statistics counter that collects the number of
1731 *including the CRC field
1732 *but excluding the preamble and SFD bytes.
1733 *This count includes good, errored, and invalid frames.
1735 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1736 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1737 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1739 hw_stats->tx_size_64 = statistics;
1741 /*36-bit statistics counter that collects the number of
1743 *including the CRC field
1744 *but excluding the preamble and SFD bytes.
1745 *This count includes good, errored, and invalid frames.
1747 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1748 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1749 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1751 hw_stats->rx_size_64 = statistics;
1753 /*36-bit statistics counter that collects the number of
1754 *TX frames between the length of 65 and 127 bytes,
1755 *including the CRC field
1756 *but excluding the preamble and SFD bytes.
1757 *This count includes good, errored, and invalid frames.
1759 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1760 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1761 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1763 hw_stats->tx_size_65_127 = statistics;
1765 /*36-bit statistics counter that collects the number of
1766 *RX frames between the length of 65 and 127 bytes,
1767 *including the CRC field
1768 *but excluding the preamble and SFD bytes.
1769 *This count includes good, errored, and invalid frames.
1771 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1772 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1773 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1775 hw_stats->rx_size_65_127 = statistics;
1777 /*36-bit statistics counter that collects the number of
1778 *TX frames between the length of 128 and 255 bytes,
1779 *including the CRC field
1780 *but excluding the preamble and SFD bytes.
1781 *This count includes good, errored, and invalid frames.
1783 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1784 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1785 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1787 hw_stats->tx_size_128_255 = statistics;
1789 /*36-bit statistics counter that collects the number of
1790 *RX frames between the length of 128 and 255 bytes,
1791 *including the CRC field
1792 *but excluding the preamble and SFD bytes.
1793 *This count includes good, errored, and invalid frames.
1795 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1796 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1797 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1799 hw_stats->rx_size_128_255 = statistics;
1801 /*36-bit statistics counter that collects the number of
1802 *TX frames between the length of 256 and 511 bytes,
1803 *including the CRC field
1804 *but excluding the preamble and SFD bytes.
1805 *This count includes good, errored, and invalid frames.
1807 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1808 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1809 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1811 hw_stats->tx_size_256_511 = statistics;
1813 /*36-bit statistics counter that collects the number of
1814 *RX frames between the length of 256 and 511 bytes,
1815 *including the CRC field
1816 *but excluding the preamble and SFD bytes.
1817 *This count includes good, errored, and invalid frames.
1819 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1820 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1821 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1823 hw_stats->rx_size_256_511 = statistics;
1825 /*36-bit statistics counter that collects the number of
1826 *TX frames between the length of 512 and 1023 bytes,
1827 *including the CRC field
1828 *but excluding the preamble and SFD bytes.
1829 *This count includes good, errored, and invalid frames.
1831 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1832 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1833 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1835 hw_stats->tx_size_512_1023 = statistics;
1837 /*36-bit statistics counter that collects the number of
1838 *RX frames between the length of 512 and 1023 bytes,
1839 *including the CRC field
1840 *but excluding the preamble and SFD bytes.
1841 *This count includes good, errored, and invalid frames.
1843 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1844 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1845 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1847 hw_stats->rx_size_512_1023 = statistics;
1849 /*36-bit statistics counter that collects the number of
1850 *TX frames between the length of 1024 and 1518 bytes,
1851 *including the CRC field but
1852 *excluding the preamble and SFD bytes.
1853 *This count includes good, errored, and invalid frames.
1855 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1856 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1857 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1859 hw_stats->tx_size_1024_1518 = statistics;
1861 /*36-bit statistics counter that collects the number of
1862 *RX frames between the length of 1024 and 1518 bytes,
1863 *including the CRC field
1864 *but excluding the preamble and SFD bytes.
1865 *This count includes good, errored, and invalid frames.
1867 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1868 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1869 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1871 hw_stats->rx_size_1024_1518 = statistics;
1873 /*36-bit statistics counter that collects the number of
1874 *TX frames equal or more than the length of 1,519 bytes,
1875 *including the CRC field
1876 *but excluding the preamble and SFD bytes.
1877 *This count includes good, errored, and invalid frames.
1879 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1880 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1881 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1883 hw_stats->tx_size_1519_to_max = statistics;
1885 /*36-bit statistics counter that collects the number of
1886 *RX frames equal or more than the length of 1,519 bytes,
1887 *including the CRC field
1888 *but excluding the preamble and SFD bytes.
1889 *This count includes good,
1890 *errored, and invalid frames.
1892 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1893 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1894 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1896 hw_stats->rx_size_big = statistics;
1898 /*36-bit statistics counter that collects the total number of
1899 *RX frames with length less than 64 bytes and CRC error.
1900 *The MAC does not drop these frames.
1902 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1903 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1904 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1907 /*36-bit statistics counter that collects the number of
1908 *oversized RX frames with CRC error.
1909 *The MAC does not drop these frames.
1911 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1912 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1913 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1916 /*36-bit statistics counter that collects the number of
1917 *RX frames with CRC error,
1918 *whose length is between 64 and the maximum frame length
1919 *specified in the register.
1920 *The MAC does not drop these frames.
1922 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1923 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1924 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1927 /*36-bit statistics counter that collects the number of
1928 *valid TX unicast control frames.
1930 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1931 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1932 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1934 hw_stats->eth.tx_unicast += statistics;
1936 /*36-bit statistics counter that collects the number of
1937 *valid RX unicast control frames.
1939 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1940 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1941 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1943 hw_stats->eth.rx_unicast += statistics;
1945 /*36-bit statistics counter that collects the number of
1946 *valid TX multicast control frames.
1948 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1949 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1950 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1952 hw_stats->eth.tx_multicast += statistics;
1954 /*36-bit statistics counter that collects the number of
1955 *valid RX multicast control frames.
1957 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1958 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1959 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1961 hw_stats->eth.rx_multicast += statistics;
1963 /*36-bit statistics counter that collects the number of
1964 *valid TX broadcast control frames.
1966 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1967 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1968 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1970 hw_stats->eth.tx_broadcast += statistics;
1972 /*36-bit statistics counter that collects the number of
1973 *valid RX broadcast control frames.
1975 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1976 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1977 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1979 hw_stats->eth.rx_broadcast += statistics;
1981 /*36-bit statistics counter that collects the number of
1982 *valid TX PFC frames.
1984 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1985 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1986 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1989 /*36-bit statistics counter that collects the number of
1990 *valid RX PFC frames.
1992 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1993 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1994 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
2001 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2006 /*Bit [0]: Set this register to 1 to clear all TX statistics
2008 *The IP core clears this bit when all counters are cleared.
2009 *Bits [31:1]: Reserved.
2012 (*hw->f_mac_read)(hw,
2014 IPN3KE_10G_TX_STATS_CLR,
2018 (*hw->f_mac_write)(hw,
2020 IPN3KE_10G_TX_STATS_CLR,
2026 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2031 /*Bit [0]: Set this register to 1 to clear all RX statistics
2033 *The IP core clears this bit when all counters are cleared.
2034 *Bits [31:1]: Reserved
2037 (*hw->f_mac_read)(hw,
2039 IPN3KE_10G_RX_STATS_CLR,
2043 (*hw->f_mac_write)(hw,
2045 IPN3KE_10G_RX_STATS_CLR,
2051 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2053 uint16_t port_id = 0;
2056 struct rte_afu_device *afu_dev = NULL;
2057 struct ipn3ke_hw *hw = NULL;
2060 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2064 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2066 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2070 if (!afu_dev->shared.data) {
2071 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2075 hw = afu_dev->shared.data;
2077 ch = ethdev->data->name;
2079 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2090 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2095 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2096 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2097 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2098 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2099 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2100 } else if (hw->retimer.mac_type ==
2101 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2102 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2103 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2104 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2105 ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
2112 ipn3ke_rpst_stats_get
2113 (struct rte_eth_dev *ethdev, struct rte_eth_stats *stats)
2115 uint16_t port_id = 0;
2119 struct rte_afu_device *afu_dev = NULL;
2120 struct ipn3ke_hw *hw = NULL;
2121 struct ipn3ke_rpst_hw_port_stats hw_stats;
2124 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2128 IPN3KE_AFU_PMD_ERR("Address to return statistics is NULL!");
2132 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2134 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2138 if (!afu_dev->shared.data) {
2139 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2143 hw = afu_dev->shared.data;
2145 ch = ethdev->data->name;
2147 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2158 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2163 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2164 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2168 stats->ipackets = hw_stats.rx_size_64
2169 + hw_stats.rx_size_65_127
2170 + hw_stats.rx_size_128_255
2171 + hw_stats.rx_size_256_511
2172 + hw_stats.rx_size_512_1023
2173 + hw_stats.rx_size_1024_1518
2174 + hw_stats.rx_size_big
2175 + hw_stats.rx_undersize
2176 + hw_stats.rx_fragments
2177 + hw_stats.rx_oversize
2178 + hw_stats.rx_jabber;
2179 stats->opackets = hw_stats.tx_size_64
2180 + hw_stats.tx_size_65_127
2181 + hw_stats.tx_size_128_255
2182 + hw_stats.tx_size_256_511
2183 + hw_stats.tx_size_512_1023
2184 + hw_stats.tx_size_1024_1518
2185 + hw_stats.tx_size_1519_to_max;
2186 stats->ibytes = hw_stats.eth.rx_bytes;
2187 stats->obytes = hw_stats.eth.tx_bytes;
2189 stats->ierrors = hw_stats.eth.rx_discards
2190 + hw_stats.eth.rx_unknown_protocol;
2191 stats->oerrors = hw_stats.eth.tx_discards
2192 + hw_stats.eth.tx_errors;
2193 stats->rx_nombuf = 0;
2194 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
2195 stats->q_ipackets[i] = 0;
2196 stats->q_opackets[i] = 0;
2197 stats->q_ibytes[i] = 0;
2198 stats->q_obytes[i] = 0;
2199 stats->q_errors[i] = 0;
2202 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2212 ipn3ke_rpst_xstats_get
2213 (struct rte_eth_dev *ethdev, struct rte_eth_xstat *xstats, unsigned int n)
2215 uint16_t port_id = 0;
2218 unsigned int i, count, prio;
2219 struct rte_afu_device *afu_dev = NULL;
2220 struct ipn3ke_hw *hw = NULL;
2221 struct ipn3ke_rpst_hw_port_stats hw_stats;
2222 struct rte_eth_stats stats;
2228 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2232 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2234 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2238 if (!afu_dev->shared.data) {
2239 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2243 hw = afu_dev->shared.data;
2245 ch = ethdev->data->name;
2247 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2258 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2263 count = ipn3ke_rpst_xstats_calc_num();
2267 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2268 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2272 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2280 /* Get stats from ipn3ke_rpst_stats */
2281 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2282 xstats[count].value = *(uint64_t *)(((char *)&hw_stats.eth)
2283 + ipn3ke_rpst_stats_strings[i].offset);
2284 xstats[count].id = count;
2288 /* Get individiual stats from ipn3ke_rpst_hw_port */
2289 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2290 xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) +
2291 ipn3ke_rpst_hw_port_strings[i].offset);
2292 xstats[count].id = count;
2296 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2297 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2298 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2299 xstats[count].value =
2300 *(uint64_t *)(((char *)(&hw_stats)) +
2301 ipn3ke_rpst_rxq_prio_strings[i].offset +
2302 (sizeof(uint64_t) * prio));
2303 xstats[count].id = count;
2308 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2309 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2310 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2311 xstats[count].value =
2312 *(uint64_t *)(((char *)(&hw_stats)) +
2313 ipn3ke_rpst_txq_prio_strings[i].offset +
2314 (sizeof(uint64_t) * prio));
2315 xstats[count].id = count;
2324 ipn3ke_rpst_xstats_get_names
2325 (__rte_unused struct rte_eth_dev *dev,
2326 struct rte_eth_xstat_name *xstats_names,
2327 __rte_unused unsigned int limit)
2329 unsigned int count = 0;
2330 unsigned int i, prio;
2333 return ipn3ke_rpst_xstats_calc_num();
2335 /* Note: limit checked in rte_eth_xstats_names() */
2337 /* Get stats from ipn3ke_rpst_stats */
2338 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2339 snprintf(xstats_names[count].name,
2340 sizeof(xstats_names[count].name),
2342 ipn3ke_rpst_stats_strings[i].name);
2346 /* Get individiual stats from ipn3ke_rpst_hw_port */
2347 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2348 snprintf(xstats_names[count].name,
2349 sizeof(xstats_names[count].name),
2351 ipn3ke_rpst_hw_port_strings[i].name);
2355 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2356 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2357 for (prio = 0; prio < 8; prio++) {
2358 snprintf(xstats_names[count].name,
2359 sizeof(xstats_names[count].name),
2362 ipn3ke_rpst_rxq_prio_strings[i].name);
2367 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2368 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2369 for (prio = 0; prio < 8; prio++) {
2370 snprintf(xstats_names[count].name,
2371 sizeof(xstats_names[count].name),
2374 ipn3ke_rpst_txq_prio_strings[i].name);
2382 ipn3ke_update_link(struct rte_rawdev *rawdev,
2383 uint16_t port, struct rte_eth_link *link)
2385 uint64_t line_link_bitmap = 0;
2386 enum ifpga_rawdev_link_speed link_speed;
2388 rawdev->dev_ops->attr_get(rawdev,
2389 "LineSideLinkStatus",
2390 (uint64_t *)&line_link_bitmap);
2392 /* Parse the link status */
2393 if ((1 << port) & line_link_bitmap)
2394 link->link_status = 1;
2396 link->link_status = 0;
2398 IPN3KE_AFU_PMD_DEBUG("port is %d\n", port);
2399 IPN3KE_AFU_PMD_DEBUG("link->link_status is %d\n", link->link_status);
2401 rawdev->dev_ops->attr_get(rawdev,
2402 "LineSideLinkSpeed",
2403 (uint64_t *)&link_speed);
2404 switch (link_speed) {
2405 case IFPGA_RAWDEV_LINK_SPEED_10GB:
2406 link->link_speed = ETH_SPEED_NUM_10G;
2408 case IFPGA_RAWDEV_LINK_SPEED_25GB:
2409 link->link_speed = ETH_SPEED_NUM_25G;
2412 IPN3KE_AFU_PMD_ERR("Unknown link speed info %u", link_speed);
2418 * Set device link up.
2421 ipn3ke_rpst_dev_set_link_up(struct rte_eth_dev *dev)
2423 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2424 struct rte_eth_dev *pf;
2427 if (rpst->i40e_pf_eth) {
2428 ret = rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2429 pf = rpst->i40e_pf_eth;
2430 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2437 * Set device link down.
2440 ipn3ke_rpst_dev_set_link_down(struct rte_eth_dev *dev)
2442 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2443 struct rte_eth_dev *pf;
2446 if (rpst->i40e_pf_eth) {
2447 ret = rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2448 pf = rpst->i40e_pf_eth;
2449 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2456 ipn3ke_rpst_link_update(struct rte_eth_dev *ethdev,
2457 __rte_unused int wait_to_complete)
2459 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2460 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2461 struct rte_rawdev *rawdev;
2462 struct rte_eth_link link;
2463 struct rte_eth_dev *pf;
2465 memset(&link, 0, sizeof(link));
2467 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2468 link.link_autoneg = !(ethdev->data->dev_conf.link_speeds &
2469 ETH_LINK_SPEED_FIXED);
2471 rawdev = hw->rawdev;
2472 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2474 if (!rpst->ori_linfo.link_status &&
2476 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Up\n", rpst->port_id);
2477 rpst->ori_linfo.link_status = link.link_status;
2478 rpst->ori_linfo.link_speed = link.link_speed;
2480 rte_eth_linkstatus_set(ethdev, &link);
2482 if (rpst->i40e_pf_eth) {
2483 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Up\n",
2484 rpst->i40e_pf_eth_port_id);
2485 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2486 pf = rpst->i40e_pf_eth;
2487 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2489 } else if (rpst->ori_linfo.link_status &&
2490 !link.link_status) {
2491 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Down\n",
2493 rpst->ori_linfo.link_status = link.link_status;
2494 rpst->ori_linfo.link_speed = link.link_speed;
2496 rte_eth_linkstatus_set(ethdev, &link);
2498 if (rpst->i40e_pf_eth) {
2499 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Down\n",
2500 rpst->i40e_pf_eth_port_id);
2501 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2502 pf = rpst->i40e_pf_eth;
2503 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2511 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst)
2513 struct ipn3ke_hw *hw;
2514 struct rte_rawdev *rawdev;
2515 struct rte_eth_link link;
2516 struct rte_eth_dev *pf;
2523 memset(&link, 0, sizeof(link));
2525 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2526 link.link_autoneg = !(rpst->ethdev->data->dev_conf.link_speeds &
2527 ETH_LINK_SPEED_FIXED);
2529 rawdev = hw->rawdev;
2530 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2532 if (!rpst->ori_linfo.link_status &&
2534 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Up\n", rpst->port_id);
2535 rpst->ori_linfo.link_status = link.link_status;
2536 rpst->ori_linfo.link_speed = link.link_speed;
2538 rte_eth_linkstatus_set(rpst->ethdev, &link);
2540 if (rpst->i40e_pf_eth) {
2541 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Up\n",
2542 rpst->i40e_pf_eth_port_id);
2543 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2544 pf = rpst->i40e_pf_eth;
2545 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2547 } else if (rpst->ori_linfo.link_status &&
2548 !link.link_status) {
2549 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Down\n", rpst->port_id);
2550 rpst->ori_linfo.link_status = link.link_status;
2551 rpst->ori_linfo.link_speed = link.link_speed;
2553 rte_eth_linkstatus_set(rpst->ethdev, &link);
2555 if (rpst->i40e_pf_eth) {
2556 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Down\n",
2557 rpst->i40e_pf_eth_port_id);
2558 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2559 pf = rpst->i40e_pf_eth;
2560 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2568 ipn3ke_rpst_scan_handle_request(__rte_unused void *param)
2570 struct ipn3ke_rpst *rpst;
2577 TAILQ_FOREACH(rpst, &ipn3ke_rpst_list, next) {
2578 if (rpst->i40e_pf_eth &&
2579 rpst->ethdev->data->dev_started &&
2580 rpst->i40e_pf_eth->data->dev_started)
2581 ipn3ke_rpst_link_check(rpst);
2583 if (++num > SCAN_NUM)
2584 rte_delay_us(1 * MS);
2586 rte_delay_us(50 * MS);
2588 if (num == 0xffffff)
2596 ipn3ke_rpst_scan_check(void)
2600 if (ipn3ke_rpst_scan_num == 1) {
2601 ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
2604 ipn3ke_rpst_scan_handle_request, NULL);
2606 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2609 } else if (ipn3ke_rpst_scan_num == 0) {
2610 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2612 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2614 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2616 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2625 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2627 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2628 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2629 uint32_t rddata, val;
2631 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2632 /* Enable all unicast */
2633 (*hw->f_mac_read)(hw,
2635 IPN3KE_MAC_RX_FRAME_CONTROL,
2639 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2641 (*hw->f_mac_write)(hw,
2643 IPN3KE_MAC_RX_FRAME_CONTROL,
2652 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2654 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2655 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2656 uint32_t rddata, val;
2658 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2659 /* Disable all unicast */
2660 (*hw->f_mac_read)(hw,
2662 IPN3KE_MAC_RX_FRAME_CONTROL,
2666 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2668 (*hw->f_mac_write)(hw,
2670 IPN3KE_MAC_RX_FRAME_CONTROL,
2679 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2681 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2682 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2683 uint32_t rddata, val;
2685 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2686 /* Enable all unicast */
2687 (*hw->f_mac_read)(hw,
2689 IPN3KE_MAC_RX_FRAME_CONTROL,
2693 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2694 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2696 (*hw->f_mac_write)(hw,
2698 IPN3KE_MAC_RX_FRAME_CONTROL,
2707 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2709 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2710 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2711 uint32_t rddata, val;
2713 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2714 /* Disable all unicast */
2715 (*hw->f_mac_read)(hw,
2717 IPN3KE_MAC_RX_FRAME_CONTROL,
2721 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2722 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2724 (*hw->f_mac_write)(hw,
2726 IPN3KE_MAC_RX_FRAME_CONTROL,
2735 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2736 struct rte_ether_addr *mac_addr)
2738 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2739 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2742 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2743 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2747 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2748 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2750 /* Set mac address */
2751 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2752 (*hw->f_mac_write)(hw,
2754 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2757 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2758 (*hw->f_mac_write)(hw,
2760 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2769 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2772 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2773 struct rte_eth_dev_data *dev_data = ethdev->data;
2774 uint32_t frame_size = mtu + IPN3KE_ETH_OVERHEAD;
2776 /* check if mtu is within the allowed range */
2777 if (mtu < RTE_ETHER_MIN_MTU ||
2778 frame_size > IPN3KE_MAC_FRAME_SIZE_MAX)
2781 /* mtu setting is forbidden if port is start */
2782 /* make sure NIC port is stopped */
2783 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2784 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2785 "be stopped before configuration",
2786 rpst->i40e_pf_eth->data->port_id);
2789 /* mtu setting is forbidden if port is start */
2790 if (dev_data->dev_started) {
2791 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2792 "be stopped before configuration",
2797 if (frame_size > RTE_ETHER_MAX_LEN)
2798 dev_data->dev_conf.rxmode.offloads |=
2799 (uint64_t)(DEV_RX_OFFLOAD_JUMBO_FRAME);
2801 dev_data->dev_conf.rxmode.offloads &=
2802 (uint64_t)(~DEV_RX_OFFLOAD_JUMBO_FRAME);
2804 dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
2806 if (rpst->i40e_pf_eth) {
2807 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2810 rpst->i40e_pf_eth->data->mtu = mtu;
2817 ipn3ke_afu_filter_ctrl(struct rte_eth_dev *ethdev,
2818 enum rte_filter_type filter_type, enum rte_filter_op filter_op,
2822 struct ipn3ke_hw *hw;
2823 struct ipn3ke_rpst *rpst;
2828 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2829 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2832 switch (filter_type) {
2833 case RTE_ETH_FILTER_GENERIC:
2834 if (filter_op != RTE_ETH_FILTER_GET)
2836 *(const void **)arg = &ipn3ke_flow_ops;
2839 IPN3KE_AFU_PMD_WARN("Filter type (%d) not supported",
2844 else if (rpst->i40e_pf_eth)
2845 (*rpst->i40e_pf_eth->dev_ops->filter_ctrl)(ethdev,
2855 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2856 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2858 .dev_configure = ipn3ke_rpst_dev_configure,
2859 .dev_start = ipn3ke_rpst_dev_start,
2860 .dev_stop = ipn3ke_rpst_dev_stop,
2861 .dev_close = ipn3ke_rpst_dev_close,
2862 .dev_reset = ipn3ke_rpst_dev_reset,
2864 .stats_get = ipn3ke_rpst_stats_get,
2865 .xstats_get = ipn3ke_rpst_xstats_get,
2866 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2867 .stats_reset = ipn3ke_rpst_stats_reset,
2868 .xstats_reset = ipn3ke_rpst_stats_reset,
2870 .filter_ctrl = ipn3ke_afu_filter_ctrl,
2872 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2873 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2874 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2875 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2876 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2877 .rx_queue_release = ipn3ke_rpst_rx_queue_release,
2878 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2879 .tx_queue_release = ipn3ke_rpst_tx_queue_release,
2881 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2882 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2883 .link_update = ipn3ke_rpst_link_update,
2885 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2886 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2887 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2888 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2889 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2890 .mtu_set = ipn3ke_rpst_mtu_set,
2892 .tm_ops_get = ipn3ke_tm_ops_get,
2895 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2896 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2902 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2903 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2909 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2911 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2912 struct ipn3ke_rpst *representor_param =
2913 (struct ipn3ke_rpst *)init_params;
2915 if (representor_param->port_id >= representor_param->hw->port_num)
2918 if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
2921 rpst->ethdev = ethdev;
2922 rpst->switch_domain_id = representor_param->switch_domain_id;
2923 rpst->port_id = representor_param->port_id;
2924 rpst->hw = representor_param->hw;
2925 rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
2926 rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
2927 if (rpst->i40e_pf_eth)
2928 ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
2931 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2932 if (!ethdev->data->mac_addrs) {
2933 IPN3KE_AFU_PMD_ERR("Failed to "
2934 "allocated memory for storing mac address");
2938 if (rpst->hw->tm_hw_enable)
2939 ipn3ke_tm_init(rpst);
2941 /* Set representor device ops */
2942 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2944 /* No data-path, but need stub Rx/Tx functions to avoid crash
2945 * when testing with the likes of testpmd.
2947 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2948 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2950 ethdev->data->nb_rx_queues = 1;
2951 ethdev->data->nb_tx_queues = 1;
2953 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2956 if (!ethdev->data->mac_addrs) {
2957 IPN3KE_AFU_PMD_ERR("Failed to "
2958 "allocated memory for storing mac address");
2962 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
2964 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2965 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2966 ipn3ke_rpst_scan_num++;
2967 ipn3ke_rpst_scan_check();
2968 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2974 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2976 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2978 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2979 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2980 ipn3ke_rpst_scan_num--;
2981 ipn3ke_rpst_scan_check();
2982 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);