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);
229 * Reset PF device only to re-initialize resources in PMD layer
232 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
234 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
235 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
237 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
238 /* Disable the TX path */
239 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
241 /* Disable the RX path */
242 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
249 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
250 __rte_unused uint16_t rx_queue_id)
256 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
257 __rte_unused uint16_t rx_queue_id)
263 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
264 __rte_unused uint16_t tx_queue_id)
270 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
271 __rte_unused uint16_t tx_queue_id)
277 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
278 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
279 __rte_unused unsigned int socket_id,
280 __rte_unused const struct rte_eth_rxconf *rx_conf,
281 __rte_unused struct rte_mempool *mp)
287 ipn3ke_rpst_rx_queue_release(__rte_unused void *rxq)
292 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
293 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
294 __rte_unused unsigned int socket_id,
295 __rte_unused const struct rte_eth_txconf *tx_conf)
301 ipn3ke_rpst_tx_queue_release(__rte_unused void *txq)
305 /* Statistics collected by each port, VSI, VEB, and S-channel */
306 struct ipn3ke_rpst_eth_stats {
307 uint64_t tx_bytes; /* gotc */
308 uint64_t tx_multicast; /* mptc */
309 uint64_t tx_broadcast; /* bptc */
310 uint64_t tx_unicast; /* uptc */
311 uint64_t tx_discards; /* tdpc */
312 uint64_t tx_errors; /* tepc */
313 uint64_t rx_bytes; /* gorc */
314 uint64_t rx_multicast; /* mprc */
315 uint64_t rx_broadcast; /* bprc */
316 uint64_t rx_unicast; /* uprc */
317 uint64_t rx_discards; /* rdpc */
318 uint64_t rx_unknown_protocol; /* rupp */
321 /* store statistics names and its offset in stats structure */
322 struct ipn3ke_rpst_xstats_name_offset {
323 char name[RTE_ETH_XSTATS_NAME_SIZE];
327 static const struct ipn3ke_rpst_xstats_name_offset
328 ipn3ke_rpst_stats_strings[] = {
329 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
331 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
333 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
335 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
337 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
339 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
341 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
343 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
345 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
346 rx_unknown_protocol)},
349 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
350 sizeof(ipn3ke_rpst_stats_strings[0]))
352 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
354 /* Statistics collected by the MAC */
355 struct ipn3ke_rpst_hw_port_stats {
356 /* eth stats collected by the port */
357 struct ipn3ke_rpst_eth_stats eth;
359 /* additional port specific stats */
360 uint64_t tx_dropped_link_down;
362 uint64_t illegal_bytes;
363 uint64_t error_bytes;
364 uint64_t mac_local_faults;
365 uint64_t mac_remote_faults;
366 uint64_t rx_length_errors;
367 uint64_t link_xon_rx;
368 uint64_t link_xoff_rx;
369 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
370 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
371 uint64_t link_xon_tx;
372 uint64_t link_xoff_tx;
373 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
374 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
375 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
377 uint64_t rx_size_65_127;
378 uint64_t rx_size_128_255;
379 uint64_t rx_size_256_511;
380 uint64_t rx_size_512_1023;
381 uint64_t rx_size_1024_1518;
382 uint64_t rx_size_big;
383 uint64_t rx_undersize;
384 uint64_t rx_fragments;
385 uint64_t rx_oversize;
388 uint64_t tx_size_65_127;
389 uint64_t tx_size_128_255;
390 uint64_t tx_size_256_511;
391 uint64_t tx_size_512_1023;
392 uint64_t tx_size_1024_1518;
393 uint64_t tx_size_1519_to_max;
394 uint64_t mac_short_packet_dropped;
395 uint64_t checksum_error;
396 /* flow director stats */
397 uint64_t fd_atr_match;
398 uint64_t fd_sb_match;
399 uint64_t fd_atr_tunnel_match;
400 uint32_t fd_atr_status;
401 uint32_t fd_sb_status;
403 uint32_t tx_lpi_status;
404 uint32_t rx_lpi_status;
405 uint64_t tx_lpi_count;
406 uint64_t rx_lpi_count;
409 static const struct ipn3ke_rpst_xstats_name_offset
410 ipn3ke_rpst_hw_port_strings[] = {
411 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
412 tx_dropped_link_down)},
413 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
415 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
417 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
419 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
421 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
423 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
425 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
427 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
429 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
431 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
433 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
435 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
437 {"rx_size_128_to_255_packets",
438 offsetof(struct ipn3ke_rpst_hw_port_stats,
440 {"rx_size_256_to_511_packets",
441 offsetof(struct ipn3ke_rpst_hw_port_stats,
443 {"rx_size_512_to_1023_packets",
444 offsetof(struct ipn3ke_rpst_hw_port_stats,
446 {"rx_size_1024_to_1518_packets",
447 offsetof(struct ipn3ke_rpst_hw_port_stats,
449 {"rx_size_1519_to_max_packets",
450 offsetof(struct ipn3ke_rpst_hw_port_stats,
452 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
454 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
456 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
457 mac_short_packet_dropped)},
458 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
460 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
462 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
464 {"tx_size_65_to_127_packets",
465 offsetof(struct ipn3ke_rpst_hw_port_stats,
467 {"tx_size_128_to_255_packets",
468 offsetof(struct ipn3ke_rpst_hw_port_stats,
470 {"tx_size_256_to_511_packets",
471 offsetof(struct ipn3ke_rpst_hw_port_stats,
473 {"tx_size_512_to_1023_packets",
474 offsetof(struct ipn3ke_rpst_hw_port_stats,
476 {"tx_size_1024_to_1518_packets",
477 offsetof(struct ipn3ke_rpst_hw_port_stats,
479 {"tx_size_1519_to_max_packets",
480 offsetof(struct ipn3ke_rpst_hw_port_stats,
481 tx_size_1519_to_max)},
482 {"rx_flow_director_atr_match_packets",
483 offsetof(struct ipn3ke_rpst_hw_port_stats,
485 {"rx_flow_director_sb_match_packets",
486 offsetof(struct ipn3ke_rpst_hw_port_stats,
488 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
490 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
492 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
494 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
498 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
499 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
501 static const struct ipn3ke_rpst_xstats_name_offset
502 ipn3ke_rpst_rxq_prio_strings[] = {
503 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
505 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
509 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
510 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
512 static const struct ipn3ke_rpst_xstats_name_offset
513 ipn3ke_rpst_txq_prio_strings[] = {
514 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
516 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
518 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
519 priority_xon_2_xoff)},
522 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
523 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
526 ipn3ke_rpst_xstats_calc_num(void)
528 return IPN3KE_RPST_ETH_XSTATS_CNT
529 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
530 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
531 * IPN3KE_RPST_PRIO_XSTATS_CNT)
532 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
533 * IPN3KE_RPST_PRIO_XSTATS_CNT);
537 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
540 uint32_t tmp = 0x00000001;
541 /* Bit[0]: Software can set this bit to the value of 1
542 * to reset all of the TX statistics registers at the same time.
543 * This bit is selfclearing.
545 (*hw->f_mac_write)(hw,
547 IPN3KE_25G_TX_STATISTICS_CONFIG,
551 while (tmp & 0x00000001) {
553 (*hw->f_mac_read)(hw,
555 IPN3KE_25G_TX_STATISTICS_CONFIG,
558 if (tmp & 0x00000001)
566 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
569 uint32_t tmp = 0x00000001;
570 /* Bit[0]: Software can set this bit to the value of 1
571 * to reset all of the RX statistics registers at the same time.
572 * This bit is selfclearing.
574 (*hw->f_mac_write)(hw,
576 IPN3KE_25G_RX_STATISTICS_CONFIG,
580 while (tmp & 0x00000001) {
582 (*hw->f_mac_read)(hw,
584 IPN3KE_25G_RX_STATISTICS_CONFIG,
587 if (tmp & 0x00000001)
595 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
600 /*Bit [0]: Set this register to 1 to clear all TX statistics
602 *The IP core clears this bit when all counters are cleared.
603 *Bits [31:1]: Reserved.
606 (*hw->f_mac_read)(hw,
608 IPN3KE_10G_TX_STATS_CLR,
612 (*hw->f_mac_write)(hw,
614 IPN3KE_10G_TX_STATS_CLR,
620 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
625 /*Bit [0]: Set this register to 1 to clear all RX statistics
627 *The IP core clears this bit when all counters are cleared.
628 *Bits [31:1]: Reserved
631 (*hw->f_mac_read)(hw,
633 IPN3KE_10G_RX_STATS_CLR,
637 (*hw->f_mac_write)(hw,
639 IPN3KE_10G_RX_STATS_CLR,
645 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
646 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
648 uint32_t statistics_lo = 0x00000000;
649 uint32_t statistics_hi = 0x00000000;
650 uint64_t statistics = 0x0000000000000000;
652 (*hw->f_mac_read)(hw,
658 (*hw->f_mac_read)(hw,
664 statistics += statistics_hi;
665 statistics = statistics << IPN3KE_REGISTER_WIDTH;
666 statistics += statistics_lo;
672 ipn3ke_rpst_read_25g_lineside_stats_registers
673 (struct ipn3ke_hw *hw,
675 struct ipn3ke_rpst_hw_port_stats *hw_stats)
680 memset(hw_stats, 0, sizeof(*hw_stats));
682 /*check Tx statistics is real time.
683 *if statistics has been paused, make it real time.
686 (*hw->f_mac_read)(hw,
688 IPN3KE_25G_TX_STATISTICS_CONFIG,
692 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
694 (*hw->f_mac_write)(hw,
696 IPN3KE_25G_TX_STATISTICS_CONFIG,
702 (*hw->f_mac_read)(hw,
704 IPN3KE_25G_TX_STATISTICS_STATUS,
707 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
709 (*hw->f_mac_read)(hw,
711 IPN3KE_25G_TX_STATISTICS_CONFIG,
715 (*hw->f_mac_write)(hw,
717 IPN3KE_25G_TX_STATISTICS_CONFIG,
722 /*check Rx statistics is real time.
723 *if statistics has been paused, make it real time.
726 (*hw->f_mac_read)(hw,
728 IPN3KE_25G_RX_STATISTICS_CONFIG,
731 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
733 (*hw->f_mac_write)(hw,
735 IPN3KE_25G_RX_STATISTICS_CONFIG,
741 (*hw->f_mac_read)(hw,
743 IPN3KE_25G_RX_STATISTICS_STATUS,
747 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
749 (*hw->f_mac_read)(hw,
751 IPN3KE_25G_RX_STATISTICS_CONFIG,
755 (*hw->f_mac_write)(hw,
757 IPN3KE_25G_RX_STATISTICS_CONFIG,
762 /* pause Tx counter to read the statistics */
764 (*hw->f_mac_read)(hw,
766 IPN3KE_25G_TX_STATISTICS_CONFIG,
770 (*hw->f_mac_write)(hw,
772 IPN3KE_25G_TX_STATISTICS_CONFIG,
776 /* pause Rx counter to read the statistics */
778 (*hw->f_mac_read)(hw,
780 IPN3KE_25G_RX_STATISTICS_CONFIG,
784 (*hw->f_mac_write)(hw,
786 IPN3KE_25G_RX_STATISTICS_CONFIG,
790 /*Number of transmitted frames less than 64 bytes
791 *and reporting a CRC error
793 statistics = ipn3ke_rpst_read_64bits_statistics_register(
794 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
795 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
797 hw_stats->eth.tx_errors += statistics;
798 hw_stats->crc_errors += statistics;
800 /*Number of transmitted oversized frames reporting a CRC error*/
801 statistics = ipn3ke_rpst_read_64bits_statistics_register(
802 IPN3KE_25G_CNTR_TX_JABBERS_LO,
803 IPN3KE_25G_CNTR_TX_JABBERS_HI,
805 hw_stats->eth.tx_errors += statistics;
806 hw_stats->crc_errors += statistics;
808 /* Number of transmitted packets with FCS errors */
809 statistics = ipn3ke_rpst_read_64bits_statistics_register(
810 IPN3KE_25G_CNTR_TX_FCS_LO,
811 IPN3KE_25G_CNTR_TX_FCS_HI,
813 hw_stats->eth.tx_errors += statistics;
814 hw_stats->checksum_error += statistics;
816 /*Number of transmitted frames with a frame of length at
817 *least 64 reporting a CRC error
819 statistics = ipn3ke_rpst_read_64bits_statistics_register(
820 IPN3KE_25G_CNTR_TX_CRCERR_LO,
821 IPN3KE_25G_CNTR_TX_CRCERR_HI,
823 hw_stats->eth.tx_errors += statistics;
824 hw_stats->crc_errors += statistics;
826 /*Number of errored multicast frames transmitted,
827 *excluding control frames
829 statistics = ipn3ke_rpst_read_64bits_statistics_register(
830 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
831 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
833 hw_stats->eth.tx_errors += statistics;
835 /*Number of errored broadcast frames transmitted,
836 *excluding control frames
838 statistics = ipn3ke_rpst_read_64bits_statistics_register(
839 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
840 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
842 hw_stats->eth.tx_errors += statistics;
844 /*Number of errored unicast frames transmitted,
845 *excluding control frames
847 statistics = ipn3ke_rpst_read_64bits_statistics_register(
848 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
849 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
851 hw_stats->eth.tx_errors += statistics;
853 /* Number of errored multicast control frames transmitted */
854 statistics = ipn3ke_rpst_read_64bits_statistics_register(
855 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
856 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
858 hw_stats->eth.tx_errors += statistics;
860 /* Number of errored broadcast control frames transmitted */
861 statistics = ipn3ke_rpst_read_64bits_statistics_register(
862 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
863 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
865 hw_stats->eth.tx_errors += statistics;
867 /* Number of errored unicast control frames transmitted */
868 statistics = ipn3ke_rpst_read_64bits_statistics_register(
869 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
870 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
872 hw_stats->eth.tx_errors += statistics;
874 /* Number of errored pause frames transmitted */
875 statistics = ipn3ke_rpst_read_64bits_statistics_register(
876 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
877 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
879 hw_stats->eth.tx_errors += statistics;
881 /*Number of 64-byte transmitted frames,
882 *including the CRC field but excluding the preamble
885 statistics = ipn3ke_rpst_read_64bits_statistics_register(
886 IPN3KE_25G_CNTR_TX_64B_LO,
887 IPN3KE_25G_CNTR_TX_64B_HI,
889 hw_stats->tx_size_64 += statistics;
891 /* Number of transmitted frames between 65 and 127 bytes */
892 statistics = ipn3ke_rpst_read_64bits_statistics_register(
893 IPN3KE_25G_CNTR_TX_65_127B_LO,
894 IPN3KE_25G_CNTR_TX_65_127B_HI,
896 hw_stats->tx_size_65_127 += statistics;
898 /* Number of transmitted frames between 128 and 255 bytes */
899 statistics = ipn3ke_rpst_read_64bits_statistics_register(
900 IPN3KE_25G_CNTR_TX_128_255B_LO,
901 IPN3KE_25G_CNTR_TX_128_255B_HI,
903 hw_stats->tx_size_128_255 += statistics;
905 /* Number of transmitted frames between 256 and 511 bytes */
906 statistics = ipn3ke_rpst_read_64bits_statistics_register(
907 IPN3KE_25G_CNTR_TX_256_511B_LO,
908 IPN3KE_25G_CNTR_TX_256_511B_HI,
910 hw_stats->tx_size_256_511 += statistics;
912 /* Number of transmitted frames between 512 and 1023 bytes */
913 statistics = ipn3ke_rpst_read_64bits_statistics_register(
914 IPN3KE_25G_CNTR_TX_512_1023B_LO,
915 IPN3KE_25G_CNTR_TX_512_1023B_HI,
917 hw_stats->tx_size_512_1023 += statistics;
919 /* Number of transmitted frames between 1024 and 1518 bytes */
920 statistics = ipn3ke_rpst_read_64bits_statistics_register(
921 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
922 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
924 hw_stats->tx_size_1024_1518 += statistics;
926 /*Number of transmitted frames of size between 1519 bytes
927 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
930 statistics = ipn3ke_rpst_read_64bits_statistics_register(
931 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
932 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
934 hw_stats->tx_size_1519_to_max += statistics;
936 /*Number of oversized frames (frames with more bytes than the
937 *number specified in the MAX_TX_SIZE_CONFIG register)
940 statistics = ipn3ke_rpst_read_64bits_statistics_register(
941 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
942 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
945 /*Number of valid multicast frames transmitted,
946 *excluding control frames
948 statistics = ipn3ke_rpst_read_64bits_statistics_register(
949 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
950 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
952 hw_stats->eth.tx_multicast += statistics;
954 /*Number of valid broadcast frames transmitted,
955 *excluding control frames
957 statistics = ipn3ke_rpst_read_64bits_statistics_register(
958 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
959 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
961 hw_stats->eth.tx_broadcast += statistics;
963 /*Number of valid unicast frames transmitted,
964 *excluding control frames
966 statistics = ipn3ke_rpst_read_64bits_statistics_register(
967 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
968 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
970 hw_stats->eth.tx_unicast += statistics;
972 /*Number of valid multicast frames transmitted,
973 *excluding data frames
975 statistics = ipn3ke_rpst_read_64bits_statistics_register(
976 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
977 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
979 hw_stats->eth.tx_multicast += statistics;
981 /*Number of valid broadcast frames transmitted,
982 *excluding data frames
984 statistics = ipn3ke_rpst_read_64bits_statistics_register(
985 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
986 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
988 hw_stats->eth.tx_broadcast += statistics;
990 /*Number of valid unicast frames transmitted,
991 *excluding data frames
993 statistics = ipn3ke_rpst_read_64bits_statistics_register(
994 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
995 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
997 hw_stats->eth.tx_unicast += statistics;
999 /* Number of valid pause frames transmitted */
1000 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1001 IPN3KE_25G_CNTR_TX_PAUSE_LO,
1002 IPN3KE_25G_CNTR_TX_PAUSE_HI,
1005 /*Number of transmitted runt packets. The IP core does not
1006 *transmit frames of length less than nine bytes.
1007 *The IP core pads frames of length nine bytes to 64 bytes to
1008 *extend them to 64 bytes. Therefore, this counter does not
1009 *increment in normal operating conditions.
1011 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1012 IPN3KE_25G_CNTR_TX_RUNT_LO,
1013 IPN3KE_25G_CNTR_TX_RUNT_HI,
1016 /*Number of transmitted payload bytes in frames with no FCS,
1017 *undersized, oversized, or payload length errors.
1018 *If VLAN detection is turned off for the TX MAC (bit[1]
1019 *of the TX_MAC_CONTROL register at offset 0x40A has
1020 *the value of 1), the IP core counts the VLAN header bytes
1021 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1022 *as payload bytes. This register is compliant with
1023 *the requirements for aOctetsTransmittedOK in section
1024 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1026 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1027 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1028 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1030 hw_stats->eth.tx_bytes += statistics;
1032 /*Number of transmitted bytes in frames with no FCS, undersized,
1033 *oversized, or payload length errors. This register is
1034 *compliant with the requirements for ifOutOctets in RFC3635
1035 *(Managed Objects for Ethernet-like Interface Types)
1036 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1037 *Management Information Base (RMON)).
1039 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1040 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1041 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1044 /*Number of received frames less than 64 bytes
1045 *and reporting a CRC error
1047 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1048 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1049 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1051 hw_stats->eth.rx_discards += statistics;
1052 hw_stats->crc_errors += statistics;
1053 hw_stats->rx_length_errors += statistics;
1055 /* Number of received oversized frames reporting a CRC error */
1056 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1057 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1058 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1060 hw_stats->eth.rx_discards += statistics;
1061 hw_stats->crc_errors += statistics;
1062 hw_stats->rx_length_errors += statistics;
1064 /*Number of received packets with FCS errors.
1065 *This register maintains a count of the number of pulses
1066 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1068 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1069 IPN3KE_25G_CNTR_RX_FCS_LO,
1070 IPN3KE_25G_CNTR_RX_FCS_HI,
1072 hw_stats->eth.rx_discards += statistics;
1073 hw_stats->checksum_error += statistics;
1075 /*Number of received frames with a frame of length at least 64
1078 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1079 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1080 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1082 hw_stats->eth.rx_discards += statistics;
1083 hw_stats->crc_errors += statistics;
1085 /*Number of errored multicast frames received,
1086 *excluding control frames
1088 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1089 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1090 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1092 hw_stats->eth.rx_discards += statistics;
1094 /*Number of errored broadcast frames received,
1095 *excluding control frames
1097 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1098 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1099 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1101 hw_stats->eth.rx_discards += statistics;
1103 /*Number of errored unicast frames received,
1104 *excluding control frames
1106 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1107 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1108 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1110 hw_stats->eth.rx_discards += statistics;
1112 /* Number of errored multicast control frames received */
1113 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1114 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1115 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1117 hw_stats->eth.rx_discards += statistics;
1119 /* Number of errored broadcast control frames received */
1120 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1121 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1122 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1124 hw_stats->eth.rx_discards += statistics;
1126 /* Number of errored unicast control frames received */
1127 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1128 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1129 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1131 hw_stats->eth.rx_discards += statistics;
1133 /* Number of errored pause frames received */
1134 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1135 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1136 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1138 hw_stats->eth.rx_discards += statistics;
1140 /*Number of 64-byte received frames,
1141 *including the CRC field but excluding the preamble
1144 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1145 IPN3KE_25G_CNTR_RX_64B_LO,
1146 IPN3KE_25G_CNTR_RX_64B_HI,
1148 hw_stats->rx_size_64 += statistics;
1150 /*Number of received frames between 65 and 127 bytes */
1151 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1152 IPN3KE_25G_CNTR_RX_65_127B_LO,
1153 IPN3KE_25G_CNTR_RX_65_127B_HI,
1155 hw_stats->rx_size_65_127 += statistics;
1157 /*Number of received frames between 128 and 255 bytes
1159 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1160 IPN3KE_25G_CNTR_RX_128_255B_LO,
1161 IPN3KE_25G_CNTR_RX_128_255B_HI,
1163 hw_stats->rx_size_128_255 += statistics;
1165 /*Number of received frames between 256 and 511 bytes
1167 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1168 IPN3KE_25G_CNTR_RX_256_511B_LO,
1169 IPN3KE_25G_CNTR_RX_256_511B_HI,
1171 hw_stats->rx_size_256_511 += statistics;
1173 /*Number of received frames between 512 and 1023 bytes
1175 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1176 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1177 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1179 hw_stats->rx_size_512_1023 += statistics;
1181 /*Number of received frames between 1024 and 1518 bytes
1183 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1184 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1185 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1187 hw_stats->rx_size_1024_1518 += statistics;
1189 /*Number of received frames of size between 1519 bytes
1190 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1193 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1194 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1195 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1197 hw_stats->rx_size_big += statistics;
1199 /*Number of oversized frames (frames with more bytes
1200 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1203 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1204 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1205 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1207 hw_stats->rx_jabber += statistics;
1209 /*Number of valid multicast frames received,
1210 *excluding control frames
1212 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1213 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1214 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1216 hw_stats->eth.rx_multicast += statistics;
1218 /*Number of valid broadcast frames received,
1219 *excluding control frames
1221 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1222 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1223 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1225 hw_stats->eth.rx_broadcast += statistics;
1227 /*Number of valid unicast frames received,
1228 *excluding control frames
1230 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1231 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1232 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1234 hw_stats->eth.rx_unicast += statistics;
1236 /*Number of valid multicast frames received,
1237 *excluding data frames
1239 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1240 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1241 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1243 hw_stats->eth.rx_multicast += statistics;
1245 /*Number of valid broadcast frames received,
1246 *excluding data frames
1248 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1249 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1250 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1252 hw_stats->eth.rx_broadcast += statistics;
1254 /*Number of valid unicast frames received,
1255 *excluding data frames
1257 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1258 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1259 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1261 hw_stats->eth.rx_unicast += statistics;
1263 /*Number of received pause frames, with or without error
1265 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1266 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1267 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1270 /*Number of received runt packets. A runt is a packet of size
1271 *less than 64 bytes but greater than eight bytes.
1272 *If a packet is eight bytes or smaller, it is considered
1273 *a decoding error and not a runt frame, and the IP core
1274 *does not flag it nor count it as a runt.
1276 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1277 IPN3KE_25G_CNTR_RX_RUNT_LO,
1278 IPN3KE_25G_CNTR_RX_RUNT_HI,
1281 /*Number of received payload bytes in frames with no FCS,
1282 *undersized, oversized, or payload length errors.
1283 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1284 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1285 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1286 *8 bytes for stacked VLAN) as payload bytes.
1287 *This register is compliant with the requirements for
1288 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1291 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1292 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1293 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1295 hw_stats->eth.rx_bytes += statistics;
1297 /*Number of received bytes in frames with no FCS, undersized,
1298 *oversized, or payload length errors.
1299 *This register is compliant with the requirements for
1300 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1301 *Interface Types) and RX etherStatsOctets in RFC2819
1302 *(Remote Network Monitoring Management Information Base
1305 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1306 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1307 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1310 /*resume Tx counter to real time
1313 (*hw->f_mac_read)(hw,
1315 IPN3KE_25G_TX_STATISTICS_CONFIG,
1319 (*hw->f_mac_write)(hw,
1321 IPN3KE_25G_TX_STATISTICS_CONFIG,
1325 /*resume Rx counter to real time
1328 (*hw->f_mac_read)(hw,
1330 IPN3KE_25G_RX_STATISTICS_CONFIG,
1334 (*hw->f_mac_write)(hw,
1336 IPN3KE_25G_RX_STATISTICS_CONFIG,
1344 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1347 uint32_t tmp = 0x00000001;
1348 /* Bit[0]: Software can set this bit to the value of 1
1349 * to reset all of the TX statistics registers at the same time.
1350 * This bit is selfclearing.
1352 (*hw->f_mac_write)(hw,
1354 IPN3KE_25G_TX_STATISTICS_CONFIG,
1358 while (tmp & 0x00000001) {
1360 (*hw->f_mac_read)(hw,
1362 IPN3KE_25G_TX_STATISTICS_CONFIG,
1365 if (tmp & 0x00000001)
1373 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1376 uint32_t tmp = 0x00000001;
1377 /* Bit[0]: Software can set this bit to the value of 1
1378 * to reset all of the RX statistics registers at the same time.
1379 * This bit is selfclearing.
1381 (*hw->f_mac_write)(hw,
1383 IPN3KE_25G_RX_STATISTICS_CONFIG,
1387 while (tmp & 0x00000001) {
1389 (*hw->f_mac_read)(hw,
1391 IPN3KE_25G_RX_STATISTICS_CONFIG,
1394 if (tmp & 0x00000001)
1402 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1403 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1405 uint32_t statistics_lo = 0x00000000;
1406 uint32_t statistics_hi = 0x00000000;
1407 uint64_t statistics = 0x0000000000000000;
1409 (*hw->f_mac_read)(hw,
1414 (*hw->f_mac_read)(hw,
1419 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1420 statistics += statistics_hi;
1421 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1422 statistics += statistics_lo;
1427 ipn3ke_rpst_read_10g_lineside_stats_registers
1428 (struct ipn3ke_hw *hw,
1430 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1431 struct rte_eth_stats *stats)
1433 uint64_t statistics = 0;
1435 memset(hw_stats, 0, sizeof(*hw_stats));
1436 memset(stats, 0, sizeof(*stats));
1438 /*36-bit statistics counter that collects the number of frames
1439 *that are successfully transmitted, including control frames.
1441 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1442 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1443 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1445 stats->opackets = statistics;
1447 /*36-bit statistics counter that collects the number of frames
1448 *that are successfully received, including control frames.
1450 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1451 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1452 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1454 stats->ipackets = statistics;
1456 /*36-bit statistics counter that collects the number of frames
1457 *transmitted with error, including control frames.
1459 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1460 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1461 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1463 stats->oerrors = statistics;
1464 hw_stats->eth.tx_errors = statistics;
1466 /*36-bit statistics counter that collects the number of frames
1467 *received with error, including control frames.
1469 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1470 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1471 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1473 stats->ierrors = statistics;
1474 hw_stats->eth.rx_discards = statistics;
1476 /*36-bit statistics counter that collects the number
1477 *of RX frames with CRC error.
1479 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1480 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1481 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1483 hw_stats->crc_errors = statistics;
1485 /*64-bit statistics counter that collects the payload length,
1486 *including the bytes in control frames.
1487 *The payload length is the number of data and padding bytes
1489 *If the tx_vlan_detection[0] register bit is set to 1,
1490 *the VLAN and stacked VLAN tags are counted as part of
1493 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1494 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1495 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1497 stats->obytes = statistics;
1498 hw_stats->eth.tx_bytes = statistics;
1500 /*64-bit statistics counter that collects the payload length,
1501 *including the bytes in control frames.
1502 *The payload length is the number of data and padding bytes
1504 *If the rx_vlan_detection[0] register bit is set to 1,
1505 *the VLAN and stacked VLAN tags are counted as part of
1508 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1509 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1510 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1512 stats->ibytes = statistics;
1513 hw_stats->eth.rx_bytes = statistics;
1515 /*36-bit statistics counter that collects the number of
1516 *valid pause frames transmitted.
1518 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1519 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1520 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1523 /*36-bit statistics counter that collects the number of
1524 *valid pause frames received.
1526 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1527 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1528 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1531 /*36-bit statistics counter that collects the number of frames
1532 *transmitted that are invalid and with error.
1534 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1535 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1536 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1539 /*36-bit statistics counter that collects the number of frames
1540 *received that are invalid and with error.
1542 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1543 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1544 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1547 /*36-bit statistics counter that collects the number of
1548 *good unicast frames transmitted,
1549 *excluding control frames.
1551 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1552 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1553 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1555 hw_stats->eth.tx_unicast = statistics;
1557 /*36-bit statistics counter that collects the number of
1558 *good unicast frames received,
1559 *excluding control frames.
1561 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1562 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1563 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1565 hw_stats->eth.rx_unicast = statistics;
1567 /*36-bit statistics counter that collects the number of
1568 *unicast frames transmitted with error,
1569 *excluding control frames.
1571 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1572 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1573 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1576 /*36-bit statistics counter that collects the number of
1577 *unicast frames received with error,
1578 *excluding control frames.
1580 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1581 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1582 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1585 /*36-bit statistics counter that collects the number of
1586 *good multicast frames transmitted,
1587 *excluding control frames.
1589 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1590 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1591 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1593 hw_stats->eth.tx_multicast = statistics;
1595 /*36-bit statistics counter that collects the number of
1596 *good multicast frames received,
1597 *excluding control frames.
1599 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1600 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1601 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1603 hw_stats->eth.rx_multicast = statistics;
1605 /*36-bit statistics counter that collects the number of
1606 *multicast frames transmitted with error,
1607 *excluding control frames.
1609 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1610 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1611 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1614 /*36-bit statistics counter that collects the number
1615 *of multicast frames received with error,
1616 *excluding control frames.
1618 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1619 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1620 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1623 /*36-bit statistics counter that collects the number of
1624 *good broadcast frames transmitted,
1625 *excluding control frames.
1627 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1628 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1629 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1631 hw_stats->eth.tx_broadcast = statistics;
1633 /*36-bit statistics counter that collects the number of
1634 *good broadcast frames received,
1635 *excluding control frames.
1637 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1638 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1639 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1641 hw_stats->eth.rx_broadcast = statistics;
1643 /*36-bit statistics counter that collects the number
1644 *of broadcast frames transmitted with error,
1645 *excluding control frames.
1647 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1648 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1649 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1652 /*36-bit statistics counter that collects the number of
1653 *broadcast frames received with error,
1654 *excluding control frames.
1656 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1657 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1658 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1661 /*64-bit statistics counter that collects the total number of
1662 *octets transmitted.
1663 *This count includes good, errored, and invalid frames.
1665 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1666 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1667 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1670 /*64-bit statistics counter that collects the total number of
1672 *This count includes good, errored, and invalid frames.
1674 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1675 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1676 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1679 /*36-bit statistics counter that collects the total number of
1680 *good, errored, and invalid frames transmitted.
1682 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1683 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1684 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1687 /*36-bit statistics counter that collects the total number of
1688 *good, errored, and invalid frames received.
1690 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1691 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1692 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1695 /*36-bit statistics counter that collects the number of
1696 *undersized TX frames.
1698 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1699 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1700 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1703 /*36-bit statistics counter that collects the number of
1704 *undersized RX frames.
1706 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1707 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1708 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1710 hw_stats->rx_undersize = statistics;
1712 /*36-bit statistics counter that collects the number of
1713 *TX frames whose length exceeds the maximum frame length
1716 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1717 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1718 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1721 /*36-bit statistics counter that collects the number of
1722 *RX frames whose length exceeds the maximum frame length
1725 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1726 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1727 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1729 hw_stats->rx_oversize = statistics;
1731 /*36-bit statistics counter that collects the number of
1733 *including the CRC field
1734 *but excluding the preamble and SFD bytes.
1735 *This count includes good, errored, and invalid frames.
1737 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1738 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1739 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1741 hw_stats->tx_size_64 = statistics;
1743 /*36-bit statistics counter that collects the number of
1745 *including the CRC field
1746 *but excluding the preamble and SFD bytes.
1747 *This count includes good, errored, and invalid frames.
1749 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1750 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1751 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1753 hw_stats->rx_size_64 = statistics;
1755 /*36-bit statistics counter that collects the number of
1756 *TX frames between the length of 65 and 127 bytes,
1757 *including the CRC field
1758 *but excluding the preamble and SFD bytes.
1759 *This count includes good, errored, and invalid frames.
1761 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1762 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1763 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1765 hw_stats->tx_size_65_127 = statistics;
1767 /*36-bit statistics counter that collects the number of
1768 *RX frames between the length of 65 and 127 bytes,
1769 *including the CRC field
1770 *but excluding the preamble and SFD bytes.
1771 *This count includes good, errored, and invalid frames.
1773 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1774 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1775 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1777 hw_stats->rx_size_65_127 = statistics;
1779 /*36-bit statistics counter that collects the number of
1780 *TX frames between the length of 128 and 255 bytes,
1781 *including the CRC field
1782 *but excluding the preamble and SFD bytes.
1783 *This count includes good, errored, and invalid frames.
1785 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1786 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1787 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1789 hw_stats->tx_size_128_255 = statistics;
1791 /*36-bit statistics counter that collects the number of
1792 *RX frames between the length of 128 and 255 bytes,
1793 *including the CRC field
1794 *but excluding the preamble and SFD bytes.
1795 *This count includes good, errored, and invalid frames.
1797 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1798 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1799 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1801 hw_stats->rx_size_128_255 = statistics;
1803 /*36-bit statistics counter that collects the number of
1804 *TX frames between the length of 256 and 511 bytes,
1805 *including the CRC field
1806 *but excluding the preamble and SFD bytes.
1807 *This count includes good, errored, and invalid frames.
1809 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1810 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1811 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1813 hw_stats->tx_size_256_511 = statistics;
1815 /*36-bit statistics counter that collects the number of
1816 *RX frames between the length of 256 and 511 bytes,
1817 *including the CRC field
1818 *but excluding the preamble and SFD bytes.
1819 *This count includes good, errored, and invalid frames.
1821 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1822 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1823 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1825 hw_stats->rx_size_256_511 = statistics;
1827 /*36-bit statistics counter that collects the number of
1828 *TX frames between the length of 512 and 1023 bytes,
1829 *including the CRC field
1830 *but excluding the preamble and SFD bytes.
1831 *This count includes good, errored, and invalid frames.
1833 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1834 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1835 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1837 hw_stats->tx_size_512_1023 = statistics;
1839 /*36-bit statistics counter that collects the number of
1840 *RX frames between the length of 512 and 1023 bytes,
1841 *including the CRC field
1842 *but excluding the preamble and SFD bytes.
1843 *This count includes good, errored, and invalid frames.
1845 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1846 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1847 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1849 hw_stats->rx_size_512_1023 = statistics;
1851 /*36-bit statistics counter that collects the number of
1852 *TX frames between the length of 1024 and 1518 bytes,
1853 *including the CRC field but
1854 *excluding the preamble and SFD bytes.
1855 *This count includes good, errored, and invalid frames.
1857 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1858 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1859 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1861 hw_stats->tx_size_1024_1518 = statistics;
1863 /*36-bit statistics counter that collects the number of
1864 *RX frames between the length of 1024 and 1518 bytes,
1865 *including the CRC field
1866 *but excluding the preamble and SFD bytes.
1867 *This count includes good, errored, and invalid frames.
1869 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1870 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1871 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1873 hw_stats->rx_size_1024_1518 = statistics;
1875 /*36-bit statistics counter that collects the number of
1876 *TX frames equal or more than the length of 1,519 bytes,
1877 *including the CRC field
1878 *but excluding the preamble and SFD bytes.
1879 *This count includes good, errored, and invalid frames.
1881 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1882 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1883 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1885 hw_stats->tx_size_1519_to_max = statistics;
1887 /*36-bit statistics counter that collects the number of
1888 *RX frames equal or more than the length of 1,519 bytes,
1889 *including the CRC field
1890 *but excluding the preamble and SFD bytes.
1891 *This count includes good,
1892 *errored, and invalid frames.
1894 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1895 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1896 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1898 hw_stats->rx_size_big = statistics;
1900 /*36-bit statistics counter that collects the total number of
1901 *RX frames with length less than 64 bytes and CRC error.
1902 *The MAC does not drop these frames.
1904 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1905 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1906 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1909 /*36-bit statistics counter that collects the number of
1910 *oversized RX frames with CRC error.
1911 *The MAC does not drop these frames.
1913 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1914 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1915 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1918 /*36-bit statistics counter that collects the number of
1919 *RX frames with CRC error,
1920 *whose length is between 64 and the maximum frame length
1921 *specified in the register.
1922 *The MAC does not drop these frames.
1924 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1925 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1926 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1929 /*36-bit statistics counter that collects the number of
1930 *valid TX unicast control frames.
1932 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1933 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1934 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1936 hw_stats->eth.tx_unicast += statistics;
1938 /*36-bit statistics counter that collects the number of
1939 *valid RX unicast control frames.
1941 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1942 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1943 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1945 hw_stats->eth.rx_unicast += statistics;
1947 /*36-bit statistics counter that collects the number of
1948 *valid TX multicast control frames.
1950 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1951 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1952 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1954 hw_stats->eth.tx_multicast += statistics;
1956 /*36-bit statistics counter that collects the number of
1957 *valid RX multicast control frames.
1959 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1960 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1961 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1963 hw_stats->eth.rx_multicast += statistics;
1965 /*36-bit statistics counter that collects the number of
1966 *valid TX broadcast control frames.
1968 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1969 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1970 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1972 hw_stats->eth.tx_broadcast += statistics;
1974 /*36-bit statistics counter that collects the number of
1975 *valid RX broadcast control frames.
1977 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1978 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1979 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1981 hw_stats->eth.rx_broadcast += statistics;
1983 /*36-bit statistics counter that collects the number of
1984 *valid TX PFC frames.
1986 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1987 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1988 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1991 /*36-bit statistics counter that collects the number of
1992 *valid RX PFC frames.
1994 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1995 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1996 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
2003 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2008 /*Bit [0]: Set this register to 1 to clear all TX statistics
2010 *The IP core clears this bit when all counters are cleared.
2011 *Bits [31:1]: Reserved.
2014 (*hw->f_mac_read)(hw,
2016 IPN3KE_10G_TX_STATS_CLR,
2020 (*hw->f_mac_write)(hw,
2022 IPN3KE_10G_TX_STATS_CLR,
2028 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2033 /*Bit [0]: Set this register to 1 to clear all RX statistics
2035 *The IP core clears this bit when all counters are cleared.
2036 *Bits [31:1]: Reserved
2039 (*hw->f_mac_read)(hw,
2041 IPN3KE_10G_RX_STATS_CLR,
2045 (*hw->f_mac_write)(hw,
2047 IPN3KE_10G_RX_STATS_CLR,
2053 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2055 uint16_t port_id = 0;
2058 struct rte_afu_device *afu_dev = NULL;
2059 struct ipn3ke_hw *hw = NULL;
2062 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2066 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2068 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2072 if (!afu_dev->shared.data) {
2073 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2077 hw = afu_dev->shared.data;
2079 ch = ethdev->data->name;
2081 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2092 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2097 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2098 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2099 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2100 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2101 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2102 } else if (hw->retimer.mac_type ==
2103 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2104 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2105 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2106 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2107 ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
2114 ipn3ke_rpst_stats_get
2115 (struct rte_eth_dev *ethdev, struct rte_eth_stats *stats)
2117 uint16_t port_id = 0;
2121 struct rte_afu_device *afu_dev = NULL;
2122 struct ipn3ke_hw *hw = NULL;
2123 struct ipn3ke_rpst_hw_port_stats hw_stats;
2126 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2130 IPN3KE_AFU_PMD_ERR("Address to return statistics is NULL!");
2134 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2136 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2140 if (!afu_dev->shared.data) {
2141 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2145 hw = afu_dev->shared.data;
2147 ch = ethdev->data->name;
2149 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2160 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2165 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2166 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2170 stats->ipackets = hw_stats.rx_size_64
2171 + hw_stats.rx_size_65_127
2172 + hw_stats.rx_size_128_255
2173 + hw_stats.rx_size_256_511
2174 + hw_stats.rx_size_512_1023
2175 + hw_stats.rx_size_1024_1518
2176 + hw_stats.rx_size_big
2177 + hw_stats.rx_undersize
2178 + hw_stats.rx_fragments
2179 + hw_stats.rx_oversize
2180 + hw_stats.rx_jabber;
2181 stats->opackets = hw_stats.tx_size_64
2182 + hw_stats.tx_size_65_127
2183 + hw_stats.tx_size_128_255
2184 + hw_stats.tx_size_256_511
2185 + hw_stats.tx_size_512_1023
2186 + hw_stats.tx_size_1024_1518
2187 + hw_stats.tx_size_1519_to_max;
2188 stats->ibytes = hw_stats.eth.rx_bytes;
2189 stats->obytes = hw_stats.eth.tx_bytes;
2191 stats->ierrors = hw_stats.eth.rx_discards
2192 + hw_stats.eth.rx_unknown_protocol;
2193 stats->oerrors = hw_stats.eth.tx_discards
2194 + hw_stats.eth.tx_errors;
2195 stats->rx_nombuf = 0;
2196 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
2197 stats->q_ipackets[i] = 0;
2198 stats->q_opackets[i] = 0;
2199 stats->q_ibytes[i] = 0;
2200 stats->q_obytes[i] = 0;
2201 stats->q_errors[i] = 0;
2204 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2214 ipn3ke_rpst_xstats_get
2215 (struct rte_eth_dev *ethdev, struct rte_eth_xstat *xstats, unsigned int n)
2217 uint16_t port_id = 0;
2220 unsigned int i, count, prio;
2221 struct rte_afu_device *afu_dev = NULL;
2222 struct ipn3ke_hw *hw = NULL;
2223 struct ipn3ke_rpst_hw_port_stats hw_stats;
2224 struct rte_eth_stats stats;
2230 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2234 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2236 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2240 if (!afu_dev->shared.data) {
2241 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2245 hw = afu_dev->shared.data;
2247 ch = ethdev->data->name;
2249 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2260 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2265 count = ipn3ke_rpst_xstats_calc_num();
2269 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2270 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2274 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2282 /* Get stats from ipn3ke_rpst_stats */
2283 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2284 xstats[count].value = *(uint64_t *)(((char *)&hw_stats.eth)
2285 + ipn3ke_rpst_stats_strings[i].offset);
2286 xstats[count].id = count;
2290 /* Get individiual stats from ipn3ke_rpst_hw_port */
2291 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2292 xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) +
2293 ipn3ke_rpst_hw_port_strings[i].offset);
2294 xstats[count].id = count;
2298 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2299 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2300 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2301 xstats[count].value =
2302 *(uint64_t *)(((char *)(&hw_stats)) +
2303 ipn3ke_rpst_rxq_prio_strings[i].offset +
2304 (sizeof(uint64_t) * prio));
2305 xstats[count].id = count;
2310 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2311 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2312 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2313 xstats[count].value =
2314 *(uint64_t *)(((char *)(&hw_stats)) +
2315 ipn3ke_rpst_txq_prio_strings[i].offset +
2316 (sizeof(uint64_t) * prio));
2317 xstats[count].id = count;
2326 ipn3ke_rpst_xstats_get_names
2327 (__rte_unused struct rte_eth_dev *dev,
2328 struct rte_eth_xstat_name *xstats_names,
2329 __rte_unused unsigned int limit)
2331 unsigned int count = 0;
2332 unsigned int i, prio;
2335 return ipn3ke_rpst_xstats_calc_num();
2337 /* Note: limit checked in rte_eth_xstats_names() */
2339 /* Get stats from ipn3ke_rpst_stats */
2340 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2341 snprintf(xstats_names[count].name,
2342 sizeof(xstats_names[count].name),
2344 ipn3ke_rpst_stats_strings[i].name);
2348 /* Get individiual stats from ipn3ke_rpst_hw_port */
2349 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2350 snprintf(xstats_names[count].name,
2351 sizeof(xstats_names[count].name),
2353 ipn3ke_rpst_hw_port_strings[i].name);
2357 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2358 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2359 for (prio = 0; prio < 8; prio++) {
2360 snprintf(xstats_names[count].name,
2361 sizeof(xstats_names[count].name),
2364 ipn3ke_rpst_rxq_prio_strings[i].name);
2369 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2370 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2371 for (prio = 0; prio < 8; prio++) {
2372 snprintf(xstats_names[count].name,
2373 sizeof(xstats_names[count].name),
2376 ipn3ke_rpst_txq_prio_strings[i].name);
2384 ipn3ke_update_link(struct rte_rawdev *rawdev,
2385 uint16_t port, struct rte_eth_link *link)
2387 uint64_t line_link_bitmap = 0;
2388 enum ifpga_rawdev_link_speed link_speed;
2390 rawdev->dev_ops->attr_get(rawdev,
2391 "LineSideLinkStatus",
2392 (uint64_t *)&line_link_bitmap);
2394 /* Parse the link status */
2395 if ((1 << port) & line_link_bitmap)
2396 link->link_status = 1;
2398 link->link_status = 0;
2400 IPN3KE_AFU_PMD_DEBUG("port is %d\n", port);
2401 IPN3KE_AFU_PMD_DEBUG("link->link_status is %d\n", link->link_status);
2403 rawdev->dev_ops->attr_get(rawdev,
2404 "LineSideLinkSpeed",
2405 (uint64_t *)&link_speed);
2406 switch (link_speed) {
2407 case IFPGA_RAWDEV_LINK_SPEED_10GB:
2408 link->link_speed = ETH_SPEED_NUM_10G;
2410 case IFPGA_RAWDEV_LINK_SPEED_25GB:
2411 link->link_speed = ETH_SPEED_NUM_25G;
2414 IPN3KE_AFU_PMD_ERR("Unknown link speed info %u", link_speed);
2420 * Set device link up.
2423 ipn3ke_rpst_dev_set_link_up(struct rte_eth_dev *dev)
2425 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2426 struct rte_eth_dev *pf;
2429 if (rpst->i40e_pf_eth) {
2430 ret = rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2431 pf = rpst->i40e_pf_eth;
2432 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2439 * Set device link down.
2442 ipn3ke_rpst_dev_set_link_down(struct rte_eth_dev *dev)
2444 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2445 struct rte_eth_dev *pf;
2448 if (rpst->i40e_pf_eth) {
2449 ret = rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2450 pf = rpst->i40e_pf_eth;
2451 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2458 ipn3ke_rpst_link_update(struct rte_eth_dev *ethdev,
2459 __rte_unused int wait_to_complete)
2461 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2462 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2463 struct rte_rawdev *rawdev;
2464 struct rte_eth_link link;
2465 struct rte_eth_dev *pf;
2467 memset(&link, 0, sizeof(link));
2469 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2470 link.link_autoneg = !(ethdev->data->dev_conf.link_speeds &
2471 ETH_LINK_SPEED_FIXED);
2473 rawdev = hw->rawdev;
2474 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2476 if (!rpst->ori_linfo.link_status &&
2478 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Up\n", rpst->port_id);
2479 rpst->ori_linfo.link_status = link.link_status;
2480 rpst->ori_linfo.link_speed = link.link_speed;
2482 rte_eth_linkstatus_set(ethdev, &link);
2484 if (rpst->i40e_pf_eth) {
2485 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Up\n",
2486 rpst->i40e_pf_eth_port_id);
2487 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2488 pf = rpst->i40e_pf_eth;
2489 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2491 } else if (rpst->ori_linfo.link_status &&
2492 !link.link_status) {
2493 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Down\n",
2495 rpst->ori_linfo.link_status = link.link_status;
2496 rpst->ori_linfo.link_speed = link.link_speed;
2498 rte_eth_linkstatus_set(ethdev, &link);
2500 if (rpst->i40e_pf_eth) {
2501 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Down\n",
2502 rpst->i40e_pf_eth_port_id);
2503 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2504 pf = rpst->i40e_pf_eth;
2505 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2513 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst)
2515 struct ipn3ke_hw *hw;
2516 struct rte_rawdev *rawdev;
2517 struct rte_eth_link link;
2518 struct rte_eth_dev *pf;
2525 memset(&link, 0, sizeof(link));
2527 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2528 link.link_autoneg = !(rpst->ethdev->data->dev_conf.link_speeds &
2529 ETH_LINK_SPEED_FIXED);
2531 rawdev = hw->rawdev;
2532 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2534 if (!rpst->ori_linfo.link_status &&
2536 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Up\n", rpst->port_id);
2537 rpst->ori_linfo.link_status = link.link_status;
2538 rpst->ori_linfo.link_speed = link.link_speed;
2540 rte_eth_linkstatus_set(rpst->ethdev, &link);
2542 if (rpst->i40e_pf_eth) {
2543 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Up\n",
2544 rpst->i40e_pf_eth_port_id);
2545 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2546 pf = rpst->i40e_pf_eth;
2547 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2549 } else if (rpst->ori_linfo.link_status &&
2550 !link.link_status) {
2551 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Down\n", rpst->port_id);
2552 rpst->ori_linfo.link_status = link.link_status;
2553 rpst->ori_linfo.link_speed = link.link_speed;
2555 rte_eth_linkstatus_set(rpst->ethdev, &link);
2557 if (rpst->i40e_pf_eth) {
2558 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Down\n",
2559 rpst->i40e_pf_eth_port_id);
2560 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2561 pf = rpst->i40e_pf_eth;
2562 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2570 ipn3ke_rpst_scan_handle_request(__rte_unused void *param)
2572 struct ipn3ke_rpst *rpst;
2579 TAILQ_FOREACH(rpst, &ipn3ke_rpst_list, next) {
2580 if (rpst->i40e_pf_eth &&
2581 rpst->ethdev->data->dev_started &&
2582 rpst->i40e_pf_eth->data->dev_started)
2583 ipn3ke_rpst_link_check(rpst);
2585 if (++num > SCAN_NUM)
2586 rte_delay_us(1 * MS);
2588 rte_delay_us(50 * MS);
2590 if (num == 0xffffff)
2598 ipn3ke_rpst_scan_check(void)
2602 if (ipn3ke_rpst_scan_num == 1) {
2603 ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
2606 ipn3ke_rpst_scan_handle_request, NULL);
2608 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2611 } else if (ipn3ke_rpst_scan_num == 0) {
2612 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2614 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2616 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2618 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2627 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2629 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2630 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2631 uint32_t rddata, val;
2633 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2634 /* Enable all unicast */
2635 (*hw->f_mac_read)(hw,
2637 IPN3KE_MAC_RX_FRAME_CONTROL,
2641 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2643 (*hw->f_mac_write)(hw,
2645 IPN3KE_MAC_RX_FRAME_CONTROL,
2654 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2656 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2657 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2658 uint32_t rddata, val;
2660 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2661 /* Disable all unicast */
2662 (*hw->f_mac_read)(hw,
2664 IPN3KE_MAC_RX_FRAME_CONTROL,
2668 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2670 (*hw->f_mac_write)(hw,
2672 IPN3KE_MAC_RX_FRAME_CONTROL,
2681 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2683 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2684 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2685 uint32_t rddata, val;
2687 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2688 /* Enable all unicast */
2689 (*hw->f_mac_read)(hw,
2691 IPN3KE_MAC_RX_FRAME_CONTROL,
2695 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2696 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2698 (*hw->f_mac_write)(hw,
2700 IPN3KE_MAC_RX_FRAME_CONTROL,
2709 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2711 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2712 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2713 uint32_t rddata, val;
2715 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2716 /* Disable all unicast */
2717 (*hw->f_mac_read)(hw,
2719 IPN3KE_MAC_RX_FRAME_CONTROL,
2723 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2724 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2726 (*hw->f_mac_write)(hw,
2728 IPN3KE_MAC_RX_FRAME_CONTROL,
2737 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2738 struct rte_ether_addr *mac_addr)
2740 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2741 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2744 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2745 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2749 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2750 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2752 /* Set mac address */
2753 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2754 (*hw->f_mac_write)(hw,
2756 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2759 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2760 (*hw->f_mac_write)(hw,
2762 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2771 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2774 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2775 struct rte_eth_dev_data *dev_data = ethdev->data;
2776 uint32_t frame_size = mtu + IPN3KE_ETH_OVERHEAD;
2778 /* check if mtu is within the allowed range */
2779 if (mtu < RTE_ETHER_MIN_MTU ||
2780 frame_size > IPN3KE_MAC_FRAME_SIZE_MAX)
2783 /* mtu setting is forbidden if port is start */
2784 /* make sure NIC port is stopped */
2785 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2786 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2787 "be stopped before configuration",
2788 rpst->i40e_pf_eth->data->port_id);
2791 /* mtu setting is forbidden if port is start */
2792 if (dev_data->dev_started) {
2793 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2794 "be stopped before configuration",
2799 if (frame_size > RTE_ETHER_MAX_LEN)
2800 dev_data->dev_conf.rxmode.offloads |=
2801 (uint64_t)(DEV_RX_OFFLOAD_JUMBO_FRAME);
2803 dev_data->dev_conf.rxmode.offloads &=
2804 (uint64_t)(~DEV_RX_OFFLOAD_JUMBO_FRAME);
2806 dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
2808 if (rpst->i40e_pf_eth) {
2809 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2812 rpst->i40e_pf_eth->data->mtu = mtu;
2819 ipn3ke_afu_filter_ctrl(struct rte_eth_dev *ethdev,
2820 enum rte_filter_type filter_type, enum rte_filter_op filter_op,
2824 struct ipn3ke_hw *hw;
2825 struct ipn3ke_rpst *rpst;
2830 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2831 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2834 switch (filter_type) {
2835 case RTE_ETH_FILTER_GENERIC:
2836 if (filter_op != RTE_ETH_FILTER_GET)
2838 *(const void **)arg = &ipn3ke_flow_ops;
2841 IPN3KE_AFU_PMD_WARN("Filter type (%d) not supported",
2846 else if (rpst->i40e_pf_eth)
2847 (*rpst->i40e_pf_eth->dev_ops->filter_ctrl)(ethdev,
2857 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2858 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2860 .dev_configure = ipn3ke_rpst_dev_configure,
2861 .dev_start = ipn3ke_rpst_dev_start,
2862 .dev_stop = ipn3ke_rpst_dev_stop,
2863 .dev_close = ipn3ke_rpst_dev_close,
2864 .dev_reset = ipn3ke_rpst_dev_reset,
2866 .stats_get = ipn3ke_rpst_stats_get,
2867 .xstats_get = ipn3ke_rpst_xstats_get,
2868 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2869 .stats_reset = ipn3ke_rpst_stats_reset,
2870 .xstats_reset = ipn3ke_rpst_stats_reset,
2872 .filter_ctrl = ipn3ke_afu_filter_ctrl,
2874 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2875 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2876 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2877 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2878 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2879 .rx_queue_release = ipn3ke_rpst_rx_queue_release,
2880 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2881 .tx_queue_release = ipn3ke_rpst_tx_queue_release,
2883 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2884 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2885 .link_update = ipn3ke_rpst_link_update,
2887 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2888 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2889 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2890 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2891 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2892 .mtu_set = ipn3ke_rpst_mtu_set,
2894 .tm_ops_get = ipn3ke_tm_ops_get,
2897 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2898 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2904 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2905 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2911 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2913 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2914 struct ipn3ke_rpst *representor_param =
2915 (struct ipn3ke_rpst *)init_params;
2917 if (representor_param->port_id >= representor_param->hw->port_num)
2920 if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
2923 rpst->ethdev = ethdev;
2924 rpst->switch_domain_id = representor_param->switch_domain_id;
2925 rpst->port_id = representor_param->port_id;
2926 rpst->hw = representor_param->hw;
2927 rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
2928 rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
2929 if (rpst->i40e_pf_eth)
2930 ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
2933 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2934 if (!ethdev->data->mac_addrs) {
2935 IPN3KE_AFU_PMD_ERR("Failed to "
2936 "allocated memory for storing mac address");
2940 if (rpst->hw->tm_hw_enable)
2941 ipn3ke_tm_init(rpst);
2943 /* Set representor device ops */
2944 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2946 /* No data-path, but need stub Rx/Tx functions to avoid crash
2947 * when testing with the likes of testpmd.
2949 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2950 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2952 ethdev->data->nb_rx_queues = 1;
2953 ethdev->data->nb_tx_queues = 1;
2955 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2958 if (!ethdev->data->mac_addrs) {
2959 IPN3KE_AFU_PMD_ERR("Failed to "
2960 "allocated memory for storing mac address");
2964 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
2966 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2967 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2968 ipn3ke_rpst_scan_num++;
2969 ipn3ke_rpst_scan_check();
2970 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2976 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2978 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2980 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2981 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2982 ipn3ke_rpst_scan_num--;
2983 ipn3ke_rpst_scan_check();
2984 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);