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;
107 ipn3ke_rpst_dev_configure(__rte_unused struct rte_eth_dev *dev)
113 ipn3ke_rpst_dev_start(struct rte_eth_dev *dev)
115 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
116 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
117 struct rte_rawdev *rawdev;
120 char attr_name[IPN3KE_RAWDEV_ATTR_LEN_MAX];
124 memset(attr_name, 0, sizeof(attr_name));
125 snprintf(attr_name, IPN3KE_RAWDEV_ATTR_LEN_MAX, "%s",
127 rawdev->dev_ops->attr_get(rawdev, attr_name, &base_mac);
128 rte_ether_addr_copy((struct rte_ether_addr *)&base_mac,
131 rte_ether_addr_copy(&rpst->mac_addr, &dev->data->mac_addrs[0]);
132 dev->data->mac_addrs->addr_bytes[RTE_ETHER_ADDR_LEN - 1] =
133 (uint8_t)rpst->port_id + 1;
135 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
136 /* Set mac address */
137 rte_memcpy(((char *)(&val)),
138 (char *)&dev->data->mac_addrs->addr_bytes[0],
140 (*hw->f_mac_write)(hw,
142 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
145 rte_memcpy(((char *)(&val)),
146 (char *)&dev->data->mac_addrs->addr_bytes[4],
148 (*hw->f_mac_write)(hw,
150 IPN3KE_MAC_PRIMARY_MAC_ADDR1,
154 /* Enable the TX path */
155 ipn3ke_xmac_tx_enable(hw, rpst->port_id, 0);
157 /* Disables source address override */
158 ipn3ke_xmac_smac_ovd_dis(hw, rpst->port_id, 0);
160 /* Enable the RX path */
161 ipn3ke_xmac_rx_enable(hw, rpst->port_id, 0);
163 /* Clear line side TX statistics counters */
164 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 0);
166 /* Clear line side RX statistics counters */
167 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 0);
169 /* Clear NIC side TX statistics counters */
170 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 1);
172 /* Clear NIC side RX statistics counters */
173 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 1);
174 } else if (hw->retimer.mac_type ==
175 IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
176 /* Clear line side TX statistics counters */
177 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 0);
179 /* Clear line side RX statistics counters */
180 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 0);
182 /* Clear NIC side TX statistics counters */
183 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 1);
185 /* Clear NIC side RX statistics counters */
186 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 1);
189 ipn3ke_rpst_link_update(dev, 0);
195 ipn3ke_rpst_dev_stop(struct rte_eth_dev *dev)
197 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
198 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
200 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
201 /* Disable the TX path */
202 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
204 /* Disable the RX path */
205 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
210 ipn3ke_rpst_dev_close(struct rte_eth_dev *dev)
212 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
213 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
215 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
216 /* Disable the TX path */
217 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
219 /* Disable the RX path */
220 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
225 * Reset PF device only to re-initialize resources in PMD layer
228 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
230 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
231 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
233 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
234 /* Disable the TX path */
235 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
237 /* Disable the RX path */
238 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
245 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
246 __rte_unused uint16_t rx_queue_id)
252 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
253 __rte_unused uint16_t rx_queue_id)
259 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
260 __rte_unused uint16_t tx_queue_id)
266 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
267 __rte_unused uint16_t tx_queue_id)
273 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
274 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
275 __rte_unused unsigned int socket_id,
276 __rte_unused const struct rte_eth_rxconf *rx_conf,
277 __rte_unused struct rte_mempool *mp)
283 ipn3ke_rpst_rx_queue_release(__rte_unused void *rxq)
288 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
289 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
290 __rte_unused unsigned int socket_id,
291 __rte_unused const struct rte_eth_txconf *tx_conf)
297 ipn3ke_rpst_tx_queue_release(__rte_unused void *txq)
301 /* Statistics collected by each port, VSI, VEB, and S-channel */
302 struct ipn3ke_rpst_eth_stats {
303 uint64_t tx_bytes; /* gotc */
304 uint64_t tx_multicast; /* mptc */
305 uint64_t tx_broadcast; /* bptc */
306 uint64_t tx_unicast; /* uptc */
307 uint64_t tx_discards; /* tdpc */
308 uint64_t tx_errors; /* tepc */
309 uint64_t rx_bytes; /* gorc */
310 uint64_t rx_multicast; /* mprc */
311 uint64_t rx_broadcast; /* bprc */
312 uint64_t rx_unicast; /* uprc */
313 uint64_t rx_discards; /* rdpc */
314 uint64_t rx_unknown_protocol; /* rupp */
317 /* store statistics names and its offset in stats structure */
318 struct ipn3ke_rpst_xstats_name_offset {
319 char name[RTE_ETH_XSTATS_NAME_SIZE];
323 static const struct ipn3ke_rpst_xstats_name_offset
324 ipn3ke_rpst_stats_strings[] = {
325 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
327 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
329 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
331 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
333 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
335 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
337 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
339 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
341 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
342 rx_unknown_protocol)},
345 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
346 sizeof(ipn3ke_rpst_stats_strings[0]))
348 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
350 /* Statistics collected by the MAC */
351 struct ipn3ke_rpst_hw_port_stats {
352 /* eth stats collected by the port */
353 struct ipn3ke_rpst_eth_stats eth;
355 /* additional port specific stats */
356 uint64_t tx_dropped_link_down;
358 uint64_t illegal_bytes;
359 uint64_t error_bytes;
360 uint64_t mac_local_faults;
361 uint64_t mac_remote_faults;
362 uint64_t rx_length_errors;
363 uint64_t link_xon_rx;
364 uint64_t link_xoff_rx;
365 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
366 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
367 uint64_t link_xon_tx;
368 uint64_t link_xoff_tx;
369 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
370 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
371 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
373 uint64_t rx_size_65_127;
374 uint64_t rx_size_128_255;
375 uint64_t rx_size_256_511;
376 uint64_t rx_size_512_1023;
377 uint64_t rx_size_1024_1518;
378 uint64_t rx_size_big;
379 uint64_t rx_undersize;
380 uint64_t rx_fragments;
381 uint64_t rx_oversize;
384 uint64_t tx_size_65_127;
385 uint64_t tx_size_128_255;
386 uint64_t tx_size_256_511;
387 uint64_t tx_size_512_1023;
388 uint64_t tx_size_1024_1518;
389 uint64_t tx_size_1519_to_max;
390 uint64_t mac_short_packet_dropped;
391 uint64_t checksum_error;
392 /* flow director stats */
393 uint64_t fd_atr_match;
394 uint64_t fd_sb_match;
395 uint64_t fd_atr_tunnel_match;
396 uint32_t fd_atr_status;
397 uint32_t fd_sb_status;
399 uint32_t tx_lpi_status;
400 uint32_t rx_lpi_status;
401 uint64_t tx_lpi_count;
402 uint64_t rx_lpi_count;
405 static const struct ipn3ke_rpst_xstats_name_offset
406 ipn3ke_rpst_hw_port_strings[] = {
407 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
408 tx_dropped_link_down)},
409 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
411 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
413 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
415 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
417 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
419 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
421 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
423 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
425 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
427 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
429 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
431 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
433 {"rx_size_128_to_255_packets",
434 offsetof(struct ipn3ke_rpst_hw_port_stats,
436 {"rx_size_256_to_511_packets",
437 offsetof(struct ipn3ke_rpst_hw_port_stats,
439 {"rx_size_512_to_1023_packets",
440 offsetof(struct ipn3ke_rpst_hw_port_stats,
442 {"rx_size_1024_to_1518_packets",
443 offsetof(struct ipn3ke_rpst_hw_port_stats,
445 {"rx_size_1519_to_max_packets",
446 offsetof(struct ipn3ke_rpst_hw_port_stats,
448 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
450 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
452 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
453 mac_short_packet_dropped)},
454 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
456 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
458 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
460 {"tx_size_65_to_127_packets",
461 offsetof(struct ipn3ke_rpst_hw_port_stats,
463 {"tx_size_128_to_255_packets",
464 offsetof(struct ipn3ke_rpst_hw_port_stats,
466 {"tx_size_256_to_511_packets",
467 offsetof(struct ipn3ke_rpst_hw_port_stats,
469 {"tx_size_512_to_1023_packets",
470 offsetof(struct ipn3ke_rpst_hw_port_stats,
472 {"tx_size_1024_to_1518_packets",
473 offsetof(struct ipn3ke_rpst_hw_port_stats,
475 {"tx_size_1519_to_max_packets",
476 offsetof(struct ipn3ke_rpst_hw_port_stats,
477 tx_size_1519_to_max)},
478 {"rx_flow_director_atr_match_packets",
479 offsetof(struct ipn3ke_rpst_hw_port_stats,
481 {"rx_flow_director_sb_match_packets",
482 offsetof(struct ipn3ke_rpst_hw_port_stats,
484 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
486 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
488 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
490 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
494 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
495 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
497 static const struct ipn3ke_rpst_xstats_name_offset
498 ipn3ke_rpst_rxq_prio_strings[] = {
499 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
501 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
505 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
506 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
508 static const struct ipn3ke_rpst_xstats_name_offset
509 ipn3ke_rpst_txq_prio_strings[] = {
510 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
512 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
514 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
515 priority_xon_2_xoff)},
518 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
519 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
522 ipn3ke_rpst_xstats_calc_num(void)
524 return IPN3KE_RPST_ETH_XSTATS_CNT
525 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
526 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
527 * IPN3KE_RPST_PRIO_XSTATS_CNT)
528 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
529 * IPN3KE_RPST_PRIO_XSTATS_CNT);
533 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
536 uint32_t tmp = 0x00000001;
537 /* Bit[0]: Software can set this bit to the value of 1
538 * to reset all of the TX statistics registers at the same time.
539 * This bit is selfclearing.
541 (*hw->f_mac_write)(hw,
543 IPN3KE_25G_TX_STATISTICS_CONFIG,
547 while (tmp & 0x00000001) {
549 (*hw->f_mac_read)(hw,
551 IPN3KE_25G_TX_STATISTICS_CONFIG,
554 if (tmp & 0x00000001)
562 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
565 uint32_t tmp = 0x00000001;
566 /* Bit[0]: Software can set this bit to the value of 1
567 * to reset all of the RX statistics registers at the same time.
568 * This bit is selfclearing.
570 (*hw->f_mac_write)(hw,
572 IPN3KE_25G_RX_STATISTICS_CONFIG,
576 while (tmp & 0x00000001) {
578 (*hw->f_mac_read)(hw,
580 IPN3KE_25G_RX_STATISTICS_CONFIG,
583 if (tmp & 0x00000001)
591 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
596 /*Bit [0]: Set this register to 1 to clear all TX statistics
598 *The IP core clears this bit when all counters are cleared.
599 *Bits [31:1]: Reserved.
602 (*hw->f_mac_read)(hw,
604 IPN3KE_10G_TX_STATS_CLR,
608 (*hw->f_mac_write)(hw,
610 IPN3KE_10G_TX_STATS_CLR,
616 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
621 /*Bit [0]: Set this register to 1 to clear all RX statistics
623 *The IP core clears this bit when all counters are cleared.
624 *Bits [31:1]: Reserved
627 (*hw->f_mac_read)(hw,
629 IPN3KE_10G_RX_STATS_CLR,
633 (*hw->f_mac_write)(hw,
635 IPN3KE_10G_RX_STATS_CLR,
641 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
642 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
644 uint32_t statistics_lo = 0x00000000;
645 uint32_t statistics_hi = 0x00000000;
646 uint64_t statistics = 0x0000000000000000;
648 (*hw->f_mac_read)(hw,
654 (*hw->f_mac_read)(hw,
660 statistics += statistics_hi;
661 statistics = statistics << IPN3KE_REGISTER_WIDTH;
662 statistics += statistics_lo;
668 ipn3ke_rpst_read_25g_lineside_stats_registers
669 (struct ipn3ke_hw *hw,
671 struct ipn3ke_rpst_hw_port_stats *hw_stats)
676 memset(hw_stats, 0, sizeof(*hw_stats));
678 /*check Tx statistics is real time.
679 *if statistics has been paused, make it real time.
682 (*hw->f_mac_read)(hw,
684 IPN3KE_25G_TX_STATISTICS_CONFIG,
688 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
690 (*hw->f_mac_write)(hw,
692 IPN3KE_25G_TX_STATISTICS_CONFIG,
698 (*hw->f_mac_read)(hw,
700 IPN3KE_25G_TX_STATISTICS_STATUS,
703 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
705 (*hw->f_mac_read)(hw,
707 IPN3KE_25G_TX_STATISTICS_CONFIG,
711 (*hw->f_mac_write)(hw,
713 IPN3KE_25G_TX_STATISTICS_CONFIG,
718 /*check Rx statistics is real time.
719 *if statistics has been paused, make it real time.
722 (*hw->f_mac_read)(hw,
724 IPN3KE_25G_RX_STATISTICS_CONFIG,
727 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
729 (*hw->f_mac_write)(hw,
731 IPN3KE_25G_RX_STATISTICS_CONFIG,
737 (*hw->f_mac_read)(hw,
739 IPN3KE_25G_RX_STATISTICS_STATUS,
743 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
745 (*hw->f_mac_read)(hw,
747 IPN3KE_25G_RX_STATISTICS_CONFIG,
751 (*hw->f_mac_write)(hw,
753 IPN3KE_25G_RX_STATISTICS_CONFIG,
758 /* pause Tx counter to read the statistics */
760 (*hw->f_mac_read)(hw,
762 IPN3KE_25G_TX_STATISTICS_CONFIG,
766 (*hw->f_mac_write)(hw,
768 IPN3KE_25G_TX_STATISTICS_CONFIG,
772 /* pause Rx counter to read the statistics */
774 (*hw->f_mac_read)(hw,
776 IPN3KE_25G_RX_STATISTICS_CONFIG,
780 (*hw->f_mac_write)(hw,
782 IPN3KE_25G_RX_STATISTICS_CONFIG,
786 /*Number of transmitted frames less than 64 bytes
787 *and reporting a CRC error
789 statistics = ipn3ke_rpst_read_64bits_statistics_register(
790 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
791 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
793 hw_stats->eth.tx_errors += statistics;
794 hw_stats->crc_errors += statistics;
796 /*Number of transmitted oversized frames reporting a CRC error*/
797 statistics = ipn3ke_rpst_read_64bits_statistics_register(
798 IPN3KE_25G_CNTR_TX_JABBERS_LO,
799 IPN3KE_25G_CNTR_TX_JABBERS_HI,
801 hw_stats->eth.tx_errors += statistics;
802 hw_stats->crc_errors += statistics;
804 /* Number of transmitted packets with FCS errors */
805 statistics = ipn3ke_rpst_read_64bits_statistics_register(
806 IPN3KE_25G_CNTR_TX_FCS_LO,
807 IPN3KE_25G_CNTR_TX_FCS_HI,
809 hw_stats->eth.tx_errors += statistics;
810 hw_stats->checksum_error += statistics;
812 /*Number of transmitted frames with a frame of length at
813 *least 64 reporting a CRC error
815 statistics = ipn3ke_rpst_read_64bits_statistics_register(
816 IPN3KE_25G_CNTR_TX_CRCERR_LO,
817 IPN3KE_25G_CNTR_TX_CRCERR_HI,
819 hw_stats->eth.tx_errors += statistics;
820 hw_stats->crc_errors += statistics;
822 /*Number of errored multicast frames transmitted,
823 *excluding control frames
825 statistics = ipn3ke_rpst_read_64bits_statistics_register(
826 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
827 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
829 hw_stats->eth.tx_errors += statistics;
831 /*Number of errored broadcast frames transmitted,
832 *excluding control frames
834 statistics = ipn3ke_rpst_read_64bits_statistics_register(
835 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
836 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
838 hw_stats->eth.tx_errors += statistics;
840 /*Number of errored unicast frames transmitted,
841 *excluding control frames
843 statistics = ipn3ke_rpst_read_64bits_statistics_register(
844 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
845 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
847 hw_stats->eth.tx_errors += statistics;
849 /* Number of errored multicast control frames transmitted */
850 statistics = ipn3ke_rpst_read_64bits_statistics_register(
851 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
852 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
854 hw_stats->eth.tx_errors += statistics;
856 /* Number of errored broadcast control frames transmitted */
857 statistics = ipn3ke_rpst_read_64bits_statistics_register(
858 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
859 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
861 hw_stats->eth.tx_errors += statistics;
863 /* Number of errored unicast control frames transmitted */
864 statistics = ipn3ke_rpst_read_64bits_statistics_register(
865 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
866 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
868 hw_stats->eth.tx_errors += statistics;
870 /* Number of errored pause frames transmitted */
871 statistics = ipn3ke_rpst_read_64bits_statistics_register(
872 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
873 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
875 hw_stats->eth.tx_errors += statistics;
877 /*Number of 64-byte transmitted frames,
878 *including the CRC field but excluding the preamble
881 statistics = ipn3ke_rpst_read_64bits_statistics_register(
882 IPN3KE_25G_CNTR_TX_64B_LO,
883 IPN3KE_25G_CNTR_TX_64B_HI,
885 hw_stats->tx_size_64 += statistics;
887 /* Number of transmitted frames between 65 and 127 bytes */
888 statistics = ipn3ke_rpst_read_64bits_statistics_register(
889 IPN3KE_25G_CNTR_TX_65_127B_LO,
890 IPN3KE_25G_CNTR_TX_65_127B_HI,
892 hw_stats->tx_size_65_127 += statistics;
894 /* Number of transmitted frames between 128 and 255 bytes */
895 statistics = ipn3ke_rpst_read_64bits_statistics_register(
896 IPN3KE_25G_CNTR_TX_128_255B_LO,
897 IPN3KE_25G_CNTR_TX_128_255B_HI,
899 hw_stats->tx_size_128_255 += statistics;
901 /* Number of transmitted frames between 256 and 511 bytes */
902 statistics = ipn3ke_rpst_read_64bits_statistics_register(
903 IPN3KE_25G_CNTR_TX_256_511B_LO,
904 IPN3KE_25G_CNTR_TX_256_511B_HI,
906 hw_stats->tx_size_256_511 += statistics;
908 /* Number of transmitted frames between 512 and 1023 bytes */
909 statistics = ipn3ke_rpst_read_64bits_statistics_register(
910 IPN3KE_25G_CNTR_TX_512_1023B_LO,
911 IPN3KE_25G_CNTR_TX_512_1023B_HI,
913 hw_stats->tx_size_512_1023 += statistics;
915 /* Number of transmitted frames between 1024 and 1518 bytes */
916 statistics = ipn3ke_rpst_read_64bits_statistics_register(
917 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
918 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
920 hw_stats->tx_size_1024_1518 += statistics;
922 /*Number of transmitted frames of size between 1519 bytes
923 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
926 statistics = ipn3ke_rpst_read_64bits_statistics_register(
927 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
928 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
930 hw_stats->tx_size_1519_to_max += statistics;
932 /*Number of oversized frames (frames with more bytes than the
933 *number specified in the MAX_TX_SIZE_CONFIG register)
936 statistics = ipn3ke_rpst_read_64bits_statistics_register(
937 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
938 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
941 /*Number of valid multicast frames transmitted,
942 *excluding control frames
944 statistics = ipn3ke_rpst_read_64bits_statistics_register(
945 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
946 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
948 hw_stats->eth.tx_multicast += statistics;
950 /*Number of valid broadcast frames transmitted,
951 *excluding control frames
953 statistics = ipn3ke_rpst_read_64bits_statistics_register(
954 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
955 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
957 hw_stats->eth.tx_broadcast += statistics;
959 /*Number of valid unicast frames transmitted,
960 *excluding control frames
962 statistics = ipn3ke_rpst_read_64bits_statistics_register(
963 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
964 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
966 hw_stats->eth.tx_unicast += statistics;
968 /*Number of valid multicast frames transmitted,
969 *excluding data frames
971 statistics = ipn3ke_rpst_read_64bits_statistics_register(
972 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
973 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
975 hw_stats->eth.tx_multicast += statistics;
977 /*Number of valid broadcast frames transmitted,
978 *excluding data frames
980 statistics = ipn3ke_rpst_read_64bits_statistics_register(
981 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
982 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
984 hw_stats->eth.tx_broadcast += statistics;
986 /*Number of valid unicast frames transmitted,
987 *excluding data frames
989 statistics = ipn3ke_rpst_read_64bits_statistics_register(
990 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
991 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
993 hw_stats->eth.tx_unicast += statistics;
995 /* Number of valid pause frames transmitted */
996 statistics = ipn3ke_rpst_read_64bits_statistics_register(
997 IPN3KE_25G_CNTR_TX_PAUSE_LO,
998 IPN3KE_25G_CNTR_TX_PAUSE_HI,
1001 /*Number of transmitted runt packets. The IP core does not
1002 *transmit frames of length less than nine bytes.
1003 *The IP core pads frames of length nine bytes to 64 bytes to
1004 *extend them to 64 bytes. Therefore, this counter does not
1005 *increment in normal operating conditions.
1007 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1008 IPN3KE_25G_CNTR_TX_RUNT_LO,
1009 IPN3KE_25G_CNTR_TX_RUNT_HI,
1012 /*Number of transmitted payload bytes in frames with no FCS,
1013 *undersized, oversized, or payload length errors.
1014 *If VLAN detection is turned off for the TX MAC (bit[1]
1015 *of the TX_MAC_CONTROL register at offset 0x40A has
1016 *the value of 1), the IP core counts the VLAN header bytes
1017 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1018 *as payload bytes. This register is compliant with
1019 *the requirements for aOctetsTransmittedOK in section
1020 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1022 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1023 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1024 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1026 hw_stats->eth.tx_bytes += statistics;
1028 /*Number of transmitted bytes in frames with no FCS, undersized,
1029 *oversized, or payload length errors. This register is
1030 *compliant with the requirements for ifOutOctets in RFC3635
1031 *(Managed Objects for Ethernet-like Interface Types)
1032 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1033 *Management Information Base (RMON)).
1035 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1036 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1037 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1040 /*Number of received frames less than 64 bytes
1041 *and reporting a CRC error
1043 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1044 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1045 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1047 hw_stats->eth.rx_discards += statistics;
1048 hw_stats->crc_errors += statistics;
1049 hw_stats->rx_length_errors += statistics;
1051 /* Number of received oversized frames reporting a CRC error */
1052 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1053 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1054 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1056 hw_stats->eth.rx_discards += statistics;
1057 hw_stats->crc_errors += statistics;
1058 hw_stats->rx_length_errors += statistics;
1060 /*Number of received packets with FCS errors.
1061 *This register maintains a count of the number of pulses
1062 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1064 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1065 IPN3KE_25G_CNTR_RX_FCS_LO,
1066 IPN3KE_25G_CNTR_RX_FCS_HI,
1068 hw_stats->eth.rx_discards += statistics;
1069 hw_stats->checksum_error += statistics;
1071 /*Number of received frames with a frame of length at least 64
1074 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1075 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1076 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1078 hw_stats->eth.rx_discards += statistics;
1079 hw_stats->crc_errors += statistics;
1081 /*Number of errored multicast frames received,
1082 *excluding control frames
1084 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1085 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1086 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1088 hw_stats->eth.rx_discards += statistics;
1090 /*Number of errored broadcast frames received,
1091 *excluding control frames
1093 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1094 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1095 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1097 hw_stats->eth.rx_discards += statistics;
1099 /*Number of errored unicast frames received,
1100 *excluding control frames
1102 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1103 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1104 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1106 hw_stats->eth.rx_discards += statistics;
1108 /* Number of errored multicast control frames received */
1109 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1110 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1111 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1113 hw_stats->eth.rx_discards += statistics;
1115 /* Number of errored broadcast control frames received */
1116 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1117 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1118 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1120 hw_stats->eth.rx_discards += statistics;
1122 /* Number of errored unicast control frames received */
1123 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1124 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1125 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1127 hw_stats->eth.rx_discards += statistics;
1129 /* Number of errored pause frames received */
1130 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1131 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1132 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1134 hw_stats->eth.rx_discards += statistics;
1136 /*Number of 64-byte received frames,
1137 *including the CRC field but excluding the preamble
1140 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1141 IPN3KE_25G_CNTR_RX_64B_LO,
1142 IPN3KE_25G_CNTR_RX_64B_HI,
1144 hw_stats->rx_size_64 += statistics;
1146 /*Number of received frames between 65 and 127 bytes */
1147 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1148 IPN3KE_25G_CNTR_RX_65_127B_LO,
1149 IPN3KE_25G_CNTR_RX_65_127B_HI,
1151 hw_stats->rx_size_65_127 += statistics;
1153 /*Number of received frames between 128 and 255 bytes
1155 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1156 IPN3KE_25G_CNTR_RX_128_255B_LO,
1157 IPN3KE_25G_CNTR_RX_128_255B_HI,
1159 hw_stats->rx_size_128_255 += statistics;
1161 /*Number of received frames between 256 and 511 bytes
1163 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1164 IPN3KE_25G_CNTR_RX_256_511B_LO,
1165 IPN3KE_25G_CNTR_RX_256_511B_HI,
1167 hw_stats->rx_size_256_511 += statistics;
1169 /*Number of received frames between 512 and 1023 bytes
1171 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1172 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1173 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1175 hw_stats->rx_size_512_1023 += statistics;
1177 /*Number of received frames between 1024 and 1518 bytes
1179 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1180 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1181 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1183 hw_stats->rx_size_1024_1518 += statistics;
1185 /*Number of received frames of size between 1519 bytes
1186 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1189 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1190 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1191 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1193 hw_stats->rx_size_big += statistics;
1195 /*Number of oversized frames (frames with more bytes
1196 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1199 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1200 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1201 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1203 hw_stats->rx_jabber += statistics;
1205 /*Number of valid multicast frames received,
1206 *excluding control frames
1208 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1209 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1210 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1212 hw_stats->eth.rx_multicast += statistics;
1214 /*Number of valid broadcast frames received,
1215 *excluding control frames
1217 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1218 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1219 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1221 hw_stats->eth.rx_broadcast += statistics;
1223 /*Number of valid unicast frames received,
1224 *excluding control frames
1226 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1227 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1228 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1230 hw_stats->eth.rx_unicast += statistics;
1232 /*Number of valid multicast frames received,
1233 *excluding data frames
1235 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1236 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1237 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1239 hw_stats->eth.rx_multicast += statistics;
1241 /*Number of valid broadcast frames received,
1242 *excluding data frames
1244 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1245 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1246 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1248 hw_stats->eth.rx_broadcast += statistics;
1250 /*Number of valid unicast frames received,
1251 *excluding data frames
1253 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1254 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1255 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1257 hw_stats->eth.rx_unicast += statistics;
1259 /*Number of received pause frames, with or without error
1261 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1262 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1263 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1266 /*Number of received runt packets. A runt is a packet of size
1267 *less than 64 bytes but greater than eight bytes.
1268 *If a packet is eight bytes or smaller, it is considered
1269 *a decoding error and not a runt frame, and the IP core
1270 *does not flag it nor count it as a runt.
1272 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1273 IPN3KE_25G_CNTR_RX_RUNT_LO,
1274 IPN3KE_25G_CNTR_RX_RUNT_HI,
1277 /*Number of received payload bytes in frames with no FCS,
1278 *undersized, oversized, or payload length errors.
1279 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1280 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1281 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1282 *8 bytes for stacked VLAN) as payload bytes.
1283 *This register is compliant with the requirements for
1284 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1287 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1288 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1289 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1291 hw_stats->eth.rx_bytes += statistics;
1293 /*Number of received bytes in frames with no FCS, undersized,
1294 *oversized, or payload length errors.
1295 *This register is compliant with the requirements for
1296 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1297 *Interface Types) and RX etherStatsOctets in RFC2819
1298 *(Remote Network Monitoring Management Information Base
1301 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1302 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1303 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1306 /*resume Tx counter to real time
1309 (*hw->f_mac_read)(hw,
1311 IPN3KE_25G_TX_STATISTICS_CONFIG,
1315 (*hw->f_mac_write)(hw,
1317 IPN3KE_25G_TX_STATISTICS_CONFIG,
1321 /*resume Rx counter to real time
1324 (*hw->f_mac_read)(hw,
1326 IPN3KE_25G_RX_STATISTICS_CONFIG,
1330 (*hw->f_mac_write)(hw,
1332 IPN3KE_25G_RX_STATISTICS_CONFIG,
1340 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1343 uint32_t tmp = 0x00000001;
1344 /* Bit[0]: Software can set this bit to the value of 1
1345 * to reset all of the TX statistics registers at the same time.
1346 * This bit is selfclearing.
1348 (*hw->f_mac_write)(hw,
1350 IPN3KE_25G_TX_STATISTICS_CONFIG,
1354 while (tmp & 0x00000001) {
1356 (*hw->f_mac_read)(hw,
1358 IPN3KE_25G_TX_STATISTICS_CONFIG,
1361 if (tmp & 0x00000001)
1369 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1372 uint32_t tmp = 0x00000001;
1373 /* Bit[0]: Software can set this bit to the value of 1
1374 * to reset all of the RX statistics registers at the same time.
1375 * This bit is selfclearing.
1377 (*hw->f_mac_write)(hw,
1379 IPN3KE_25G_RX_STATISTICS_CONFIG,
1383 while (tmp & 0x00000001) {
1385 (*hw->f_mac_read)(hw,
1387 IPN3KE_25G_RX_STATISTICS_CONFIG,
1390 if (tmp & 0x00000001)
1398 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1399 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1401 uint32_t statistics_lo = 0x00000000;
1402 uint32_t statistics_hi = 0x00000000;
1403 uint64_t statistics = 0x0000000000000000;
1405 (*hw->f_mac_read)(hw,
1410 (*hw->f_mac_read)(hw,
1415 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1416 statistics += statistics_hi;
1417 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1418 statistics += statistics_lo;
1423 ipn3ke_rpst_read_10g_lineside_stats_registers
1424 (struct ipn3ke_hw *hw,
1426 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1427 struct rte_eth_stats *stats)
1429 uint64_t statistics = 0;
1431 memset(hw_stats, 0, sizeof(*hw_stats));
1432 memset(stats, 0, sizeof(*stats));
1434 /*36-bit statistics counter that collects the number of frames
1435 *that are successfully transmitted, including control frames.
1437 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1438 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1439 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1441 stats->opackets = statistics;
1443 /*36-bit statistics counter that collects the number of frames
1444 *that are successfully received, including control frames.
1446 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1447 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1448 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1450 stats->ipackets = statistics;
1452 /*36-bit statistics counter that collects the number of frames
1453 *transmitted with error, including control frames.
1455 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1456 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1457 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1459 stats->oerrors = statistics;
1460 hw_stats->eth.tx_errors = statistics;
1462 /*36-bit statistics counter that collects the number of frames
1463 *received with error, including control frames.
1465 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1466 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1467 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1469 stats->ierrors = statistics;
1470 hw_stats->eth.rx_discards = statistics;
1472 /*36-bit statistics counter that collects the number
1473 *of RX frames with CRC error.
1475 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1476 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1477 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1479 hw_stats->crc_errors = statistics;
1481 /*64-bit statistics counter that collects the payload length,
1482 *including the bytes in control frames.
1483 *The payload length is the number of data and padding bytes
1485 *If the tx_vlan_detection[0] register bit is set to 1,
1486 *the VLAN and stacked VLAN tags are counted as part of
1489 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1490 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1491 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1493 stats->obytes = statistics;
1494 hw_stats->eth.tx_bytes = statistics;
1496 /*64-bit statistics counter that collects the payload length,
1497 *including the bytes in control frames.
1498 *The payload length is the number of data and padding bytes
1500 *If the rx_vlan_detection[0] register bit is set to 1,
1501 *the VLAN and stacked VLAN tags are counted as part of
1504 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1505 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1506 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1508 stats->ibytes = statistics;
1509 hw_stats->eth.rx_bytes = statistics;
1511 /*36-bit statistics counter that collects the number of
1512 *valid pause frames transmitted.
1514 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1515 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1516 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1519 /*36-bit statistics counter that collects the number of
1520 *valid pause frames received.
1522 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1523 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1524 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1527 /*36-bit statistics counter that collects the number of frames
1528 *transmitted that are invalid and with error.
1530 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1531 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1532 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1535 /*36-bit statistics counter that collects the number of frames
1536 *received that are invalid and with error.
1538 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1539 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1540 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1543 /*36-bit statistics counter that collects the number of
1544 *good unicast frames transmitted,
1545 *excluding control frames.
1547 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1548 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1549 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1551 hw_stats->eth.tx_unicast = statistics;
1553 /*36-bit statistics counter that collects the number of
1554 *good unicast frames received,
1555 *excluding control frames.
1557 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1558 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1559 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1561 hw_stats->eth.rx_unicast = statistics;
1563 /*36-bit statistics counter that collects the number of
1564 *unicast frames transmitted with error,
1565 *excluding control frames.
1567 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1568 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1569 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1572 /*36-bit statistics counter that collects the number of
1573 *unicast frames received with error,
1574 *excluding control frames.
1576 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1577 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1578 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1581 /*36-bit statistics counter that collects the number of
1582 *good multicast frames transmitted,
1583 *excluding control frames.
1585 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1586 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1587 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1589 hw_stats->eth.tx_multicast = statistics;
1591 /*36-bit statistics counter that collects the number of
1592 *good multicast frames received,
1593 *excluding control frames.
1595 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1596 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1597 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1599 hw_stats->eth.rx_multicast = statistics;
1601 /*36-bit statistics counter that collects the number of
1602 *multicast frames transmitted with error,
1603 *excluding control frames.
1605 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1606 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1607 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1610 /*36-bit statistics counter that collects the number
1611 *of multicast frames received with error,
1612 *excluding control frames.
1614 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1615 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1616 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1619 /*36-bit statistics counter that collects the number of
1620 *good broadcast frames transmitted,
1621 *excluding control frames.
1623 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1624 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1625 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1627 hw_stats->eth.tx_broadcast = statistics;
1629 /*36-bit statistics counter that collects the number of
1630 *good broadcast frames received,
1631 *excluding control frames.
1633 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1634 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1635 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1637 hw_stats->eth.rx_broadcast = statistics;
1639 /*36-bit statistics counter that collects the number
1640 *of broadcast frames transmitted with error,
1641 *excluding control frames.
1643 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1644 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1645 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1648 /*36-bit statistics counter that collects the number of
1649 *broadcast frames received with error,
1650 *excluding control frames.
1652 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1653 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1654 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1657 /*64-bit statistics counter that collects the total number of
1658 *octets transmitted.
1659 *This count includes good, errored, and invalid frames.
1661 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1662 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1663 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1666 /*64-bit statistics counter that collects the total number of
1668 *This count includes good, errored, and invalid frames.
1670 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1671 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1672 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1675 /*36-bit statistics counter that collects the total number of
1676 *good, errored, and invalid frames transmitted.
1678 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1679 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1680 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1683 /*36-bit statistics counter that collects the total number of
1684 *good, errored, and invalid frames received.
1686 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1687 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1688 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1691 /*36-bit statistics counter that collects the number of
1692 *undersized TX frames.
1694 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1695 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1696 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1699 /*36-bit statistics counter that collects the number of
1700 *undersized RX frames.
1702 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1703 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1704 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1706 hw_stats->rx_undersize = statistics;
1708 /*36-bit statistics counter that collects the number of
1709 *TX frames whose length exceeds the maximum frame length
1712 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1713 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1714 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1717 /*36-bit statistics counter that collects the number of
1718 *RX frames whose length exceeds the maximum frame length
1721 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1722 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1723 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1725 hw_stats->rx_oversize = statistics;
1727 /*36-bit statistics counter that collects the number of
1729 *including the CRC field
1730 *but excluding the preamble and SFD bytes.
1731 *This count includes good, errored, and invalid frames.
1733 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1734 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1735 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1737 hw_stats->tx_size_64 = statistics;
1739 /*36-bit statistics counter that collects the number of
1741 *including the CRC field
1742 *but excluding the preamble and SFD bytes.
1743 *This count includes good, errored, and invalid frames.
1745 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1746 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1747 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1749 hw_stats->rx_size_64 = statistics;
1751 /*36-bit statistics counter that collects the number of
1752 *TX frames between the length of 65 and 127 bytes,
1753 *including the CRC field
1754 *but excluding the preamble and SFD bytes.
1755 *This count includes good, errored, and invalid frames.
1757 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1758 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1759 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1761 hw_stats->tx_size_65_127 = statistics;
1763 /*36-bit statistics counter that collects the number of
1764 *RX frames between the length of 65 and 127 bytes,
1765 *including the CRC field
1766 *but excluding the preamble and SFD bytes.
1767 *This count includes good, errored, and invalid frames.
1769 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1770 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1771 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1773 hw_stats->rx_size_65_127 = statistics;
1775 /*36-bit statistics counter that collects the number of
1776 *TX frames between the length of 128 and 255 bytes,
1777 *including the CRC field
1778 *but excluding the preamble and SFD bytes.
1779 *This count includes good, errored, and invalid frames.
1781 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1782 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1783 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1785 hw_stats->tx_size_128_255 = statistics;
1787 /*36-bit statistics counter that collects the number of
1788 *RX frames between the length of 128 and 255 bytes,
1789 *including the CRC field
1790 *but excluding the preamble and SFD bytes.
1791 *This count includes good, errored, and invalid frames.
1793 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1794 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1795 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1797 hw_stats->rx_size_128_255 = statistics;
1799 /*36-bit statistics counter that collects the number of
1800 *TX frames between the length of 256 and 511 bytes,
1801 *including the CRC field
1802 *but excluding the preamble and SFD bytes.
1803 *This count includes good, errored, and invalid frames.
1805 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1806 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1807 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1809 hw_stats->tx_size_256_511 = statistics;
1811 /*36-bit statistics counter that collects the number of
1812 *RX frames between the length of 256 and 511 bytes,
1813 *including the CRC field
1814 *but excluding the preamble and SFD bytes.
1815 *This count includes good, errored, and invalid frames.
1817 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1818 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1819 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1821 hw_stats->rx_size_256_511 = statistics;
1823 /*36-bit statistics counter that collects the number of
1824 *TX frames between the length of 512 and 1023 bytes,
1825 *including the CRC field
1826 *but excluding the preamble and SFD bytes.
1827 *This count includes good, errored, and invalid frames.
1829 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1830 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1831 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1833 hw_stats->tx_size_512_1023 = statistics;
1835 /*36-bit statistics counter that collects the number of
1836 *RX frames between the length of 512 and 1023 bytes,
1837 *including the CRC field
1838 *but excluding the preamble and SFD bytes.
1839 *This count includes good, errored, and invalid frames.
1841 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1842 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1843 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1845 hw_stats->rx_size_512_1023 = statistics;
1847 /*36-bit statistics counter that collects the number of
1848 *TX frames between the length of 1024 and 1518 bytes,
1849 *including the CRC field but
1850 *excluding the preamble and SFD bytes.
1851 *This count includes good, errored, and invalid frames.
1853 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1854 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1855 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1857 hw_stats->tx_size_1024_1518 = statistics;
1859 /*36-bit statistics counter that collects the number of
1860 *RX frames between the length of 1024 and 1518 bytes,
1861 *including the CRC field
1862 *but excluding the preamble and SFD bytes.
1863 *This count includes good, errored, and invalid frames.
1865 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1866 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1867 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1869 hw_stats->rx_size_1024_1518 = statistics;
1871 /*36-bit statistics counter that collects the number of
1872 *TX frames equal or more than the length of 1,519 bytes,
1873 *including the CRC field
1874 *but excluding the preamble and SFD bytes.
1875 *This count includes good, errored, and invalid frames.
1877 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1878 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1879 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1881 hw_stats->tx_size_1519_to_max = statistics;
1883 /*36-bit statistics counter that collects the number of
1884 *RX frames equal or more than the length of 1,519 bytes,
1885 *including the CRC field
1886 *but excluding the preamble and SFD bytes.
1887 *This count includes good,
1888 *errored, and invalid frames.
1890 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1891 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1892 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1894 hw_stats->rx_size_big = statistics;
1896 /*36-bit statistics counter that collects the total number of
1897 *RX frames with length less than 64 bytes and CRC error.
1898 *The MAC does not drop these frames.
1900 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1901 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1902 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1905 /*36-bit statistics counter that collects the number of
1906 *oversized RX frames with CRC error.
1907 *The MAC does not drop these frames.
1909 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1910 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1911 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1914 /*36-bit statistics counter that collects the number of
1915 *RX frames with CRC error,
1916 *whose length is between 64 and the maximum frame length
1917 *specified in the register.
1918 *The MAC does not drop these frames.
1920 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1921 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1922 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1925 /*36-bit statistics counter that collects the number of
1926 *valid TX unicast control frames.
1928 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1929 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1930 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1932 hw_stats->eth.tx_unicast += statistics;
1934 /*36-bit statistics counter that collects the number of
1935 *valid RX unicast control frames.
1937 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1938 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1939 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1941 hw_stats->eth.rx_unicast += statistics;
1943 /*36-bit statistics counter that collects the number of
1944 *valid TX multicast control frames.
1946 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1947 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1948 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1950 hw_stats->eth.tx_multicast += statistics;
1952 /*36-bit statistics counter that collects the number of
1953 *valid RX multicast control frames.
1955 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1956 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1957 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1959 hw_stats->eth.rx_multicast += statistics;
1961 /*36-bit statistics counter that collects the number of
1962 *valid TX broadcast control frames.
1964 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1965 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1966 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1968 hw_stats->eth.tx_broadcast += statistics;
1970 /*36-bit statistics counter that collects the number of
1971 *valid RX broadcast control frames.
1973 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1974 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1975 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1977 hw_stats->eth.rx_broadcast += statistics;
1979 /*36-bit statistics counter that collects the number of
1980 *valid TX PFC frames.
1982 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1983 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1984 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1987 /*36-bit statistics counter that collects the number of
1988 *valid RX PFC frames.
1990 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1991 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1992 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1999 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2004 /*Bit [0]: Set this register to 1 to clear all TX statistics
2006 *The IP core clears this bit when all counters are cleared.
2007 *Bits [31:1]: Reserved.
2010 (*hw->f_mac_read)(hw,
2012 IPN3KE_10G_TX_STATS_CLR,
2016 (*hw->f_mac_write)(hw,
2018 IPN3KE_10G_TX_STATS_CLR,
2024 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2029 /*Bit [0]: Set this register to 1 to clear all RX statistics
2031 *The IP core clears this bit when all counters are cleared.
2032 *Bits [31:1]: Reserved
2035 (*hw->f_mac_read)(hw,
2037 IPN3KE_10G_RX_STATS_CLR,
2041 (*hw->f_mac_write)(hw,
2043 IPN3KE_10G_RX_STATS_CLR,
2049 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2051 uint16_t port_id = 0;
2054 struct rte_afu_device *afu_dev = NULL;
2055 struct ipn3ke_hw *hw = NULL;
2058 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2062 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2064 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2068 if (!afu_dev->shared.data) {
2069 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2073 hw = afu_dev->shared.data;
2075 ch = ethdev->data->name;
2077 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2088 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2093 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2094 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2095 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2096 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2097 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2098 } else if (hw->retimer.mac_type ==
2099 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2100 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2101 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2102 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2103 ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
2108 ipn3ke_rpst_stats_get
2109 (struct rte_eth_dev *ethdev, struct rte_eth_stats *stats)
2111 uint16_t port_id = 0;
2115 struct rte_afu_device *afu_dev = NULL;
2116 struct ipn3ke_hw *hw = NULL;
2117 struct ipn3ke_rpst_hw_port_stats hw_stats;
2120 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2124 IPN3KE_AFU_PMD_ERR("Address to return statistics is NULL!");
2128 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2130 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2134 if (!afu_dev->shared.data) {
2135 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2139 hw = afu_dev->shared.data;
2141 ch = ethdev->data->name;
2143 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2154 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2159 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2160 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2164 stats->ipackets = hw_stats.rx_size_64
2165 + hw_stats.rx_size_65_127
2166 + hw_stats.rx_size_128_255
2167 + hw_stats.rx_size_256_511
2168 + hw_stats.rx_size_512_1023
2169 + hw_stats.rx_size_1024_1518
2170 + hw_stats.rx_size_big
2171 + hw_stats.rx_undersize
2172 + hw_stats.rx_fragments
2173 + hw_stats.rx_oversize
2174 + hw_stats.rx_jabber;
2175 stats->opackets = hw_stats.tx_size_64
2176 + hw_stats.tx_size_65_127
2177 + hw_stats.tx_size_128_255
2178 + hw_stats.tx_size_256_511
2179 + hw_stats.tx_size_512_1023
2180 + hw_stats.tx_size_1024_1518
2181 + hw_stats.tx_size_1519_to_max;
2182 stats->ibytes = hw_stats.eth.rx_bytes;
2183 stats->obytes = hw_stats.eth.tx_bytes;
2185 stats->ierrors = hw_stats.eth.rx_discards
2186 + hw_stats.eth.rx_unknown_protocol;
2187 stats->oerrors = hw_stats.eth.tx_discards
2188 + hw_stats.eth.tx_errors;
2189 stats->rx_nombuf = 0;
2190 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
2191 stats->q_ipackets[i] = 0;
2192 stats->q_opackets[i] = 0;
2193 stats->q_ibytes[i] = 0;
2194 stats->q_obytes[i] = 0;
2195 stats->q_errors[i] = 0;
2198 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2208 ipn3ke_rpst_xstats_get
2209 (struct rte_eth_dev *ethdev, struct rte_eth_xstat *xstats, unsigned int n)
2211 uint16_t port_id = 0;
2214 unsigned int i, count, prio;
2215 struct rte_afu_device *afu_dev = NULL;
2216 struct ipn3ke_hw *hw = NULL;
2217 struct ipn3ke_rpst_hw_port_stats hw_stats;
2218 struct rte_eth_stats stats;
2224 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2228 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2230 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2234 if (!afu_dev->shared.data) {
2235 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2239 hw = afu_dev->shared.data;
2241 ch = ethdev->data->name;
2243 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2254 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2259 count = ipn3ke_rpst_xstats_calc_num();
2263 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2264 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2268 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2276 /* Get stats from ipn3ke_rpst_stats */
2277 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2278 xstats[count].value = *(uint64_t *)(((char *)&hw_stats.eth)
2279 + ipn3ke_rpst_stats_strings[i].offset);
2280 xstats[count].id = count;
2284 /* Get individiual stats from ipn3ke_rpst_hw_port */
2285 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2286 xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) +
2287 ipn3ke_rpst_hw_port_strings[i].offset);
2288 xstats[count].id = count;
2292 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2293 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2294 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2295 xstats[count].value =
2296 *(uint64_t *)(((char *)(&hw_stats)) +
2297 ipn3ke_rpst_rxq_prio_strings[i].offset +
2298 (sizeof(uint64_t) * prio));
2299 xstats[count].id = count;
2304 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2305 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2306 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2307 xstats[count].value =
2308 *(uint64_t *)(((char *)(&hw_stats)) +
2309 ipn3ke_rpst_txq_prio_strings[i].offset +
2310 (sizeof(uint64_t) * prio));
2311 xstats[count].id = count;
2320 ipn3ke_rpst_xstats_get_names
2321 (__rte_unused struct rte_eth_dev *dev,
2322 struct rte_eth_xstat_name *xstats_names,
2323 __rte_unused unsigned int limit)
2325 unsigned int count = 0;
2326 unsigned int i, prio;
2329 return ipn3ke_rpst_xstats_calc_num();
2331 /* Note: limit checked in rte_eth_xstats_names() */
2333 /* Get stats from ipn3ke_rpst_stats */
2334 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2335 snprintf(xstats_names[count].name,
2336 sizeof(xstats_names[count].name),
2338 ipn3ke_rpst_stats_strings[i].name);
2342 /* Get individiual stats from ipn3ke_rpst_hw_port */
2343 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2344 snprintf(xstats_names[count].name,
2345 sizeof(xstats_names[count].name),
2347 ipn3ke_rpst_hw_port_strings[i].name);
2351 /* Get individiual stats from ipn3ke_rpst_rxq_pri */
2352 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2353 for (prio = 0; prio < 8; prio++) {
2354 snprintf(xstats_names[count].name,
2355 sizeof(xstats_names[count].name),
2358 ipn3ke_rpst_rxq_prio_strings[i].name);
2363 /* Get individiual stats from ipn3ke_rpst_txq_prio */
2364 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2365 for (prio = 0; prio < 8; prio++) {
2366 snprintf(xstats_names[count].name,
2367 sizeof(xstats_names[count].name),
2370 ipn3ke_rpst_txq_prio_strings[i].name);
2378 ipn3ke_update_link(struct rte_rawdev *rawdev,
2379 uint16_t port, struct rte_eth_link *link)
2381 uint64_t line_link_bitmap = 0;
2382 enum ifpga_rawdev_link_speed link_speed;
2384 rawdev->dev_ops->attr_get(rawdev,
2385 "LineSideLinkStatus",
2386 (uint64_t *)&line_link_bitmap);
2388 /* Parse the link status */
2389 if ((1 << port) & line_link_bitmap)
2390 link->link_status = 1;
2392 link->link_status = 0;
2394 IPN3KE_AFU_PMD_DEBUG("port is %d\n", port);
2395 IPN3KE_AFU_PMD_DEBUG("link->link_status is %d\n", link->link_status);
2397 rawdev->dev_ops->attr_get(rawdev,
2398 "LineSideLinkSpeed",
2399 (uint64_t *)&link_speed);
2400 switch (link_speed) {
2401 case IFPGA_RAWDEV_LINK_SPEED_10GB:
2402 link->link_speed = ETH_SPEED_NUM_10G;
2404 case IFPGA_RAWDEV_LINK_SPEED_25GB:
2405 link->link_speed = ETH_SPEED_NUM_25G;
2408 IPN3KE_AFU_PMD_ERR("Unknown link speed info %u", link_speed);
2414 * Set device link up.
2417 ipn3ke_rpst_dev_set_link_up(struct rte_eth_dev *dev)
2419 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2420 struct rte_eth_dev *pf;
2423 if (rpst->i40e_pf_eth) {
2424 ret = rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2425 pf = rpst->i40e_pf_eth;
2426 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2433 * Set device link down.
2436 ipn3ke_rpst_dev_set_link_down(struct rte_eth_dev *dev)
2438 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2439 struct rte_eth_dev *pf;
2442 if (rpst->i40e_pf_eth) {
2443 ret = rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2444 pf = rpst->i40e_pf_eth;
2445 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2452 ipn3ke_rpst_link_update(struct rte_eth_dev *ethdev,
2453 __rte_unused int wait_to_complete)
2455 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2456 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2457 struct rte_rawdev *rawdev;
2458 struct rte_eth_link link;
2459 struct rte_eth_dev *pf;
2461 memset(&link, 0, sizeof(link));
2463 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2464 link.link_autoneg = !(ethdev->data->dev_conf.link_speeds &
2465 ETH_LINK_SPEED_FIXED);
2467 rawdev = hw->rawdev;
2468 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2470 if (!rpst->ori_linfo.link_status &&
2472 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Up\n", rpst->port_id);
2473 rpst->ori_linfo.link_status = link.link_status;
2474 rpst->ori_linfo.link_speed = link.link_speed;
2476 rte_eth_linkstatus_set(ethdev, &link);
2478 if (rpst->i40e_pf_eth) {
2479 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Up\n",
2480 rpst->i40e_pf_eth_port_id);
2481 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2482 pf = rpst->i40e_pf_eth;
2483 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2485 } else if (rpst->ori_linfo.link_status &&
2486 !link.link_status) {
2487 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Down\n",
2489 rpst->ori_linfo.link_status = link.link_status;
2490 rpst->ori_linfo.link_speed = link.link_speed;
2492 rte_eth_linkstatus_set(ethdev, &link);
2494 if (rpst->i40e_pf_eth) {
2495 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Down\n",
2496 rpst->i40e_pf_eth_port_id);
2497 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2498 pf = rpst->i40e_pf_eth;
2499 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2507 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst)
2509 struct ipn3ke_hw *hw;
2510 struct rte_rawdev *rawdev;
2511 struct rte_eth_link link;
2512 struct rte_eth_dev *pf;
2519 memset(&link, 0, sizeof(link));
2521 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2522 link.link_autoneg = !(rpst->ethdev->data->dev_conf.link_speeds &
2523 ETH_LINK_SPEED_FIXED);
2525 rawdev = hw->rawdev;
2526 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2528 if (!rpst->ori_linfo.link_status &&
2530 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Up\n", rpst->port_id);
2531 rpst->ori_linfo.link_status = link.link_status;
2532 rpst->ori_linfo.link_speed = link.link_speed;
2534 rte_eth_linkstatus_set(rpst->ethdev, &link);
2536 if (rpst->i40e_pf_eth) {
2537 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Up\n",
2538 rpst->i40e_pf_eth_port_id);
2539 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2540 pf = rpst->i40e_pf_eth;
2541 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2543 } else if (rpst->ori_linfo.link_status &&
2544 !link.link_status) {
2545 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Down\n", rpst->port_id);
2546 rpst->ori_linfo.link_status = link.link_status;
2547 rpst->ori_linfo.link_speed = link.link_speed;
2549 rte_eth_linkstatus_set(rpst->ethdev, &link);
2551 if (rpst->i40e_pf_eth) {
2552 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Down\n",
2553 rpst->i40e_pf_eth_port_id);
2554 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2555 pf = rpst->i40e_pf_eth;
2556 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2564 ipn3ke_rpst_scan_handle_request(__rte_unused void *param)
2566 struct ipn3ke_rpst *rpst;
2573 TAILQ_FOREACH(rpst, &ipn3ke_rpst_list, next) {
2574 if (rpst->i40e_pf_eth &&
2575 rpst->ethdev->data->dev_started &&
2576 rpst->i40e_pf_eth->data->dev_started)
2577 ipn3ke_rpst_link_check(rpst);
2579 if (++num > SCAN_NUM)
2580 rte_delay_us(1 * MS);
2582 rte_delay_us(50 * MS);
2584 if (num == 0xffffff)
2592 ipn3ke_rpst_scan_check(void)
2596 if (ipn3ke_rpst_scan_num == 1) {
2597 ret = pthread_create(&ipn3ke_rpst_scan_thread,
2599 ipn3ke_rpst_scan_handle_request, NULL);
2601 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2604 } else if (ipn3ke_rpst_scan_num == 0) {
2605 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2607 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2609 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2611 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2620 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2622 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2623 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2624 uint32_t rddata, val;
2626 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2627 /* Enable all unicast */
2628 (*hw->f_mac_read)(hw,
2630 IPN3KE_MAC_RX_FRAME_CONTROL,
2634 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2636 (*hw->f_mac_write)(hw,
2638 IPN3KE_MAC_RX_FRAME_CONTROL,
2645 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2647 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2648 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2649 uint32_t rddata, val;
2651 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2652 /* Disable all unicast */
2653 (*hw->f_mac_read)(hw,
2655 IPN3KE_MAC_RX_FRAME_CONTROL,
2659 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2661 (*hw->f_mac_write)(hw,
2663 IPN3KE_MAC_RX_FRAME_CONTROL,
2670 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2672 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2673 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2674 uint32_t rddata, val;
2676 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2677 /* Enable all unicast */
2678 (*hw->f_mac_read)(hw,
2680 IPN3KE_MAC_RX_FRAME_CONTROL,
2684 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2685 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2687 (*hw->f_mac_write)(hw,
2689 IPN3KE_MAC_RX_FRAME_CONTROL,
2696 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2698 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2699 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2700 uint32_t rddata, val;
2702 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2703 /* Disable all unicast */
2704 (*hw->f_mac_read)(hw,
2706 IPN3KE_MAC_RX_FRAME_CONTROL,
2710 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2711 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2713 (*hw->f_mac_write)(hw,
2715 IPN3KE_MAC_RX_FRAME_CONTROL,
2722 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2723 struct rte_ether_addr *mac_addr)
2725 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2726 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2729 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2730 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2734 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2735 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2737 /* Set mac address */
2738 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2739 (*hw->f_mac_write)(hw,
2741 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2744 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2745 (*hw->f_mac_write)(hw,
2747 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2756 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2759 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2760 struct rte_eth_dev_data *dev_data = ethdev->data;
2761 uint32_t frame_size = mtu + IPN3KE_ETH_OVERHEAD;
2763 /* check if mtu is within the allowed range */
2764 if (mtu < RTE_ETHER_MIN_MTU ||
2765 frame_size > IPN3KE_MAC_FRAME_SIZE_MAX)
2768 /* mtu setting is forbidden if port is start */
2769 /* make sure NIC port is stopped */
2770 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2771 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2772 "be stopped before configuration",
2773 rpst->i40e_pf_eth->data->port_id);
2776 /* mtu setting is forbidden if port is start */
2777 if (dev_data->dev_started) {
2778 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2779 "be stopped before configuration",
2784 if (frame_size > RTE_ETHER_MAX_LEN)
2785 dev_data->dev_conf.rxmode.offloads |=
2786 (uint64_t)(DEV_RX_OFFLOAD_JUMBO_FRAME);
2788 dev_data->dev_conf.rxmode.offloads &=
2789 (uint64_t)(~DEV_RX_OFFLOAD_JUMBO_FRAME);
2791 dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
2793 if (rpst->i40e_pf_eth) {
2794 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2797 rpst->i40e_pf_eth->data->mtu = mtu;
2804 ipn3ke_afu_filter_ctrl(struct rte_eth_dev *ethdev,
2805 enum rte_filter_type filter_type, enum rte_filter_op filter_op,
2809 struct ipn3ke_hw *hw;
2810 struct ipn3ke_rpst *rpst;
2815 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2816 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2819 switch (filter_type) {
2820 case RTE_ETH_FILTER_GENERIC:
2821 if (filter_op != RTE_ETH_FILTER_GET)
2823 *(const void **)arg = &ipn3ke_flow_ops;
2826 IPN3KE_AFU_PMD_WARN("Filter type (%d) not supported",
2831 else if (rpst->i40e_pf_eth)
2832 (*rpst->i40e_pf_eth->dev_ops->filter_ctrl)(ethdev,
2842 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2843 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2845 .dev_configure = ipn3ke_rpst_dev_configure,
2846 .dev_start = ipn3ke_rpst_dev_start,
2847 .dev_stop = ipn3ke_rpst_dev_stop,
2848 .dev_close = ipn3ke_rpst_dev_close,
2849 .dev_reset = ipn3ke_rpst_dev_reset,
2851 .stats_get = ipn3ke_rpst_stats_get,
2852 .xstats_get = ipn3ke_rpst_xstats_get,
2853 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2854 .stats_reset = ipn3ke_rpst_stats_reset,
2855 .xstats_reset = ipn3ke_rpst_stats_reset,
2857 .filter_ctrl = ipn3ke_afu_filter_ctrl,
2859 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2860 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2861 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2862 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2863 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2864 .rx_queue_release = ipn3ke_rpst_rx_queue_release,
2865 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2866 .tx_queue_release = ipn3ke_rpst_tx_queue_release,
2868 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2869 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2870 .link_update = ipn3ke_rpst_link_update,
2872 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2873 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2874 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2875 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2876 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2877 .mtu_set = ipn3ke_rpst_mtu_set,
2879 .tm_ops_get = ipn3ke_tm_ops_get,
2882 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2883 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2889 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2890 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2896 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2898 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2899 struct ipn3ke_rpst *representor_param =
2900 (struct ipn3ke_rpst *)init_params;
2902 if (representor_param->port_id >= representor_param->hw->port_num)
2905 rpst->ethdev = ethdev;
2906 rpst->switch_domain_id = representor_param->switch_domain_id;
2907 rpst->port_id = representor_param->port_id;
2908 rpst->hw = representor_param->hw;
2909 rpst->i40e_pf_eth = NULL;
2910 rpst->i40e_pf_eth_port_id = 0xFFFF;
2912 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2913 if (!ethdev->data->mac_addrs) {
2914 IPN3KE_AFU_PMD_ERR("Failed to "
2915 "allocated memory for storing mac address");
2919 if (rpst->hw->tm_hw_enable)
2920 ipn3ke_tm_init(rpst);
2922 /* Set representor device ops */
2923 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2925 /* No data-path, but need stub Rx/Tx functions to avoid crash
2926 * when testing with the likes of testpmd.
2928 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2929 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2931 ethdev->data->nb_rx_queues = 1;
2932 ethdev->data->nb_tx_queues = 1;
2934 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2937 if (!ethdev->data->mac_addrs) {
2938 IPN3KE_AFU_PMD_ERR("Failed to "
2939 "allocated memory for storing mac address");
2943 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
2945 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2946 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2947 ipn3ke_rpst_scan_num++;
2948 ipn3ke_rpst_scan_check();
2949 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2955 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2957 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2959 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2960 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2961 ipn3ke_rpst_scan_num--;
2962 ipn3ke_rpst_scan_check();
2963 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);