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 (rte_eal_process_type() != RTE_PROC_PRIMARY)
220 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
221 /* Disable the TX path */
222 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
224 /* Disable the RX path */
225 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
232 * Reset PF device only to re-initialize resources in PMD layer
235 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
237 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
238 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
240 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
241 /* Disable the TX path */
242 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
244 /* Disable the RX path */
245 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
252 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
253 __rte_unused uint16_t rx_queue_id)
259 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
260 __rte_unused uint16_t rx_queue_id)
266 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
267 __rte_unused uint16_t tx_queue_id)
273 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
274 __rte_unused uint16_t tx_queue_id)
280 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
281 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
282 __rte_unused unsigned int socket_id,
283 __rte_unused const struct rte_eth_rxconf *rx_conf,
284 __rte_unused struct rte_mempool *mp)
290 ipn3ke_rpst_rx_queue_release(__rte_unused void *rxq)
295 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
296 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
297 __rte_unused unsigned int socket_id,
298 __rte_unused const struct rte_eth_txconf *tx_conf)
304 ipn3ke_rpst_tx_queue_release(__rte_unused void *txq)
308 /* Statistics collected by each port, VSI, VEB, and S-channel */
309 struct ipn3ke_rpst_eth_stats {
310 uint64_t tx_bytes; /* gotc */
311 uint64_t tx_multicast; /* mptc */
312 uint64_t tx_broadcast; /* bptc */
313 uint64_t tx_unicast; /* uptc */
314 uint64_t tx_discards; /* tdpc */
315 uint64_t tx_errors; /* tepc */
316 uint64_t rx_bytes; /* gorc */
317 uint64_t rx_multicast; /* mprc */
318 uint64_t rx_broadcast; /* bprc */
319 uint64_t rx_unicast; /* uprc */
320 uint64_t rx_discards; /* rdpc */
321 uint64_t rx_unknown_protocol; /* rupp */
324 /* store statistics names and its offset in stats structure */
325 struct ipn3ke_rpst_xstats_name_offset {
326 char name[RTE_ETH_XSTATS_NAME_SIZE];
330 static const struct ipn3ke_rpst_xstats_name_offset
331 ipn3ke_rpst_stats_strings[] = {
332 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
334 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
336 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
338 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
340 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
342 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
344 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
346 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
348 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
349 rx_unknown_protocol)},
352 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
353 sizeof(ipn3ke_rpst_stats_strings[0]))
355 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
357 /* Statistics collected by the MAC */
358 struct ipn3ke_rpst_hw_port_stats {
359 /* eth stats collected by the port */
360 struct ipn3ke_rpst_eth_stats eth;
362 /* additional port specific stats */
363 uint64_t tx_dropped_link_down;
365 uint64_t illegal_bytes;
366 uint64_t error_bytes;
367 uint64_t mac_local_faults;
368 uint64_t mac_remote_faults;
369 uint64_t rx_length_errors;
370 uint64_t link_xon_rx;
371 uint64_t link_xoff_rx;
372 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
373 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
374 uint64_t link_xon_tx;
375 uint64_t link_xoff_tx;
376 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
377 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
378 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
380 uint64_t rx_size_65_127;
381 uint64_t rx_size_128_255;
382 uint64_t rx_size_256_511;
383 uint64_t rx_size_512_1023;
384 uint64_t rx_size_1024_1518;
385 uint64_t rx_size_big;
386 uint64_t rx_undersize;
387 uint64_t rx_fragments;
388 uint64_t rx_oversize;
391 uint64_t tx_size_65_127;
392 uint64_t tx_size_128_255;
393 uint64_t tx_size_256_511;
394 uint64_t tx_size_512_1023;
395 uint64_t tx_size_1024_1518;
396 uint64_t tx_size_1519_to_max;
397 uint64_t mac_short_packet_dropped;
398 uint64_t checksum_error;
399 /* flow director stats */
400 uint64_t fd_atr_match;
401 uint64_t fd_sb_match;
402 uint64_t fd_atr_tunnel_match;
403 uint32_t fd_atr_status;
404 uint32_t fd_sb_status;
406 uint32_t tx_lpi_status;
407 uint32_t rx_lpi_status;
408 uint64_t tx_lpi_count;
409 uint64_t rx_lpi_count;
412 static const struct ipn3ke_rpst_xstats_name_offset
413 ipn3ke_rpst_hw_port_strings[] = {
414 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
415 tx_dropped_link_down)},
416 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
418 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
420 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
422 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
424 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
426 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
428 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
430 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
432 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
434 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
436 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
438 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
440 {"rx_size_128_to_255_packets",
441 offsetof(struct ipn3ke_rpst_hw_port_stats,
443 {"rx_size_256_to_511_packets",
444 offsetof(struct ipn3ke_rpst_hw_port_stats,
446 {"rx_size_512_to_1023_packets",
447 offsetof(struct ipn3ke_rpst_hw_port_stats,
449 {"rx_size_1024_to_1518_packets",
450 offsetof(struct ipn3ke_rpst_hw_port_stats,
452 {"rx_size_1519_to_max_packets",
453 offsetof(struct ipn3ke_rpst_hw_port_stats,
455 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
457 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
459 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
460 mac_short_packet_dropped)},
461 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
463 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
465 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
467 {"tx_size_65_to_127_packets",
468 offsetof(struct ipn3ke_rpst_hw_port_stats,
470 {"tx_size_128_to_255_packets",
471 offsetof(struct ipn3ke_rpst_hw_port_stats,
473 {"tx_size_256_to_511_packets",
474 offsetof(struct ipn3ke_rpst_hw_port_stats,
476 {"tx_size_512_to_1023_packets",
477 offsetof(struct ipn3ke_rpst_hw_port_stats,
479 {"tx_size_1024_to_1518_packets",
480 offsetof(struct ipn3ke_rpst_hw_port_stats,
482 {"tx_size_1519_to_max_packets",
483 offsetof(struct ipn3ke_rpst_hw_port_stats,
484 tx_size_1519_to_max)},
485 {"rx_flow_director_atr_match_packets",
486 offsetof(struct ipn3ke_rpst_hw_port_stats,
488 {"rx_flow_director_sb_match_packets",
489 offsetof(struct ipn3ke_rpst_hw_port_stats,
491 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
493 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
495 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
497 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
501 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
502 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
504 static const struct ipn3ke_rpst_xstats_name_offset
505 ipn3ke_rpst_rxq_prio_strings[] = {
506 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
508 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
512 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
513 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
515 static const struct ipn3ke_rpst_xstats_name_offset
516 ipn3ke_rpst_txq_prio_strings[] = {
517 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
519 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
521 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
522 priority_xon_2_xoff)},
525 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
526 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
529 ipn3ke_rpst_xstats_calc_num(void)
531 return IPN3KE_RPST_ETH_XSTATS_CNT
532 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
533 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
534 * IPN3KE_RPST_PRIO_XSTATS_CNT)
535 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
536 * IPN3KE_RPST_PRIO_XSTATS_CNT);
540 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
543 uint32_t tmp = 0x00000001;
544 /* Bit[0]: Software can set this bit to the value of 1
545 * to reset all of the TX statistics registers at the same time.
546 * This bit is selfclearing.
548 (*hw->f_mac_write)(hw,
550 IPN3KE_25G_TX_STATISTICS_CONFIG,
554 while (tmp & 0x00000001) {
556 (*hw->f_mac_read)(hw,
558 IPN3KE_25G_TX_STATISTICS_CONFIG,
561 if (tmp & 0x00000001)
569 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
572 uint32_t tmp = 0x00000001;
573 /* Bit[0]: Software can set this bit to the value of 1
574 * to reset all of the RX statistics registers at the same time.
575 * This bit is selfclearing.
577 (*hw->f_mac_write)(hw,
579 IPN3KE_25G_RX_STATISTICS_CONFIG,
583 while (tmp & 0x00000001) {
585 (*hw->f_mac_read)(hw,
587 IPN3KE_25G_RX_STATISTICS_CONFIG,
590 if (tmp & 0x00000001)
598 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
603 /*Bit [0]: Set this register to 1 to clear all TX statistics
605 *The IP core clears this bit when all counters are cleared.
606 *Bits [31:1]: Reserved.
609 (*hw->f_mac_read)(hw,
611 IPN3KE_10G_TX_STATS_CLR,
615 (*hw->f_mac_write)(hw,
617 IPN3KE_10G_TX_STATS_CLR,
623 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
628 /*Bit [0]: Set this register to 1 to clear all RX statistics
630 *The IP core clears this bit when all counters are cleared.
631 *Bits [31:1]: Reserved
634 (*hw->f_mac_read)(hw,
636 IPN3KE_10G_RX_STATS_CLR,
640 (*hw->f_mac_write)(hw,
642 IPN3KE_10G_RX_STATS_CLR,
648 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
649 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
651 uint32_t statistics_lo = 0x00000000;
652 uint32_t statistics_hi = 0x00000000;
653 uint64_t statistics = 0x0000000000000000;
655 (*hw->f_mac_read)(hw,
661 (*hw->f_mac_read)(hw,
667 statistics += statistics_hi;
668 statistics = statistics << IPN3KE_REGISTER_WIDTH;
669 statistics += statistics_lo;
675 ipn3ke_rpst_read_25g_lineside_stats_registers
676 (struct ipn3ke_hw *hw,
678 struct ipn3ke_rpst_hw_port_stats *hw_stats)
683 memset(hw_stats, 0, sizeof(*hw_stats));
685 /*check Tx statistics is real time.
686 *if statistics has been paused, make it real time.
689 (*hw->f_mac_read)(hw,
691 IPN3KE_25G_TX_STATISTICS_CONFIG,
695 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
697 (*hw->f_mac_write)(hw,
699 IPN3KE_25G_TX_STATISTICS_CONFIG,
705 (*hw->f_mac_read)(hw,
707 IPN3KE_25G_TX_STATISTICS_STATUS,
710 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
712 (*hw->f_mac_read)(hw,
714 IPN3KE_25G_TX_STATISTICS_CONFIG,
718 (*hw->f_mac_write)(hw,
720 IPN3KE_25G_TX_STATISTICS_CONFIG,
725 /*check Rx statistics is real time.
726 *if statistics has been paused, make it real time.
729 (*hw->f_mac_read)(hw,
731 IPN3KE_25G_RX_STATISTICS_CONFIG,
734 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
736 (*hw->f_mac_write)(hw,
738 IPN3KE_25G_RX_STATISTICS_CONFIG,
744 (*hw->f_mac_read)(hw,
746 IPN3KE_25G_RX_STATISTICS_STATUS,
750 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
752 (*hw->f_mac_read)(hw,
754 IPN3KE_25G_RX_STATISTICS_CONFIG,
758 (*hw->f_mac_write)(hw,
760 IPN3KE_25G_RX_STATISTICS_CONFIG,
765 /* pause Tx counter to read the statistics */
767 (*hw->f_mac_read)(hw,
769 IPN3KE_25G_TX_STATISTICS_CONFIG,
773 (*hw->f_mac_write)(hw,
775 IPN3KE_25G_TX_STATISTICS_CONFIG,
779 /* pause Rx counter to read the statistics */
781 (*hw->f_mac_read)(hw,
783 IPN3KE_25G_RX_STATISTICS_CONFIG,
787 (*hw->f_mac_write)(hw,
789 IPN3KE_25G_RX_STATISTICS_CONFIG,
793 /*Number of transmitted frames less than 64 bytes
794 *and reporting a CRC error
796 statistics = ipn3ke_rpst_read_64bits_statistics_register(
797 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
798 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
800 hw_stats->eth.tx_errors += statistics;
801 hw_stats->crc_errors += statistics;
803 /*Number of transmitted oversized frames reporting a CRC error*/
804 statistics = ipn3ke_rpst_read_64bits_statistics_register(
805 IPN3KE_25G_CNTR_TX_JABBERS_LO,
806 IPN3KE_25G_CNTR_TX_JABBERS_HI,
808 hw_stats->eth.tx_errors += statistics;
809 hw_stats->crc_errors += statistics;
811 /* Number of transmitted packets with FCS errors */
812 statistics = ipn3ke_rpst_read_64bits_statistics_register(
813 IPN3KE_25G_CNTR_TX_FCS_LO,
814 IPN3KE_25G_CNTR_TX_FCS_HI,
816 hw_stats->eth.tx_errors += statistics;
817 hw_stats->checksum_error += statistics;
819 /*Number of transmitted frames with a frame of length at
820 *least 64 reporting a CRC error
822 statistics = ipn3ke_rpst_read_64bits_statistics_register(
823 IPN3KE_25G_CNTR_TX_CRCERR_LO,
824 IPN3KE_25G_CNTR_TX_CRCERR_HI,
826 hw_stats->eth.tx_errors += statistics;
827 hw_stats->crc_errors += statistics;
829 /*Number of errored multicast frames transmitted,
830 *excluding control frames
832 statistics = ipn3ke_rpst_read_64bits_statistics_register(
833 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
834 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
836 hw_stats->eth.tx_errors += statistics;
838 /*Number of errored broadcast frames transmitted,
839 *excluding control frames
841 statistics = ipn3ke_rpst_read_64bits_statistics_register(
842 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
843 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
845 hw_stats->eth.tx_errors += statistics;
847 /*Number of errored unicast frames transmitted,
848 *excluding control frames
850 statistics = ipn3ke_rpst_read_64bits_statistics_register(
851 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
852 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
854 hw_stats->eth.tx_errors += statistics;
856 /* Number of errored multicast control frames transmitted */
857 statistics = ipn3ke_rpst_read_64bits_statistics_register(
858 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
859 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
861 hw_stats->eth.tx_errors += statistics;
863 /* Number of errored broadcast control frames transmitted */
864 statistics = ipn3ke_rpst_read_64bits_statistics_register(
865 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
866 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
868 hw_stats->eth.tx_errors += statistics;
870 /* Number of errored unicast control frames transmitted */
871 statistics = ipn3ke_rpst_read_64bits_statistics_register(
872 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
873 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
875 hw_stats->eth.tx_errors += statistics;
877 /* Number of errored pause frames transmitted */
878 statistics = ipn3ke_rpst_read_64bits_statistics_register(
879 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
880 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
882 hw_stats->eth.tx_errors += statistics;
884 /*Number of 64-byte transmitted frames,
885 *including the CRC field but excluding the preamble
888 statistics = ipn3ke_rpst_read_64bits_statistics_register(
889 IPN3KE_25G_CNTR_TX_64B_LO,
890 IPN3KE_25G_CNTR_TX_64B_HI,
892 hw_stats->tx_size_64 += statistics;
894 /* Number of transmitted frames between 65 and 127 bytes */
895 statistics = ipn3ke_rpst_read_64bits_statistics_register(
896 IPN3KE_25G_CNTR_TX_65_127B_LO,
897 IPN3KE_25G_CNTR_TX_65_127B_HI,
899 hw_stats->tx_size_65_127 += statistics;
901 /* Number of transmitted frames between 128 and 255 bytes */
902 statistics = ipn3ke_rpst_read_64bits_statistics_register(
903 IPN3KE_25G_CNTR_TX_128_255B_LO,
904 IPN3KE_25G_CNTR_TX_128_255B_HI,
906 hw_stats->tx_size_128_255 += statistics;
908 /* Number of transmitted frames between 256 and 511 bytes */
909 statistics = ipn3ke_rpst_read_64bits_statistics_register(
910 IPN3KE_25G_CNTR_TX_256_511B_LO,
911 IPN3KE_25G_CNTR_TX_256_511B_HI,
913 hw_stats->tx_size_256_511 += statistics;
915 /* Number of transmitted frames between 512 and 1023 bytes */
916 statistics = ipn3ke_rpst_read_64bits_statistics_register(
917 IPN3KE_25G_CNTR_TX_512_1023B_LO,
918 IPN3KE_25G_CNTR_TX_512_1023B_HI,
920 hw_stats->tx_size_512_1023 += statistics;
922 /* Number of transmitted frames between 1024 and 1518 bytes */
923 statistics = ipn3ke_rpst_read_64bits_statistics_register(
924 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
925 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
927 hw_stats->tx_size_1024_1518 += statistics;
929 /*Number of transmitted frames of size between 1519 bytes
930 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
933 statistics = ipn3ke_rpst_read_64bits_statistics_register(
934 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
935 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
937 hw_stats->tx_size_1519_to_max += statistics;
939 /*Number of oversized frames (frames with more bytes than the
940 *number specified in the MAX_TX_SIZE_CONFIG register)
943 statistics = ipn3ke_rpst_read_64bits_statistics_register(
944 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
945 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
948 /*Number of valid multicast frames transmitted,
949 *excluding control frames
951 statistics = ipn3ke_rpst_read_64bits_statistics_register(
952 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
953 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
955 hw_stats->eth.tx_multicast += statistics;
957 /*Number of valid broadcast frames transmitted,
958 *excluding control frames
960 statistics = ipn3ke_rpst_read_64bits_statistics_register(
961 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
962 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
964 hw_stats->eth.tx_broadcast += statistics;
966 /*Number of valid unicast frames transmitted,
967 *excluding control frames
969 statistics = ipn3ke_rpst_read_64bits_statistics_register(
970 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
971 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
973 hw_stats->eth.tx_unicast += statistics;
975 /*Number of valid multicast frames transmitted,
976 *excluding data frames
978 statistics = ipn3ke_rpst_read_64bits_statistics_register(
979 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
980 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
982 hw_stats->eth.tx_multicast += statistics;
984 /*Number of valid broadcast frames transmitted,
985 *excluding data frames
987 statistics = ipn3ke_rpst_read_64bits_statistics_register(
988 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
989 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
991 hw_stats->eth.tx_broadcast += statistics;
993 /*Number of valid unicast frames transmitted,
994 *excluding data frames
996 statistics = ipn3ke_rpst_read_64bits_statistics_register(
997 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
998 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
1000 hw_stats->eth.tx_unicast += statistics;
1002 /* Number of valid pause frames transmitted */
1003 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1004 IPN3KE_25G_CNTR_TX_PAUSE_LO,
1005 IPN3KE_25G_CNTR_TX_PAUSE_HI,
1008 /*Number of transmitted runt packets. The IP core does not
1009 *transmit frames of length less than nine bytes.
1010 *The IP core pads frames of length nine bytes to 64 bytes to
1011 *extend them to 64 bytes. Therefore, this counter does not
1012 *increment in normal operating conditions.
1014 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1015 IPN3KE_25G_CNTR_TX_RUNT_LO,
1016 IPN3KE_25G_CNTR_TX_RUNT_HI,
1019 /*Number of transmitted payload bytes in frames with no FCS,
1020 *undersized, oversized, or payload length errors.
1021 *If VLAN detection is turned off for the TX MAC (bit[1]
1022 *of the TX_MAC_CONTROL register at offset 0x40A has
1023 *the value of 1), the IP core counts the VLAN header bytes
1024 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1025 *as payload bytes. This register is compliant with
1026 *the requirements for aOctetsTransmittedOK in section
1027 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1029 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1030 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1031 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1033 hw_stats->eth.tx_bytes += statistics;
1035 /*Number of transmitted bytes in frames with no FCS, undersized,
1036 *oversized, or payload length errors. This register is
1037 *compliant with the requirements for ifOutOctets in RFC3635
1038 *(Managed Objects for Ethernet-like Interface Types)
1039 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1040 *Management Information Base (RMON)).
1042 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1043 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1044 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1047 /*Number of received frames less than 64 bytes
1048 *and reporting a CRC error
1050 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1051 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1052 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1054 hw_stats->eth.rx_discards += statistics;
1055 hw_stats->crc_errors += statistics;
1056 hw_stats->rx_length_errors += statistics;
1058 /* Number of received oversized frames reporting a CRC error */
1059 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1060 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1061 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1063 hw_stats->eth.rx_discards += statistics;
1064 hw_stats->crc_errors += statistics;
1065 hw_stats->rx_length_errors += statistics;
1067 /*Number of received packets with FCS errors.
1068 *This register maintains a count of the number of pulses
1069 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1071 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1072 IPN3KE_25G_CNTR_RX_FCS_LO,
1073 IPN3KE_25G_CNTR_RX_FCS_HI,
1075 hw_stats->eth.rx_discards += statistics;
1076 hw_stats->checksum_error += statistics;
1078 /*Number of received frames with a frame of length at least 64
1081 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1082 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1083 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1085 hw_stats->eth.rx_discards += statistics;
1086 hw_stats->crc_errors += statistics;
1088 /*Number of errored multicast frames received,
1089 *excluding control frames
1091 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1092 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1093 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1095 hw_stats->eth.rx_discards += statistics;
1097 /*Number of errored broadcast frames received,
1098 *excluding control frames
1100 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1101 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1102 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1104 hw_stats->eth.rx_discards += statistics;
1106 /*Number of errored unicast frames received,
1107 *excluding control frames
1109 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1110 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1111 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1113 hw_stats->eth.rx_discards += statistics;
1115 /* Number of errored multicast control frames received */
1116 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1117 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1118 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1120 hw_stats->eth.rx_discards += statistics;
1122 /* Number of errored broadcast control frames received */
1123 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1124 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1125 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1127 hw_stats->eth.rx_discards += statistics;
1129 /* Number of errored unicast control frames received */
1130 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1131 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1132 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1134 hw_stats->eth.rx_discards += statistics;
1136 /* Number of errored pause frames received */
1137 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1138 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1139 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1141 hw_stats->eth.rx_discards += statistics;
1143 /*Number of 64-byte received frames,
1144 *including the CRC field but excluding the preamble
1147 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1148 IPN3KE_25G_CNTR_RX_64B_LO,
1149 IPN3KE_25G_CNTR_RX_64B_HI,
1151 hw_stats->rx_size_64 += statistics;
1153 /*Number of received frames between 65 and 127 bytes */
1154 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1155 IPN3KE_25G_CNTR_RX_65_127B_LO,
1156 IPN3KE_25G_CNTR_RX_65_127B_HI,
1158 hw_stats->rx_size_65_127 += statistics;
1160 /*Number of received frames between 128 and 255 bytes
1162 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1163 IPN3KE_25G_CNTR_RX_128_255B_LO,
1164 IPN3KE_25G_CNTR_RX_128_255B_HI,
1166 hw_stats->rx_size_128_255 += statistics;
1168 /*Number of received frames between 256 and 511 bytes
1170 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1171 IPN3KE_25G_CNTR_RX_256_511B_LO,
1172 IPN3KE_25G_CNTR_RX_256_511B_HI,
1174 hw_stats->rx_size_256_511 += statistics;
1176 /*Number of received frames between 512 and 1023 bytes
1178 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1179 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1180 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1182 hw_stats->rx_size_512_1023 += statistics;
1184 /*Number of received frames between 1024 and 1518 bytes
1186 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1187 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1188 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1190 hw_stats->rx_size_1024_1518 += statistics;
1192 /*Number of received frames of size between 1519 bytes
1193 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1196 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1197 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1198 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1200 hw_stats->rx_size_big += statistics;
1202 /*Number of oversized frames (frames with more bytes
1203 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1206 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1207 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1208 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1210 hw_stats->rx_jabber += statistics;
1212 /*Number of valid multicast frames received,
1213 *excluding control frames
1215 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1216 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1217 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1219 hw_stats->eth.rx_multicast += statistics;
1221 /*Number of valid broadcast frames received,
1222 *excluding control frames
1224 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1225 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1226 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1228 hw_stats->eth.rx_broadcast += statistics;
1230 /*Number of valid unicast frames received,
1231 *excluding control frames
1233 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1234 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1235 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1237 hw_stats->eth.rx_unicast += statistics;
1239 /*Number of valid multicast frames received,
1240 *excluding data frames
1242 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1243 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1244 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1246 hw_stats->eth.rx_multicast += statistics;
1248 /*Number of valid broadcast frames received,
1249 *excluding data frames
1251 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1252 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1253 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1255 hw_stats->eth.rx_broadcast += statistics;
1257 /*Number of valid unicast frames received,
1258 *excluding data frames
1260 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1261 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1262 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1264 hw_stats->eth.rx_unicast += statistics;
1266 /*Number of received pause frames, with or without error
1268 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1269 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1270 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1273 /*Number of received runt packets. A runt is a packet of size
1274 *less than 64 bytes but greater than eight bytes.
1275 *If a packet is eight bytes or smaller, it is considered
1276 *a decoding error and not a runt frame, and the IP core
1277 *does not flag it nor count it as a runt.
1279 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1280 IPN3KE_25G_CNTR_RX_RUNT_LO,
1281 IPN3KE_25G_CNTR_RX_RUNT_HI,
1284 /*Number of received payload bytes in frames with no FCS,
1285 *undersized, oversized, or payload length errors.
1286 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1287 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1288 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1289 *8 bytes for stacked VLAN) as payload bytes.
1290 *This register is compliant with the requirements for
1291 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1294 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1295 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1296 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1298 hw_stats->eth.rx_bytes += statistics;
1300 /*Number of received bytes in frames with no FCS, undersized,
1301 *oversized, or payload length errors.
1302 *This register is compliant with the requirements for
1303 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1304 *Interface Types) and RX etherStatsOctets in RFC2819
1305 *(Remote Network Monitoring Management Information Base
1308 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1309 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1310 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1313 /*resume Tx counter to real time
1316 (*hw->f_mac_read)(hw,
1318 IPN3KE_25G_TX_STATISTICS_CONFIG,
1322 (*hw->f_mac_write)(hw,
1324 IPN3KE_25G_TX_STATISTICS_CONFIG,
1328 /*resume Rx counter to real time
1331 (*hw->f_mac_read)(hw,
1333 IPN3KE_25G_RX_STATISTICS_CONFIG,
1337 (*hw->f_mac_write)(hw,
1339 IPN3KE_25G_RX_STATISTICS_CONFIG,
1347 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1350 uint32_t tmp = 0x00000001;
1351 /* Bit[0]: Software can set this bit to the value of 1
1352 * to reset all of the TX statistics registers at the same time.
1353 * This bit is selfclearing.
1355 (*hw->f_mac_write)(hw,
1357 IPN3KE_25G_TX_STATISTICS_CONFIG,
1361 while (tmp & 0x00000001) {
1363 (*hw->f_mac_read)(hw,
1365 IPN3KE_25G_TX_STATISTICS_CONFIG,
1368 if (tmp & 0x00000001)
1376 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1379 uint32_t tmp = 0x00000001;
1380 /* Bit[0]: Software can set this bit to the value of 1
1381 * to reset all of the RX statistics registers at the same time.
1382 * This bit is selfclearing.
1384 (*hw->f_mac_write)(hw,
1386 IPN3KE_25G_RX_STATISTICS_CONFIG,
1390 while (tmp & 0x00000001) {
1392 (*hw->f_mac_read)(hw,
1394 IPN3KE_25G_RX_STATISTICS_CONFIG,
1397 if (tmp & 0x00000001)
1405 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1406 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1408 uint32_t statistics_lo = 0x00000000;
1409 uint32_t statistics_hi = 0x00000000;
1410 uint64_t statistics = 0x0000000000000000;
1412 (*hw->f_mac_read)(hw,
1417 (*hw->f_mac_read)(hw,
1422 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1423 statistics += statistics_hi;
1424 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1425 statistics += statistics_lo;
1430 ipn3ke_rpst_read_10g_lineside_stats_registers
1431 (struct ipn3ke_hw *hw,
1433 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1434 struct rte_eth_stats *stats)
1436 uint64_t statistics = 0;
1438 memset(hw_stats, 0, sizeof(*hw_stats));
1439 memset(stats, 0, sizeof(*stats));
1441 /*36-bit statistics counter that collects the number of frames
1442 *that are successfully transmitted, including control frames.
1444 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1445 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1446 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1448 stats->opackets = statistics;
1450 /*36-bit statistics counter that collects the number of frames
1451 *that are successfully received, including control frames.
1453 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1454 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1455 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1457 stats->ipackets = statistics;
1459 /*36-bit statistics counter that collects the number of frames
1460 *transmitted with error, including control frames.
1462 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1463 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1464 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1466 stats->oerrors = statistics;
1467 hw_stats->eth.tx_errors = statistics;
1469 /*36-bit statistics counter that collects the number of frames
1470 *received with error, including control frames.
1472 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1473 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1474 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1476 stats->ierrors = statistics;
1477 hw_stats->eth.rx_discards = statistics;
1479 /*36-bit statistics counter that collects the number
1480 *of RX frames with CRC error.
1482 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1483 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1484 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1486 hw_stats->crc_errors = statistics;
1488 /*64-bit statistics counter that collects the payload length,
1489 *including the bytes in control frames.
1490 *The payload length is the number of data and padding bytes
1492 *If the tx_vlan_detection[0] register bit is set to 1,
1493 *the VLAN and stacked VLAN tags are counted as part of
1496 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1497 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1498 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1500 stats->obytes = statistics;
1501 hw_stats->eth.tx_bytes = statistics;
1503 /*64-bit statistics counter that collects the payload length,
1504 *including the bytes in control frames.
1505 *The payload length is the number of data and padding bytes
1507 *If the rx_vlan_detection[0] register bit is set to 1,
1508 *the VLAN and stacked VLAN tags are counted as part of
1511 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1512 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1513 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1515 stats->ibytes = statistics;
1516 hw_stats->eth.rx_bytes = statistics;
1518 /*36-bit statistics counter that collects the number of
1519 *valid pause frames transmitted.
1521 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1522 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1523 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1526 /*36-bit statistics counter that collects the number of
1527 *valid pause frames received.
1529 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1530 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1531 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1534 /*36-bit statistics counter that collects the number of frames
1535 *transmitted that are invalid and with error.
1537 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1538 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1539 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1542 /*36-bit statistics counter that collects the number of frames
1543 *received that are invalid and with error.
1545 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1546 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1547 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1550 /*36-bit statistics counter that collects the number of
1551 *good unicast frames transmitted,
1552 *excluding control frames.
1554 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1555 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1556 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1558 hw_stats->eth.tx_unicast = statistics;
1560 /*36-bit statistics counter that collects the number of
1561 *good unicast frames received,
1562 *excluding control frames.
1564 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1565 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1566 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1568 hw_stats->eth.rx_unicast = statistics;
1570 /*36-bit statistics counter that collects the number of
1571 *unicast frames transmitted with error,
1572 *excluding control frames.
1574 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1575 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1576 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1579 /*36-bit statistics counter that collects the number of
1580 *unicast frames received with error,
1581 *excluding control frames.
1583 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1584 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1585 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1588 /*36-bit statistics counter that collects the number of
1589 *good multicast frames transmitted,
1590 *excluding control frames.
1592 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1593 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1594 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1596 hw_stats->eth.tx_multicast = statistics;
1598 /*36-bit statistics counter that collects the number of
1599 *good multicast frames received,
1600 *excluding control frames.
1602 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1603 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1604 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1606 hw_stats->eth.rx_multicast = statistics;
1608 /*36-bit statistics counter that collects the number of
1609 *multicast frames transmitted with error,
1610 *excluding control frames.
1612 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1613 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1614 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1617 /*36-bit statistics counter that collects the number
1618 *of multicast frames received with error,
1619 *excluding control frames.
1621 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1622 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1623 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1626 /*36-bit statistics counter that collects the number of
1627 *good broadcast frames transmitted,
1628 *excluding control frames.
1630 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1631 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1632 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1634 hw_stats->eth.tx_broadcast = statistics;
1636 /*36-bit statistics counter that collects the number of
1637 *good broadcast frames received,
1638 *excluding control frames.
1640 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1641 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1642 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1644 hw_stats->eth.rx_broadcast = statistics;
1646 /*36-bit statistics counter that collects the number
1647 *of broadcast frames transmitted with error,
1648 *excluding control frames.
1650 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1651 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1652 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1655 /*36-bit statistics counter that collects the number of
1656 *broadcast frames received with error,
1657 *excluding control frames.
1659 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1660 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1661 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1664 /*64-bit statistics counter that collects the total number of
1665 *octets transmitted.
1666 *This count includes good, errored, and invalid frames.
1668 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1669 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1670 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1673 /*64-bit statistics counter that collects the total number of
1675 *This count includes good, errored, and invalid frames.
1677 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1678 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1679 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1682 /*36-bit statistics counter that collects the total number of
1683 *good, errored, and invalid frames transmitted.
1685 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1686 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1687 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1690 /*36-bit statistics counter that collects the total number of
1691 *good, errored, and invalid frames received.
1693 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1694 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1695 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1698 /*36-bit statistics counter that collects the number of
1699 *undersized TX frames.
1701 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1702 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1703 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1706 /*36-bit statistics counter that collects the number of
1707 *undersized RX frames.
1709 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1710 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1711 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1713 hw_stats->rx_undersize = statistics;
1715 /*36-bit statistics counter that collects the number of
1716 *TX frames whose length exceeds the maximum frame length
1719 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1720 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1721 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1724 /*36-bit statistics counter that collects the number of
1725 *RX frames whose length exceeds the maximum frame length
1728 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1729 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1730 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1732 hw_stats->rx_oversize = statistics;
1734 /*36-bit statistics counter that collects the number of
1736 *including the CRC field
1737 *but excluding the preamble and SFD bytes.
1738 *This count includes good, errored, and invalid frames.
1740 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1741 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1742 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1744 hw_stats->tx_size_64 = statistics;
1746 /*36-bit statistics counter that collects the number of
1748 *including the CRC field
1749 *but excluding the preamble and SFD bytes.
1750 *This count includes good, errored, and invalid frames.
1752 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1753 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1754 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1756 hw_stats->rx_size_64 = statistics;
1758 /*36-bit statistics counter that collects the number of
1759 *TX frames between the length of 65 and 127 bytes,
1760 *including the CRC field
1761 *but excluding the preamble and SFD bytes.
1762 *This count includes good, errored, and invalid frames.
1764 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1765 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1766 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1768 hw_stats->tx_size_65_127 = statistics;
1770 /*36-bit statistics counter that collects the number of
1771 *RX frames between the length of 65 and 127 bytes,
1772 *including the CRC field
1773 *but excluding the preamble and SFD bytes.
1774 *This count includes good, errored, and invalid frames.
1776 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1777 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1778 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1780 hw_stats->rx_size_65_127 = statistics;
1782 /*36-bit statistics counter that collects the number of
1783 *TX frames between the length of 128 and 255 bytes,
1784 *including the CRC field
1785 *but excluding the preamble and SFD bytes.
1786 *This count includes good, errored, and invalid frames.
1788 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1789 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1790 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1792 hw_stats->tx_size_128_255 = statistics;
1794 /*36-bit statistics counter that collects the number of
1795 *RX frames between the length of 128 and 255 bytes,
1796 *including the CRC field
1797 *but excluding the preamble and SFD bytes.
1798 *This count includes good, errored, and invalid frames.
1800 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1801 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1802 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1804 hw_stats->rx_size_128_255 = statistics;
1806 /*36-bit statistics counter that collects the number of
1807 *TX frames between the length of 256 and 511 bytes,
1808 *including the CRC field
1809 *but excluding the preamble and SFD bytes.
1810 *This count includes good, errored, and invalid frames.
1812 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1813 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1814 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1816 hw_stats->tx_size_256_511 = statistics;
1818 /*36-bit statistics counter that collects the number of
1819 *RX frames between the length of 256 and 511 bytes,
1820 *including the CRC field
1821 *but excluding the preamble and SFD bytes.
1822 *This count includes good, errored, and invalid frames.
1824 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1825 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1826 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1828 hw_stats->rx_size_256_511 = statistics;
1830 /*36-bit statistics counter that collects the number of
1831 *TX frames between the length of 512 and 1023 bytes,
1832 *including the CRC field
1833 *but excluding the preamble and SFD bytes.
1834 *This count includes good, errored, and invalid frames.
1836 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1837 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1838 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1840 hw_stats->tx_size_512_1023 = statistics;
1842 /*36-bit statistics counter that collects the number of
1843 *RX frames between the length of 512 and 1023 bytes,
1844 *including the CRC field
1845 *but excluding the preamble and SFD bytes.
1846 *This count includes good, errored, and invalid frames.
1848 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1849 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1850 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1852 hw_stats->rx_size_512_1023 = statistics;
1854 /*36-bit statistics counter that collects the number of
1855 *TX frames between the length of 1024 and 1518 bytes,
1856 *including the CRC field but
1857 *excluding the preamble and SFD bytes.
1858 *This count includes good, errored, and invalid frames.
1860 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1861 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1862 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1864 hw_stats->tx_size_1024_1518 = statistics;
1866 /*36-bit statistics counter that collects the number of
1867 *RX frames between the length of 1024 and 1518 bytes,
1868 *including the CRC field
1869 *but excluding the preamble and SFD bytes.
1870 *This count includes good, errored, and invalid frames.
1872 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1873 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1874 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1876 hw_stats->rx_size_1024_1518 = statistics;
1878 /*36-bit statistics counter that collects the number of
1879 *TX frames equal or more than the length of 1,519 bytes,
1880 *including the CRC field
1881 *but excluding the preamble and SFD bytes.
1882 *This count includes good, errored, and invalid frames.
1884 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1885 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1886 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1888 hw_stats->tx_size_1519_to_max = statistics;
1890 /*36-bit statistics counter that collects the number of
1891 *RX frames equal or more than the length of 1,519 bytes,
1892 *including the CRC field
1893 *but excluding the preamble and SFD bytes.
1894 *This count includes good,
1895 *errored, and invalid frames.
1897 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1898 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1899 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1901 hw_stats->rx_size_big = statistics;
1903 /*36-bit statistics counter that collects the total number of
1904 *RX frames with length less than 64 bytes and CRC error.
1905 *The MAC does not drop these frames.
1907 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1908 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1909 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1912 /*36-bit statistics counter that collects the number of
1913 *oversized RX frames with CRC error.
1914 *The MAC does not drop these frames.
1916 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1917 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1918 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1921 /*36-bit statistics counter that collects the number of
1922 *RX frames with CRC error,
1923 *whose length is between 64 and the maximum frame length
1924 *specified in the register.
1925 *The MAC does not drop these frames.
1927 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1928 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1929 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1932 /*36-bit statistics counter that collects the number of
1933 *valid TX unicast control frames.
1935 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1936 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1937 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1939 hw_stats->eth.tx_unicast += statistics;
1941 /*36-bit statistics counter that collects the number of
1942 *valid RX unicast control frames.
1944 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1945 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1946 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1948 hw_stats->eth.rx_unicast += statistics;
1950 /*36-bit statistics counter that collects the number of
1951 *valid TX multicast control frames.
1953 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1954 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1955 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1957 hw_stats->eth.tx_multicast += statistics;
1959 /*36-bit statistics counter that collects the number of
1960 *valid RX multicast control frames.
1962 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1963 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1964 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1966 hw_stats->eth.rx_multicast += statistics;
1968 /*36-bit statistics counter that collects the number of
1969 *valid TX broadcast control frames.
1971 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1972 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1973 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1975 hw_stats->eth.tx_broadcast += statistics;
1977 /*36-bit statistics counter that collects the number of
1978 *valid RX broadcast control frames.
1980 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1981 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1982 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1984 hw_stats->eth.rx_broadcast += statistics;
1986 /*36-bit statistics counter that collects the number of
1987 *valid TX PFC frames.
1989 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1990 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1991 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1994 /*36-bit statistics counter that collects the number of
1995 *valid RX PFC frames.
1997 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1998 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1999 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
2006 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2011 /*Bit [0]: Set this register to 1 to clear all TX statistics
2013 *The IP core clears this bit when all counters are cleared.
2014 *Bits [31:1]: Reserved.
2017 (*hw->f_mac_read)(hw,
2019 IPN3KE_10G_TX_STATS_CLR,
2023 (*hw->f_mac_write)(hw,
2025 IPN3KE_10G_TX_STATS_CLR,
2031 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2036 /*Bit [0]: Set this register to 1 to clear all RX statistics
2038 *The IP core clears this bit when all counters are cleared.
2039 *Bits [31:1]: Reserved
2042 (*hw->f_mac_read)(hw,
2044 IPN3KE_10G_RX_STATS_CLR,
2048 (*hw->f_mac_write)(hw,
2050 IPN3KE_10G_RX_STATS_CLR,
2056 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2058 uint16_t port_id = 0;
2061 struct rte_afu_device *afu_dev = NULL;
2062 struct ipn3ke_hw *hw = NULL;
2065 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2069 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2071 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2075 if (!afu_dev->shared.data) {
2076 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2080 hw = afu_dev->shared.data;
2082 ch = ethdev->data->name;
2084 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2095 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2100 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2101 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2102 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2103 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2104 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2105 } else if (hw->retimer.mac_type ==
2106 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2107 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2108 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2109 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2110 ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
2117 ipn3ke_rpst_stats_get
2118 (struct rte_eth_dev *ethdev, struct rte_eth_stats *stats)
2120 uint16_t port_id = 0;
2124 struct rte_afu_device *afu_dev = NULL;
2125 struct ipn3ke_hw *hw = NULL;
2126 struct ipn3ke_rpst_hw_port_stats hw_stats;
2129 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2133 IPN3KE_AFU_PMD_ERR("Address to return statistics is NULL!");
2137 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2139 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2143 if (!afu_dev->shared.data) {
2144 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2148 hw = afu_dev->shared.data;
2150 ch = ethdev->data->name;
2152 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2163 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2168 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2169 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2173 stats->ipackets = hw_stats.rx_size_64
2174 + hw_stats.rx_size_65_127
2175 + hw_stats.rx_size_128_255
2176 + hw_stats.rx_size_256_511
2177 + hw_stats.rx_size_512_1023
2178 + hw_stats.rx_size_1024_1518
2179 + hw_stats.rx_size_big
2180 + hw_stats.rx_undersize
2181 + hw_stats.rx_fragments
2182 + hw_stats.rx_oversize
2183 + hw_stats.rx_jabber;
2184 stats->opackets = hw_stats.tx_size_64
2185 + hw_stats.tx_size_65_127
2186 + hw_stats.tx_size_128_255
2187 + hw_stats.tx_size_256_511
2188 + hw_stats.tx_size_512_1023
2189 + hw_stats.tx_size_1024_1518
2190 + hw_stats.tx_size_1519_to_max;
2191 stats->ibytes = hw_stats.eth.rx_bytes;
2192 stats->obytes = hw_stats.eth.tx_bytes;
2194 stats->ierrors = hw_stats.eth.rx_discards
2195 + hw_stats.eth.rx_unknown_protocol;
2196 stats->oerrors = hw_stats.eth.tx_discards
2197 + hw_stats.eth.tx_errors;
2198 stats->rx_nombuf = 0;
2199 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
2200 stats->q_ipackets[i] = 0;
2201 stats->q_opackets[i] = 0;
2202 stats->q_ibytes[i] = 0;
2203 stats->q_obytes[i] = 0;
2204 stats->q_errors[i] = 0;
2207 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2217 ipn3ke_rpst_xstats_get
2218 (struct rte_eth_dev *ethdev, struct rte_eth_xstat *xstats, unsigned int n)
2220 uint16_t port_id = 0;
2223 unsigned int i, count, prio;
2224 struct rte_afu_device *afu_dev = NULL;
2225 struct ipn3ke_hw *hw = NULL;
2226 struct ipn3ke_rpst_hw_port_stats hw_stats;
2227 struct rte_eth_stats stats;
2233 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2237 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2239 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2243 if (!afu_dev->shared.data) {
2244 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2248 hw = afu_dev->shared.data;
2250 ch = ethdev->data->name;
2252 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2263 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2268 count = ipn3ke_rpst_xstats_calc_num();
2272 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2273 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2277 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2285 /* Get stats from ipn3ke_rpst_stats */
2286 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2287 xstats[count].value = *(uint64_t *)(((char *)&hw_stats.eth)
2288 + ipn3ke_rpst_stats_strings[i].offset);
2289 xstats[count].id = count;
2293 /* Get individiual stats from ipn3ke_rpst_hw_port */
2294 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2295 xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) +
2296 ipn3ke_rpst_hw_port_strings[i].offset);
2297 xstats[count].id = count;
2301 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2302 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2303 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2304 xstats[count].value =
2305 *(uint64_t *)(((char *)(&hw_stats)) +
2306 ipn3ke_rpst_rxq_prio_strings[i].offset +
2307 (sizeof(uint64_t) * prio));
2308 xstats[count].id = count;
2313 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2314 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2315 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2316 xstats[count].value =
2317 *(uint64_t *)(((char *)(&hw_stats)) +
2318 ipn3ke_rpst_txq_prio_strings[i].offset +
2319 (sizeof(uint64_t) * prio));
2320 xstats[count].id = count;
2329 ipn3ke_rpst_xstats_get_names
2330 (__rte_unused struct rte_eth_dev *dev,
2331 struct rte_eth_xstat_name *xstats_names,
2332 __rte_unused unsigned int limit)
2334 unsigned int count = 0;
2335 unsigned int i, prio;
2338 return ipn3ke_rpst_xstats_calc_num();
2340 /* Note: limit checked in rte_eth_xstats_names() */
2342 /* Get stats from ipn3ke_rpst_stats */
2343 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2344 snprintf(xstats_names[count].name,
2345 sizeof(xstats_names[count].name),
2347 ipn3ke_rpst_stats_strings[i].name);
2351 /* Get individiual stats from ipn3ke_rpst_hw_port */
2352 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2353 snprintf(xstats_names[count].name,
2354 sizeof(xstats_names[count].name),
2356 ipn3ke_rpst_hw_port_strings[i].name);
2360 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2361 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2362 for (prio = 0; prio < 8; prio++) {
2363 snprintf(xstats_names[count].name,
2364 sizeof(xstats_names[count].name),
2367 ipn3ke_rpst_rxq_prio_strings[i].name);
2372 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2373 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2374 for (prio = 0; prio < 8; prio++) {
2375 snprintf(xstats_names[count].name,
2376 sizeof(xstats_names[count].name),
2379 ipn3ke_rpst_txq_prio_strings[i].name);
2387 ipn3ke_update_link(struct rte_rawdev *rawdev,
2388 uint16_t port, struct rte_eth_link *link)
2390 uint64_t line_link_bitmap = 0;
2391 enum ifpga_rawdev_link_speed link_speed;
2393 rawdev->dev_ops->attr_get(rawdev,
2394 "LineSideLinkStatus",
2395 (uint64_t *)&line_link_bitmap);
2397 /* Parse the link status */
2398 if ((1 << port) & line_link_bitmap)
2399 link->link_status = 1;
2401 link->link_status = 0;
2403 IPN3KE_AFU_PMD_DEBUG("port is %d\n", port);
2404 IPN3KE_AFU_PMD_DEBUG("link->link_status is %d\n", link->link_status);
2406 rawdev->dev_ops->attr_get(rawdev,
2407 "LineSideLinkSpeed",
2408 (uint64_t *)&link_speed);
2409 switch (link_speed) {
2410 case IFPGA_RAWDEV_LINK_SPEED_10GB:
2411 link->link_speed = ETH_SPEED_NUM_10G;
2413 case IFPGA_RAWDEV_LINK_SPEED_25GB:
2414 link->link_speed = ETH_SPEED_NUM_25G;
2417 IPN3KE_AFU_PMD_ERR("Unknown link speed info %u", link_speed);
2423 * Set device link up.
2426 ipn3ke_rpst_dev_set_link_up(struct rte_eth_dev *dev)
2428 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2429 struct rte_eth_dev *pf;
2432 if (rpst->i40e_pf_eth) {
2433 ret = rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2434 pf = rpst->i40e_pf_eth;
2435 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2442 * Set device link down.
2445 ipn3ke_rpst_dev_set_link_down(struct rte_eth_dev *dev)
2447 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2448 struct rte_eth_dev *pf;
2451 if (rpst->i40e_pf_eth) {
2452 ret = rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2453 pf = rpst->i40e_pf_eth;
2454 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2461 ipn3ke_rpst_link_update(struct rte_eth_dev *ethdev,
2462 __rte_unused int wait_to_complete)
2464 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2465 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2466 struct rte_rawdev *rawdev;
2467 struct rte_eth_link link;
2468 struct rte_eth_dev *pf;
2470 memset(&link, 0, sizeof(link));
2472 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2473 link.link_autoneg = !(ethdev->data->dev_conf.link_speeds &
2474 ETH_LINK_SPEED_FIXED);
2476 rawdev = hw->rawdev;
2477 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2479 if (!rpst->ori_linfo.link_status &&
2481 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Up\n", rpst->port_id);
2482 rpst->ori_linfo.link_status = link.link_status;
2483 rpst->ori_linfo.link_speed = link.link_speed;
2485 rte_eth_linkstatus_set(ethdev, &link);
2487 if (rpst->i40e_pf_eth) {
2488 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Up\n",
2489 rpst->i40e_pf_eth_port_id);
2490 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2491 pf = rpst->i40e_pf_eth;
2492 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2494 } else if (rpst->ori_linfo.link_status &&
2495 !link.link_status) {
2496 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Down\n",
2498 rpst->ori_linfo.link_status = link.link_status;
2499 rpst->ori_linfo.link_speed = link.link_speed;
2501 rte_eth_linkstatus_set(ethdev, &link);
2503 if (rpst->i40e_pf_eth) {
2504 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Down\n",
2505 rpst->i40e_pf_eth_port_id);
2506 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2507 pf = rpst->i40e_pf_eth;
2508 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2516 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst)
2518 struct ipn3ke_hw *hw;
2519 struct rte_rawdev *rawdev;
2520 struct rte_eth_link link;
2521 struct rte_eth_dev *pf;
2528 memset(&link, 0, sizeof(link));
2530 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2531 link.link_autoneg = !(rpst->ethdev->data->dev_conf.link_speeds &
2532 ETH_LINK_SPEED_FIXED);
2534 rawdev = hw->rawdev;
2535 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2537 if (!rpst->ori_linfo.link_status &&
2539 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Up\n", rpst->port_id);
2540 rpst->ori_linfo.link_status = link.link_status;
2541 rpst->ori_linfo.link_speed = link.link_speed;
2543 rte_eth_linkstatus_set(rpst->ethdev, &link);
2545 if (rpst->i40e_pf_eth) {
2546 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Up\n",
2547 rpst->i40e_pf_eth_port_id);
2548 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2549 pf = rpst->i40e_pf_eth;
2550 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2552 } else if (rpst->ori_linfo.link_status &&
2553 !link.link_status) {
2554 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Down\n", rpst->port_id);
2555 rpst->ori_linfo.link_status = link.link_status;
2556 rpst->ori_linfo.link_speed = link.link_speed;
2558 rte_eth_linkstatus_set(rpst->ethdev, &link);
2560 if (rpst->i40e_pf_eth) {
2561 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Down\n",
2562 rpst->i40e_pf_eth_port_id);
2563 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2564 pf = rpst->i40e_pf_eth;
2565 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2573 ipn3ke_rpst_scan_handle_request(__rte_unused void *param)
2575 struct ipn3ke_rpst *rpst;
2582 TAILQ_FOREACH(rpst, &ipn3ke_rpst_list, next) {
2583 if (rpst->i40e_pf_eth &&
2584 rpst->ethdev->data->dev_started &&
2585 rpst->i40e_pf_eth->data->dev_started)
2586 ipn3ke_rpst_link_check(rpst);
2588 if (++num > SCAN_NUM)
2589 rte_delay_us(1 * MS);
2591 rte_delay_us(50 * MS);
2593 if (num == 0xffffff)
2601 ipn3ke_rpst_scan_check(void)
2605 if (ipn3ke_rpst_scan_num == 1) {
2606 ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
2609 ipn3ke_rpst_scan_handle_request, NULL);
2611 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2614 } else if (ipn3ke_rpst_scan_num == 0) {
2615 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2617 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2619 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2621 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2630 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2632 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2633 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2634 uint32_t rddata, val;
2636 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2637 /* Enable all unicast */
2638 (*hw->f_mac_read)(hw,
2640 IPN3KE_MAC_RX_FRAME_CONTROL,
2644 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2646 (*hw->f_mac_write)(hw,
2648 IPN3KE_MAC_RX_FRAME_CONTROL,
2657 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2659 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2660 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2661 uint32_t rddata, val;
2663 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2664 /* Disable all unicast */
2665 (*hw->f_mac_read)(hw,
2667 IPN3KE_MAC_RX_FRAME_CONTROL,
2671 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2673 (*hw->f_mac_write)(hw,
2675 IPN3KE_MAC_RX_FRAME_CONTROL,
2684 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2686 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2687 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2688 uint32_t rddata, val;
2690 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2691 /* Enable all unicast */
2692 (*hw->f_mac_read)(hw,
2694 IPN3KE_MAC_RX_FRAME_CONTROL,
2698 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2699 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2701 (*hw->f_mac_write)(hw,
2703 IPN3KE_MAC_RX_FRAME_CONTROL,
2712 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2714 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2715 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2716 uint32_t rddata, val;
2718 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2719 /* Disable all unicast */
2720 (*hw->f_mac_read)(hw,
2722 IPN3KE_MAC_RX_FRAME_CONTROL,
2726 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2727 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2729 (*hw->f_mac_write)(hw,
2731 IPN3KE_MAC_RX_FRAME_CONTROL,
2740 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2741 struct rte_ether_addr *mac_addr)
2743 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2744 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2747 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2748 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2752 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2753 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2755 /* Set mac address */
2756 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2757 (*hw->f_mac_write)(hw,
2759 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2762 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2763 (*hw->f_mac_write)(hw,
2765 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2774 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2777 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2778 struct rte_eth_dev_data *dev_data = ethdev->data;
2779 uint32_t frame_size = mtu + IPN3KE_ETH_OVERHEAD;
2781 /* check if mtu is within the allowed range */
2782 if (mtu < RTE_ETHER_MIN_MTU ||
2783 frame_size > IPN3KE_MAC_FRAME_SIZE_MAX)
2786 /* mtu setting is forbidden if port is start */
2787 /* make sure NIC port is stopped */
2788 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2789 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2790 "be stopped before configuration",
2791 rpst->i40e_pf_eth->data->port_id);
2794 /* mtu setting is forbidden if port is start */
2795 if (dev_data->dev_started) {
2796 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2797 "be stopped before configuration",
2802 if (frame_size > RTE_ETHER_MAX_LEN)
2803 dev_data->dev_conf.rxmode.offloads |=
2804 (uint64_t)(DEV_RX_OFFLOAD_JUMBO_FRAME);
2806 dev_data->dev_conf.rxmode.offloads &=
2807 (uint64_t)(~DEV_RX_OFFLOAD_JUMBO_FRAME);
2809 dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
2811 if (rpst->i40e_pf_eth) {
2812 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2815 rpst->i40e_pf_eth->data->mtu = mtu;
2822 ipn3ke_afu_filter_ctrl(struct rte_eth_dev *ethdev,
2823 enum rte_filter_type filter_type, enum rte_filter_op filter_op,
2827 struct ipn3ke_hw *hw;
2828 struct ipn3ke_rpst *rpst;
2833 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2834 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2837 switch (filter_type) {
2838 case RTE_ETH_FILTER_GENERIC:
2839 if (filter_op != RTE_ETH_FILTER_GET)
2841 *(const void **)arg = &ipn3ke_flow_ops;
2844 IPN3KE_AFU_PMD_WARN("Filter type (%d) not supported",
2849 else if (rpst->i40e_pf_eth)
2850 (*rpst->i40e_pf_eth->dev_ops->filter_ctrl)(ethdev,
2860 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2861 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2863 .dev_configure = ipn3ke_rpst_dev_configure,
2864 .dev_start = ipn3ke_rpst_dev_start,
2865 .dev_stop = ipn3ke_rpst_dev_stop,
2866 .dev_close = ipn3ke_rpst_dev_close,
2867 .dev_reset = ipn3ke_rpst_dev_reset,
2869 .stats_get = ipn3ke_rpst_stats_get,
2870 .xstats_get = ipn3ke_rpst_xstats_get,
2871 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2872 .stats_reset = ipn3ke_rpst_stats_reset,
2873 .xstats_reset = ipn3ke_rpst_stats_reset,
2875 .filter_ctrl = ipn3ke_afu_filter_ctrl,
2877 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2878 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2879 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2880 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2881 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2882 .rx_queue_release = ipn3ke_rpst_rx_queue_release,
2883 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2884 .tx_queue_release = ipn3ke_rpst_tx_queue_release,
2886 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2887 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2888 .link_update = ipn3ke_rpst_link_update,
2890 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2891 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2892 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2893 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2894 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2895 .mtu_set = ipn3ke_rpst_mtu_set,
2897 .tm_ops_get = ipn3ke_tm_ops_get,
2900 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2901 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2907 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2908 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2914 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2916 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2917 struct ipn3ke_rpst *representor_param =
2918 (struct ipn3ke_rpst *)init_params;
2920 if (representor_param->port_id >= representor_param->hw->port_num)
2923 if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
2926 rpst->ethdev = ethdev;
2927 rpst->switch_domain_id = representor_param->switch_domain_id;
2928 rpst->port_id = representor_param->port_id;
2929 rpst->hw = representor_param->hw;
2930 rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
2931 rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
2932 if (rpst->i40e_pf_eth)
2933 ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
2936 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2937 if (!ethdev->data->mac_addrs) {
2938 IPN3KE_AFU_PMD_ERR("Failed to "
2939 "allocated memory for storing mac address");
2943 if (rpst->hw->tm_hw_enable)
2944 ipn3ke_tm_init(rpst);
2946 /* Set representor device ops */
2947 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2949 /* No data-path, but need stub Rx/Tx functions to avoid crash
2950 * when testing with the likes of testpmd.
2952 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2953 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2955 ethdev->data->nb_rx_queues = 1;
2956 ethdev->data->nb_tx_queues = 1;
2958 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2961 if (!ethdev->data->mac_addrs) {
2962 IPN3KE_AFU_PMD_ERR("Failed to "
2963 "allocated memory for storing mac address");
2967 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
2969 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2970 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2971 ipn3ke_rpst_scan_num++;
2972 ipn3ke_rpst_scan_check();
2973 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2979 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2981 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2983 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2984 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2985 ipn3ke_rpst_scan_num--;
2986 ipn3ke_rpst_scan_check();
2987 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);