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 <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) ?
53 RTE_ETH_LINK_SPEED_10G :
54 ((hw->retimer.mac_type ==
55 IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) ?
56 RTE_ETH_LINK_SPEED_25G :
57 RTE_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 RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
71 RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
72 RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
73 RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
74 RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
75 RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
76 RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
77 RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
79 dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
80 dev_info->tx_offload_capa =
81 RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
82 RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
83 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
84 RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
85 RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
86 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
87 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
88 RTE_ETH_TX_OFFLOAD_TCP_TSO |
89 RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
90 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
91 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
92 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
93 RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
94 dev_info->tx_queue_offload_capa;
97 RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
98 RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
99 dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
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);
214 ipn3ke_rpst_dev_close(struct rte_eth_dev *dev)
216 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
217 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
219 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
222 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
223 /* Disable the TX path */
224 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
226 /* Disable the RX path */
227 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
234 * Reset PF device only to re-initialize resources in PMD layer
237 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
239 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
240 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
242 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
243 /* Disable the TX path */
244 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
246 /* Disable the RX path */
247 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
254 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
255 __rte_unused uint16_t rx_queue_id)
261 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
262 __rte_unused uint16_t rx_queue_id)
268 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
269 __rte_unused uint16_t tx_queue_id)
275 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
276 __rte_unused uint16_t tx_queue_id)
282 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
283 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
284 __rte_unused unsigned int socket_id,
285 __rte_unused const struct rte_eth_rxconf *rx_conf,
286 __rte_unused struct rte_mempool *mp)
292 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
293 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
294 __rte_unused unsigned int socket_id,
295 __rte_unused const struct rte_eth_txconf *tx_conf)
300 /* Statistics collected by each port, VSI, VEB, and S-channel */
301 struct ipn3ke_rpst_eth_stats {
302 uint64_t tx_bytes; /* gotc */
303 uint64_t tx_multicast; /* mptc */
304 uint64_t tx_broadcast; /* bptc */
305 uint64_t tx_unicast; /* uptc */
306 uint64_t tx_discards; /* tdpc */
307 uint64_t tx_errors; /* tepc */
308 uint64_t rx_bytes; /* gorc */
309 uint64_t rx_multicast; /* mprc */
310 uint64_t rx_broadcast; /* bprc */
311 uint64_t rx_unicast; /* uprc */
312 uint64_t rx_discards; /* rdpc */
313 uint64_t rx_unknown_protocol; /* rupp */
316 /* store statistics names and its offset in stats structure */
317 struct ipn3ke_rpst_xstats_name_offset {
318 char name[RTE_ETH_XSTATS_NAME_SIZE];
322 static const struct ipn3ke_rpst_xstats_name_offset
323 ipn3ke_rpst_stats_strings[] = {
324 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
326 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
328 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
330 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
332 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
334 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
336 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
338 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
340 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
341 rx_unknown_protocol)},
344 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
345 sizeof(ipn3ke_rpst_stats_strings[0]))
347 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
349 /* Statistics collected by the MAC */
350 struct ipn3ke_rpst_hw_port_stats {
351 /* eth stats collected by the port */
352 struct ipn3ke_rpst_eth_stats eth;
354 /* additional port specific stats */
355 uint64_t tx_dropped_link_down;
357 uint64_t illegal_bytes;
358 uint64_t error_bytes;
359 uint64_t mac_local_faults;
360 uint64_t mac_remote_faults;
361 uint64_t rx_length_errors;
362 uint64_t link_xon_rx;
363 uint64_t link_xoff_rx;
364 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
365 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
366 uint64_t link_xon_tx;
367 uint64_t link_xoff_tx;
368 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
369 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
370 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
372 uint64_t rx_size_65_127;
373 uint64_t rx_size_128_255;
374 uint64_t rx_size_256_511;
375 uint64_t rx_size_512_1023;
376 uint64_t rx_size_1024_1518;
377 uint64_t rx_size_big;
378 uint64_t rx_undersize;
379 uint64_t rx_fragments;
380 uint64_t rx_oversize;
383 uint64_t tx_size_65_127;
384 uint64_t tx_size_128_255;
385 uint64_t tx_size_256_511;
386 uint64_t tx_size_512_1023;
387 uint64_t tx_size_1024_1518;
388 uint64_t tx_size_1519_to_max;
389 uint64_t mac_short_packet_dropped;
390 uint64_t checksum_error;
391 /* flow director stats */
392 uint64_t fd_atr_match;
393 uint64_t fd_sb_match;
394 uint64_t fd_atr_tunnel_match;
395 uint32_t fd_atr_status;
396 uint32_t fd_sb_status;
398 uint32_t tx_lpi_status;
399 uint32_t rx_lpi_status;
400 uint64_t tx_lpi_count;
401 uint64_t rx_lpi_count;
404 static const struct ipn3ke_rpst_xstats_name_offset
405 ipn3ke_rpst_hw_port_strings[] = {
406 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
407 tx_dropped_link_down)},
408 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
410 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
412 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
414 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
416 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
418 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
420 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
422 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
424 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
426 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
428 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
430 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
432 {"rx_size_128_to_255_packets",
433 offsetof(struct ipn3ke_rpst_hw_port_stats,
435 {"rx_size_256_to_511_packets",
436 offsetof(struct ipn3ke_rpst_hw_port_stats,
438 {"rx_size_512_to_1023_packets",
439 offsetof(struct ipn3ke_rpst_hw_port_stats,
441 {"rx_size_1024_to_1518_packets",
442 offsetof(struct ipn3ke_rpst_hw_port_stats,
444 {"rx_size_1519_to_max_packets",
445 offsetof(struct ipn3ke_rpst_hw_port_stats,
447 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
449 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
451 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
452 mac_short_packet_dropped)},
453 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
455 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
457 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
459 {"tx_size_65_to_127_packets",
460 offsetof(struct ipn3ke_rpst_hw_port_stats,
462 {"tx_size_128_to_255_packets",
463 offsetof(struct ipn3ke_rpst_hw_port_stats,
465 {"tx_size_256_to_511_packets",
466 offsetof(struct ipn3ke_rpst_hw_port_stats,
468 {"tx_size_512_to_1023_packets",
469 offsetof(struct ipn3ke_rpst_hw_port_stats,
471 {"tx_size_1024_to_1518_packets",
472 offsetof(struct ipn3ke_rpst_hw_port_stats,
474 {"tx_size_1519_to_max_packets",
475 offsetof(struct ipn3ke_rpst_hw_port_stats,
476 tx_size_1519_to_max)},
477 {"rx_flow_director_atr_match_packets",
478 offsetof(struct ipn3ke_rpst_hw_port_stats,
480 {"rx_flow_director_sb_match_packets",
481 offsetof(struct ipn3ke_rpst_hw_port_stats,
483 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
485 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
487 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
489 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
493 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
494 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
496 static const struct ipn3ke_rpst_xstats_name_offset
497 ipn3ke_rpst_rxq_prio_strings[] = {
498 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
500 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
504 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
505 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
507 static const struct ipn3ke_rpst_xstats_name_offset
508 ipn3ke_rpst_txq_prio_strings[] = {
509 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
511 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
513 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
514 priority_xon_2_xoff)},
517 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
518 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
521 ipn3ke_rpst_xstats_calc_num(void)
523 return IPN3KE_RPST_ETH_XSTATS_CNT
524 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
525 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
526 * IPN3KE_RPST_PRIO_XSTATS_CNT)
527 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
528 * IPN3KE_RPST_PRIO_XSTATS_CNT);
532 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
535 uint32_t tmp = 0x00000001;
536 /* Bit[0]: Software can set this bit to the value of 1
537 * to reset all of the TX statistics registers at the same time.
538 * This bit is selfclearing.
540 (*hw->f_mac_write)(hw,
542 IPN3KE_25G_TX_STATISTICS_CONFIG,
546 while (tmp & 0x00000001) {
548 (*hw->f_mac_read)(hw,
550 IPN3KE_25G_TX_STATISTICS_CONFIG,
553 if (tmp & 0x00000001)
561 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
564 uint32_t tmp = 0x00000001;
565 /* Bit[0]: Software can set this bit to the value of 1
566 * to reset all of the RX statistics registers at the same time.
567 * This bit is selfclearing.
569 (*hw->f_mac_write)(hw,
571 IPN3KE_25G_RX_STATISTICS_CONFIG,
575 while (tmp & 0x00000001) {
577 (*hw->f_mac_read)(hw,
579 IPN3KE_25G_RX_STATISTICS_CONFIG,
582 if (tmp & 0x00000001)
590 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
595 /*Bit [0]: Set this register to 1 to clear all TX statistics
597 *The IP core clears this bit when all counters are cleared.
598 *Bits [31:1]: Reserved.
601 (*hw->f_mac_read)(hw,
603 IPN3KE_10G_TX_STATS_CLR,
607 (*hw->f_mac_write)(hw,
609 IPN3KE_10G_TX_STATS_CLR,
615 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
620 /*Bit [0]: Set this register to 1 to clear all RX statistics
622 *The IP core clears this bit when all counters are cleared.
623 *Bits [31:1]: Reserved
626 (*hw->f_mac_read)(hw,
628 IPN3KE_10G_RX_STATS_CLR,
632 (*hw->f_mac_write)(hw,
634 IPN3KE_10G_RX_STATS_CLR,
640 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
641 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
643 uint32_t statistics_lo = 0x00000000;
644 uint32_t statistics_hi = 0x00000000;
645 uint64_t statistics = 0x0000000000000000;
647 (*hw->f_mac_read)(hw,
653 (*hw->f_mac_read)(hw,
659 statistics += statistics_hi;
660 statistics = statistics << IPN3KE_REGISTER_WIDTH;
661 statistics += statistics_lo;
667 ipn3ke_rpst_read_25g_lineside_stats_registers
668 (struct ipn3ke_hw *hw,
670 struct ipn3ke_rpst_hw_port_stats *hw_stats)
675 memset(hw_stats, 0, sizeof(*hw_stats));
677 /*check Tx statistics is real time.
678 *if statistics has been paused, make it real time.
681 (*hw->f_mac_read)(hw,
683 IPN3KE_25G_TX_STATISTICS_CONFIG,
687 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
689 (*hw->f_mac_write)(hw,
691 IPN3KE_25G_TX_STATISTICS_CONFIG,
697 (*hw->f_mac_read)(hw,
699 IPN3KE_25G_TX_STATISTICS_STATUS,
702 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
704 (*hw->f_mac_read)(hw,
706 IPN3KE_25G_TX_STATISTICS_CONFIG,
710 (*hw->f_mac_write)(hw,
712 IPN3KE_25G_TX_STATISTICS_CONFIG,
717 /*check Rx statistics is real time.
718 *if statistics has been paused, make it real time.
721 (*hw->f_mac_read)(hw,
723 IPN3KE_25G_RX_STATISTICS_CONFIG,
726 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
728 (*hw->f_mac_write)(hw,
730 IPN3KE_25G_RX_STATISTICS_CONFIG,
736 (*hw->f_mac_read)(hw,
738 IPN3KE_25G_RX_STATISTICS_STATUS,
742 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
744 (*hw->f_mac_read)(hw,
746 IPN3KE_25G_RX_STATISTICS_CONFIG,
750 (*hw->f_mac_write)(hw,
752 IPN3KE_25G_RX_STATISTICS_CONFIG,
757 /* pause Tx counter to read the statistics */
759 (*hw->f_mac_read)(hw,
761 IPN3KE_25G_TX_STATISTICS_CONFIG,
765 (*hw->f_mac_write)(hw,
767 IPN3KE_25G_TX_STATISTICS_CONFIG,
771 /* pause Rx counter to read the statistics */
773 (*hw->f_mac_read)(hw,
775 IPN3KE_25G_RX_STATISTICS_CONFIG,
779 (*hw->f_mac_write)(hw,
781 IPN3KE_25G_RX_STATISTICS_CONFIG,
785 /*Number of transmitted frames less than 64 bytes
786 *and reporting a CRC error
788 statistics = ipn3ke_rpst_read_64bits_statistics_register(
789 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
790 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
792 hw_stats->eth.tx_errors += statistics;
793 hw_stats->crc_errors += statistics;
795 /*Number of transmitted oversized frames reporting a CRC error*/
796 statistics = ipn3ke_rpst_read_64bits_statistics_register(
797 IPN3KE_25G_CNTR_TX_JABBERS_LO,
798 IPN3KE_25G_CNTR_TX_JABBERS_HI,
800 hw_stats->eth.tx_errors += statistics;
801 hw_stats->crc_errors += statistics;
803 /* Number of transmitted packets with FCS errors */
804 statistics = ipn3ke_rpst_read_64bits_statistics_register(
805 IPN3KE_25G_CNTR_TX_FCS_LO,
806 IPN3KE_25G_CNTR_TX_FCS_HI,
808 hw_stats->eth.tx_errors += statistics;
809 hw_stats->checksum_error += statistics;
811 /*Number of transmitted frames with a frame of length at
812 *least 64 reporting a CRC error
814 statistics = ipn3ke_rpst_read_64bits_statistics_register(
815 IPN3KE_25G_CNTR_TX_CRCERR_LO,
816 IPN3KE_25G_CNTR_TX_CRCERR_HI,
818 hw_stats->eth.tx_errors += statistics;
819 hw_stats->crc_errors += statistics;
821 /*Number of errored multicast frames transmitted,
822 *excluding control frames
824 statistics = ipn3ke_rpst_read_64bits_statistics_register(
825 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
826 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
828 hw_stats->eth.tx_errors += statistics;
830 /*Number of errored broadcast frames transmitted,
831 *excluding control frames
833 statistics = ipn3ke_rpst_read_64bits_statistics_register(
834 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
835 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
837 hw_stats->eth.tx_errors += statistics;
839 /*Number of errored unicast frames transmitted,
840 *excluding control frames
842 statistics = ipn3ke_rpst_read_64bits_statistics_register(
843 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
844 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
846 hw_stats->eth.tx_errors += statistics;
848 /* Number of errored multicast control frames transmitted */
849 statistics = ipn3ke_rpst_read_64bits_statistics_register(
850 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
851 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
853 hw_stats->eth.tx_errors += statistics;
855 /* Number of errored broadcast control frames transmitted */
856 statistics = ipn3ke_rpst_read_64bits_statistics_register(
857 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
858 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
860 hw_stats->eth.tx_errors += statistics;
862 /* Number of errored unicast control frames transmitted */
863 statistics = ipn3ke_rpst_read_64bits_statistics_register(
864 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
865 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
867 hw_stats->eth.tx_errors += statistics;
869 /* Number of errored pause frames transmitted */
870 statistics = ipn3ke_rpst_read_64bits_statistics_register(
871 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
872 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
874 hw_stats->eth.tx_errors += statistics;
876 /*Number of 64-byte transmitted frames,
877 *including the CRC field but excluding the preamble
880 statistics = ipn3ke_rpst_read_64bits_statistics_register(
881 IPN3KE_25G_CNTR_TX_64B_LO,
882 IPN3KE_25G_CNTR_TX_64B_HI,
884 hw_stats->tx_size_64 += statistics;
886 /* Number of transmitted frames between 65 and 127 bytes */
887 statistics = ipn3ke_rpst_read_64bits_statistics_register(
888 IPN3KE_25G_CNTR_TX_65_127B_LO,
889 IPN3KE_25G_CNTR_TX_65_127B_HI,
891 hw_stats->tx_size_65_127 += statistics;
893 /* Number of transmitted frames between 128 and 255 bytes */
894 statistics = ipn3ke_rpst_read_64bits_statistics_register(
895 IPN3KE_25G_CNTR_TX_128_255B_LO,
896 IPN3KE_25G_CNTR_TX_128_255B_HI,
898 hw_stats->tx_size_128_255 += statistics;
900 /* Number of transmitted frames between 256 and 511 bytes */
901 statistics = ipn3ke_rpst_read_64bits_statistics_register(
902 IPN3KE_25G_CNTR_TX_256_511B_LO,
903 IPN3KE_25G_CNTR_TX_256_511B_HI,
905 hw_stats->tx_size_256_511 += statistics;
907 /* Number of transmitted frames between 512 and 1023 bytes */
908 statistics = ipn3ke_rpst_read_64bits_statistics_register(
909 IPN3KE_25G_CNTR_TX_512_1023B_LO,
910 IPN3KE_25G_CNTR_TX_512_1023B_HI,
912 hw_stats->tx_size_512_1023 += statistics;
914 /* Number of transmitted frames between 1024 and 1518 bytes */
915 statistics = ipn3ke_rpst_read_64bits_statistics_register(
916 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
917 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
919 hw_stats->tx_size_1024_1518 += statistics;
921 /*Number of transmitted frames of size between 1519 bytes
922 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
925 statistics = ipn3ke_rpst_read_64bits_statistics_register(
926 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
927 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
929 hw_stats->tx_size_1519_to_max += statistics;
931 /*Number of oversized frames (frames with more bytes than the
932 *number specified in the MAX_TX_SIZE_CONFIG register)
935 statistics = ipn3ke_rpst_read_64bits_statistics_register(
936 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
937 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
940 /*Number of valid multicast frames transmitted,
941 *excluding control frames
943 statistics = ipn3ke_rpst_read_64bits_statistics_register(
944 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
945 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
947 hw_stats->eth.tx_multicast += statistics;
949 /*Number of valid broadcast frames transmitted,
950 *excluding control frames
952 statistics = ipn3ke_rpst_read_64bits_statistics_register(
953 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
954 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
956 hw_stats->eth.tx_broadcast += statistics;
958 /*Number of valid unicast frames transmitted,
959 *excluding control frames
961 statistics = ipn3ke_rpst_read_64bits_statistics_register(
962 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
963 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
965 hw_stats->eth.tx_unicast += statistics;
967 /*Number of valid multicast frames transmitted,
968 *excluding data frames
970 statistics = ipn3ke_rpst_read_64bits_statistics_register(
971 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
972 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
974 hw_stats->eth.tx_multicast += statistics;
976 /*Number of valid broadcast frames transmitted,
977 *excluding data frames
979 statistics = ipn3ke_rpst_read_64bits_statistics_register(
980 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
981 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
983 hw_stats->eth.tx_broadcast += statistics;
985 /*Number of valid unicast frames transmitted,
986 *excluding data frames
988 statistics = ipn3ke_rpst_read_64bits_statistics_register(
989 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
990 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
992 hw_stats->eth.tx_unicast += statistics;
994 /* Number of valid pause frames transmitted */
995 statistics = ipn3ke_rpst_read_64bits_statistics_register(
996 IPN3KE_25G_CNTR_TX_PAUSE_LO,
997 IPN3KE_25G_CNTR_TX_PAUSE_HI,
1000 /*Number of transmitted runt packets. The IP core does not
1001 *transmit frames of length less than nine bytes.
1002 *The IP core pads frames of length nine bytes to 64 bytes to
1003 *extend them to 64 bytes. Therefore, this counter does not
1004 *increment in normal operating conditions.
1006 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1007 IPN3KE_25G_CNTR_TX_RUNT_LO,
1008 IPN3KE_25G_CNTR_TX_RUNT_HI,
1011 /*Number of transmitted payload bytes in frames with no FCS,
1012 *undersized, oversized, or payload length errors.
1013 *If VLAN detection is turned off for the TX MAC (bit[1]
1014 *of the TX_MAC_CONTROL register at offset 0x40A has
1015 *the value of 1), the IP core counts the VLAN header bytes
1016 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1017 *as payload bytes. This register is compliant with
1018 *the requirements for aOctetsTransmittedOK in section
1019 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1021 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1022 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1023 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1025 hw_stats->eth.tx_bytes += statistics;
1027 /*Number of transmitted bytes in frames with no FCS, undersized,
1028 *oversized, or payload length errors. This register is
1029 *compliant with the requirements for ifOutOctets in RFC3635
1030 *(Managed Objects for Ethernet-like Interface Types)
1031 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1032 *Management Information Base (RMON)).
1034 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1035 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1036 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1039 /*Number of received frames less than 64 bytes
1040 *and reporting a CRC error
1042 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1043 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1044 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1046 hw_stats->eth.rx_discards += statistics;
1047 hw_stats->crc_errors += statistics;
1048 hw_stats->rx_length_errors += statistics;
1050 /* Number of received oversized frames reporting a CRC error */
1051 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1052 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1053 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1055 hw_stats->eth.rx_discards += statistics;
1056 hw_stats->crc_errors += statistics;
1057 hw_stats->rx_length_errors += statistics;
1059 /*Number of received packets with FCS errors.
1060 *This register maintains a count of the number of pulses
1061 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1063 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1064 IPN3KE_25G_CNTR_RX_FCS_LO,
1065 IPN3KE_25G_CNTR_RX_FCS_HI,
1067 hw_stats->eth.rx_discards += statistics;
1068 hw_stats->checksum_error += statistics;
1070 /*Number of received frames with a frame of length at least 64
1073 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1074 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1075 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1077 hw_stats->eth.rx_discards += statistics;
1078 hw_stats->crc_errors += statistics;
1080 /*Number of errored multicast frames received,
1081 *excluding control frames
1083 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1084 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1085 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1087 hw_stats->eth.rx_discards += statistics;
1089 /*Number of errored broadcast frames received,
1090 *excluding control frames
1092 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1093 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1094 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1096 hw_stats->eth.rx_discards += statistics;
1098 /*Number of errored unicast frames received,
1099 *excluding control frames
1101 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1102 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1103 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1105 hw_stats->eth.rx_discards += statistics;
1107 /* Number of errored multicast control frames received */
1108 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1109 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1110 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1112 hw_stats->eth.rx_discards += statistics;
1114 /* Number of errored broadcast control frames received */
1115 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1116 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1117 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1119 hw_stats->eth.rx_discards += statistics;
1121 /* Number of errored unicast control frames received */
1122 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1123 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1124 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1126 hw_stats->eth.rx_discards += statistics;
1128 /* Number of errored pause frames received */
1129 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1130 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1131 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1133 hw_stats->eth.rx_discards += statistics;
1135 /*Number of 64-byte received frames,
1136 *including the CRC field but excluding the preamble
1139 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1140 IPN3KE_25G_CNTR_RX_64B_LO,
1141 IPN3KE_25G_CNTR_RX_64B_HI,
1143 hw_stats->rx_size_64 += statistics;
1145 /*Number of received frames between 65 and 127 bytes */
1146 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1147 IPN3KE_25G_CNTR_RX_65_127B_LO,
1148 IPN3KE_25G_CNTR_RX_65_127B_HI,
1150 hw_stats->rx_size_65_127 += statistics;
1152 /*Number of received frames between 128 and 255 bytes
1154 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1155 IPN3KE_25G_CNTR_RX_128_255B_LO,
1156 IPN3KE_25G_CNTR_RX_128_255B_HI,
1158 hw_stats->rx_size_128_255 += statistics;
1160 /*Number of received frames between 256 and 511 bytes
1162 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1163 IPN3KE_25G_CNTR_RX_256_511B_LO,
1164 IPN3KE_25G_CNTR_RX_256_511B_HI,
1166 hw_stats->rx_size_256_511 += statistics;
1168 /*Number of received frames between 512 and 1023 bytes
1170 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1171 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1172 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1174 hw_stats->rx_size_512_1023 += statistics;
1176 /*Number of received frames between 1024 and 1518 bytes
1178 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1179 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1180 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1182 hw_stats->rx_size_1024_1518 += statistics;
1184 /*Number of received frames of size between 1519 bytes
1185 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1188 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1189 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1190 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1192 hw_stats->rx_size_big += statistics;
1194 /*Number of oversized frames (frames with more bytes
1195 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1198 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1199 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1200 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1202 hw_stats->rx_jabber += statistics;
1204 /*Number of valid multicast frames received,
1205 *excluding control frames
1207 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1208 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1209 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1211 hw_stats->eth.rx_multicast += statistics;
1213 /*Number of valid broadcast frames received,
1214 *excluding control frames
1216 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1217 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1218 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1220 hw_stats->eth.rx_broadcast += statistics;
1222 /*Number of valid unicast frames received,
1223 *excluding control frames
1225 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1226 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1227 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1229 hw_stats->eth.rx_unicast += statistics;
1231 /*Number of valid multicast frames received,
1232 *excluding data frames
1234 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1235 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1236 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1238 hw_stats->eth.rx_multicast += statistics;
1240 /*Number of valid broadcast frames received,
1241 *excluding data frames
1243 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1244 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1245 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1247 hw_stats->eth.rx_broadcast += statistics;
1249 /*Number of valid unicast frames received,
1250 *excluding data frames
1252 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1253 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1254 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1256 hw_stats->eth.rx_unicast += statistics;
1258 /*Number of received pause frames, with or without error
1260 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1261 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1262 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1265 /*Number of received runt packets. A runt is a packet of size
1266 *less than 64 bytes but greater than eight bytes.
1267 *If a packet is eight bytes or smaller, it is considered
1268 *a decoding error and not a runt frame, and the IP core
1269 *does not flag it nor count it as a runt.
1271 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1272 IPN3KE_25G_CNTR_RX_RUNT_LO,
1273 IPN3KE_25G_CNTR_RX_RUNT_HI,
1276 /*Number of received payload bytes in frames with no FCS,
1277 *undersized, oversized, or payload length errors.
1278 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1279 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1280 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1281 *8 bytes for stacked VLAN) as payload bytes.
1282 *This register is compliant with the requirements for
1283 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1286 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1287 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1288 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1290 hw_stats->eth.rx_bytes += statistics;
1292 /*Number of received bytes in frames with no FCS, undersized,
1293 *oversized, or payload length errors.
1294 *This register is compliant with the requirements for
1295 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1296 *Interface Types) and RX etherStatsOctets in RFC2819
1297 *(Remote Network Monitoring Management Information Base
1300 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1301 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1302 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1305 /*resume Tx counter to real time
1308 (*hw->f_mac_read)(hw,
1310 IPN3KE_25G_TX_STATISTICS_CONFIG,
1314 (*hw->f_mac_write)(hw,
1316 IPN3KE_25G_TX_STATISTICS_CONFIG,
1320 /*resume Rx counter to real time
1323 (*hw->f_mac_read)(hw,
1325 IPN3KE_25G_RX_STATISTICS_CONFIG,
1329 (*hw->f_mac_write)(hw,
1331 IPN3KE_25G_RX_STATISTICS_CONFIG,
1339 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1342 uint32_t tmp = 0x00000001;
1343 /* Bit[0]: Software can set this bit to the value of 1
1344 * to reset all of the TX statistics registers at the same time.
1345 * This bit is selfclearing.
1347 (*hw->f_mac_write)(hw,
1349 IPN3KE_25G_TX_STATISTICS_CONFIG,
1353 while (tmp & 0x00000001) {
1355 (*hw->f_mac_read)(hw,
1357 IPN3KE_25G_TX_STATISTICS_CONFIG,
1360 if (tmp & 0x00000001)
1368 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1371 uint32_t tmp = 0x00000001;
1372 /* Bit[0]: Software can set this bit to the value of 1
1373 * to reset all of the RX statistics registers at the same time.
1374 * This bit is selfclearing.
1376 (*hw->f_mac_write)(hw,
1378 IPN3KE_25G_RX_STATISTICS_CONFIG,
1382 while (tmp & 0x00000001) {
1384 (*hw->f_mac_read)(hw,
1386 IPN3KE_25G_RX_STATISTICS_CONFIG,
1389 if (tmp & 0x00000001)
1397 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1398 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1400 uint32_t statistics_lo = 0x00000000;
1401 uint32_t statistics_hi = 0x00000000;
1402 uint64_t statistics = 0x0000000000000000;
1404 (*hw->f_mac_read)(hw,
1409 (*hw->f_mac_read)(hw,
1414 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1415 statistics += statistics_hi;
1416 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1417 statistics += statistics_lo;
1422 ipn3ke_rpst_read_10g_lineside_stats_registers
1423 (struct ipn3ke_hw *hw,
1425 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1426 struct rte_eth_stats *stats)
1428 uint64_t statistics = 0;
1430 memset(hw_stats, 0, sizeof(*hw_stats));
1431 memset(stats, 0, sizeof(*stats));
1433 /*36-bit statistics counter that collects the number of frames
1434 *that are successfully transmitted, including control frames.
1436 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1437 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1438 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1440 stats->opackets = statistics;
1442 /*36-bit statistics counter that collects the number of frames
1443 *that are successfully received, including control frames.
1445 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1446 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1447 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1449 stats->ipackets = statistics;
1451 /*36-bit statistics counter that collects the number of frames
1452 *transmitted with error, including control frames.
1454 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1455 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1456 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1458 stats->oerrors = statistics;
1459 hw_stats->eth.tx_errors = statistics;
1461 /*36-bit statistics counter that collects the number of frames
1462 *received with error, including control frames.
1464 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1465 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1466 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1468 stats->ierrors = statistics;
1469 hw_stats->eth.rx_discards = statistics;
1471 /*36-bit statistics counter that collects the number
1472 *of RX frames with CRC error.
1474 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1475 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1476 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1478 hw_stats->crc_errors = statistics;
1480 /*64-bit statistics counter that collects the payload length,
1481 *including the bytes in control frames.
1482 *The payload length is the number of data and padding bytes
1484 *If the tx_vlan_detection[0] register bit is set to 1,
1485 *the VLAN and stacked VLAN tags are counted as part of
1488 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1489 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1490 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1492 stats->obytes = statistics;
1493 hw_stats->eth.tx_bytes = statistics;
1495 /*64-bit statistics counter that collects the payload length,
1496 *including the bytes in control frames.
1497 *The payload length is the number of data and padding bytes
1499 *If the rx_vlan_detection[0] register bit is set to 1,
1500 *the VLAN and stacked VLAN tags are counted as part of
1503 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1504 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1505 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1507 stats->ibytes = statistics;
1508 hw_stats->eth.rx_bytes = statistics;
1510 /*36-bit statistics counter that collects the number of
1511 *valid pause frames transmitted.
1513 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1514 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1515 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1518 /*36-bit statistics counter that collects the number of
1519 *valid pause frames received.
1521 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1522 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1523 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1526 /*36-bit statistics counter that collects the number of frames
1527 *transmitted that are invalid and with error.
1529 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1530 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1531 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1534 /*36-bit statistics counter that collects the number of frames
1535 *received that are invalid and with error.
1537 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1538 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1539 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1542 /*36-bit statistics counter that collects the number of
1543 *good unicast frames transmitted,
1544 *excluding control frames.
1546 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1547 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1548 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1550 hw_stats->eth.tx_unicast = statistics;
1552 /*36-bit statistics counter that collects the number of
1553 *good unicast frames received,
1554 *excluding control frames.
1556 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1557 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1558 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1560 hw_stats->eth.rx_unicast = statistics;
1562 /*36-bit statistics counter that collects the number of
1563 *unicast frames transmitted with error,
1564 *excluding control frames.
1566 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1567 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1568 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1571 /*36-bit statistics counter that collects the number of
1572 *unicast frames received with error,
1573 *excluding control frames.
1575 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1576 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1577 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1580 /*36-bit statistics counter that collects the number of
1581 *good multicast frames transmitted,
1582 *excluding control frames.
1584 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1585 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1586 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1588 hw_stats->eth.tx_multicast = statistics;
1590 /*36-bit statistics counter that collects the number of
1591 *good multicast frames received,
1592 *excluding control frames.
1594 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1595 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1596 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1598 hw_stats->eth.rx_multicast = statistics;
1600 /*36-bit statistics counter that collects the number of
1601 *multicast frames transmitted with error,
1602 *excluding control frames.
1604 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1605 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1606 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1609 /*36-bit statistics counter that collects the number
1610 *of multicast frames received with error,
1611 *excluding control frames.
1613 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1614 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1615 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1618 /*36-bit statistics counter that collects the number of
1619 *good broadcast frames transmitted,
1620 *excluding control frames.
1622 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1623 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1624 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1626 hw_stats->eth.tx_broadcast = statistics;
1628 /*36-bit statistics counter that collects the number of
1629 *good broadcast frames received,
1630 *excluding control frames.
1632 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1633 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1634 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1636 hw_stats->eth.rx_broadcast = statistics;
1638 /*36-bit statistics counter that collects the number
1639 *of broadcast frames transmitted with error,
1640 *excluding control frames.
1642 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1643 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1644 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1647 /*36-bit statistics counter that collects the number of
1648 *broadcast frames received with error,
1649 *excluding control frames.
1651 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1652 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1653 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1656 /*64-bit statistics counter that collects the total number of
1657 *octets transmitted.
1658 *This count includes good, errored, and invalid frames.
1660 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1661 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1662 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1665 /*64-bit statistics counter that collects the total number of
1667 *This count includes good, errored, and invalid frames.
1669 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1670 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1671 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1674 /*36-bit statistics counter that collects the total number of
1675 *good, errored, and invalid frames transmitted.
1677 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1678 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1679 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1682 /*36-bit statistics counter that collects the total number of
1683 *good, errored, and invalid frames received.
1685 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1686 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1687 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1690 /*36-bit statistics counter that collects the number of
1691 *undersized TX frames.
1693 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1694 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1695 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1698 /*36-bit statistics counter that collects the number of
1699 *undersized RX frames.
1701 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1702 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1703 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1705 hw_stats->rx_undersize = statistics;
1707 /*36-bit statistics counter that collects the number of
1708 *TX frames whose length exceeds the maximum frame length
1711 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1712 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1713 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1716 /*36-bit statistics counter that collects the number of
1717 *RX frames whose length exceeds the maximum frame length
1720 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1721 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1722 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1724 hw_stats->rx_oversize = statistics;
1726 /*36-bit statistics counter that collects the number of
1728 *including the CRC field
1729 *but excluding the preamble and SFD bytes.
1730 *This count includes good, errored, and invalid frames.
1732 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1733 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1734 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1736 hw_stats->tx_size_64 = statistics;
1738 /*36-bit statistics counter that collects the number of
1740 *including the CRC field
1741 *but excluding the preamble and SFD bytes.
1742 *This count includes good, errored, and invalid frames.
1744 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1745 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1746 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1748 hw_stats->rx_size_64 = statistics;
1750 /*36-bit statistics counter that collects the number of
1751 *TX frames between the length of 65 and 127 bytes,
1752 *including the CRC field
1753 *but excluding the preamble and SFD bytes.
1754 *This count includes good, errored, and invalid frames.
1756 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1757 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1758 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1760 hw_stats->tx_size_65_127 = statistics;
1762 /*36-bit statistics counter that collects the number of
1763 *RX frames between the length of 65 and 127 bytes,
1764 *including the CRC field
1765 *but excluding the preamble and SFD bytes.
1766 *This count includes good, errored, and invalid frames.
1768 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1769 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1770 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1772 hw_stats->rx_size_65_127 = statistics;
1774 /*36-bit statistics counter that collects the number of
1775 *TX frames between the length of 128 and 255 bytes,
1776 *including the CRC field
1777 *but excluding the preamble and SFD bytes.
1778 *This count includes good, errored, and invalid frames.
1780 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1781 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1782 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1784 hw_stats->tx_size_128_255 = statistics;
1786 /*36-bit statistics counter that collects the number of
1787 *RX frames between the length of 128 and 255 bytes,
1788 *including the CRC field
1789 *but excluding the preamble and SFD bytes.
1790 *This count includes good, errored, and invalid frames.
1792 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1793 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1794 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1796 hw_stats->rx_size_128_255 = statistics;
1798 /*36-bit statistics counter that collects the number of
1799 *TX frames between the length of 256 and 511 bytes,
1800 *including the CRC field
1801 *but excluding the preamble and SFD bytes.
1802 *This count includes good, errored, and invalid frames.
1804 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1805 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1806 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1808 hw_stats->tx_size_256_511 = statistics;
1810 /*36-bit statistics counter that collects the number of
1811 *RX frames between the length of 256 and 511 bytes,
1812 *including the CRC field
1813 *but excluding the preamble and SFD bytes.
1814 *This count includes good, errored, and invalid frames.
1816 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1817 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1818 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1820 hw_stats->rx_size_256_511 = statistics;
1822 /*36-bit statistics counter that collects the number of
1823 *TX frames between the length of 512 and 1023 bytes,
1824 *including the CRC field
1825 *but excluding the preamble and SFD bytes.
1826 *This count includes good, errored, and invalid frames.
1828 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1829 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1830 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1832 hw_stats->tx_size_512_1023 = statistics;
1834 /*36-bit statistics counter that collects the number of
1835 *RX frames between the length of 512 and 1023 bytes,
1836 *including the CRC field
1837 *but excluding the preamble and SFD bytes.
1838 *This count includes good, errored, and invalid frames.
1840 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1841 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1842 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1844 hw_stats->rx_size_512_1023 = statistics;
1846 /*36-bit statistics counter that collects the number of
1847 *TX frames between the length of 1024 and 1518 bytes,
1848 *including the CRC field but
1849 *excluding the preamble and SFD bytes.
1850 *This count includes good, errored, and invalid frames.
1852 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1853 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1854 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1856 hw_stats->tx_size_1024_1518 = statistics;
1858 /*36-bit statistics counter that collects the number of
1859 *RX frames between the length of 1024 and 1518 bytes,
1860 *including the CRC field
1861 *but excluding the preamble and SFD bytes.
1862 *This count includes good, errored, and invalid frames.
1864 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1865 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1866 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1868 hw_stats->rx_size_1024_1518 = statistics;
1870 /*36-bit statistics counter that collects the number of
1871 *TX frames equal or more than the length of 1,519 bytes,
1872 *including the CRC field
1873 *but excluding the preamble and SFD bytes.
1874 *This count includes good, errored, and invalid frames.
1876 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1877 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1878 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1880 hw_stats->tx_size_1519_to_max = statistics;
1882 /*36-bit statistics counter that collects the number of
1883 *RX frames equal or more than the length of 1,519 bytes,
1884 *including the CRC field
1885 *but excluding the preamble and SFD bytes.
1886 *This count includes good,
1887 *errored, and invalid frames.
1889 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1890 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1891 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1893 hw_stats->rx_size_big = statistics;
1895 /*36-bit statistics counter that collects the total number of
1896 *RX frames with length less than 64 bytes and CRC error.
1897 *The MAC does not drop these frames.
1899 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1900 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1901 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1904 /*36-bit statistics counter that collects the number of
1905 *oversized RX frames with CRC error.
1906 *The MAC does not drop these frames.
1908 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1909 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1910 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1913 /*36-bit statistics counter that collects the number of
1914 *RX frames with CRC error,
1915 *whose length is between 64 and the maximum frame length
1916 *specified in the register.
1917 *The MAC does not drop these frames.
1919 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1920 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1921 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1924 /*36-bit statistics counter that collects the number of
1925 *valid TX unicast control frames.
1927 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1928 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1929 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1931 hw_stats->eth.tx_unicast += statistics;
1933 /*36-bit statistics counter that collects the number of
1934 *valid RX unicast control frames.
1936 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1937 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1938 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1940 hw_stats->eth.rx_unicast += statistics;
1942 /*36-bit statistics counter that collects the number of
1943 *valid TX multicast control frames.
1945 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1946 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1947 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1949 hw_stats->eth.tx_multicast += statistics;
1951 /*36-bit statistics counter that collects the number of
1952 *valid RX multicast control frames.
1954 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1955 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1956 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1958 hw_stats->eth.rx_multicast += statistics;
1960 /*36-bit statistics counter that collects the number of
1961 *valid TX broadcast control frames.
1963 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1964 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1965 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1967 hw_stats->eth.tx_broadcast += statistics;
1969 /*36-bit statistics counter that collects the number of
1970 *valid RX broadcast control frames.
1972 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1973 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1974 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1976 hw_stats->eth.rx_broadcast += statistics;
1978 /*36-bit statistics counter that collects the number of
1979 *valid TX PFC frames.
1981 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1982 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1983 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1986 /*36-bit statistics counter that collects the number of
1987 *valid RX PFC frames.
1989 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1990 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1991 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1998 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2003 /*Bit [0]: Set this register to 1 to clear all TX statistics
2005 *The IP core clears this bit when all counters are cleared.
2006 *Bits [31:1]: Reserved.
2009 (*hw->f_mac_read)(hw,
2011 IPN3KE_10G_TX_STATS_CLR,
2015 (*hw->f_mac_write)(hw,
2017 IPN3KE_10G_TX_STATS_CLR,
2023 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2028 /*Bit [0]: Set this register to 1 to clear all RX statistics
2030 *The IP core clears this bit when all counters are cleared.
2031 *Bits [31:1]: Reserved
2034 (*hw->f_mac_read)(hw,
2036 IPN3KE_10G_RX_STATS_CLR,
2040 (*hw->f_mac_write)(hw,
2042 IPN3KE_10G_RX_STATS_CLR,
2048 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2050 uint16_t port_id = 0;
2053 struct rte_afu_device *afu_dev = NULL;
2054 struct ipn3ke_hw *hw = NULL;
2057 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2061 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2063 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2067 if (!afu_dev->shared.data) {
2068 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2072 hw = afu_dev->shared.data;
2074 ch = ethdev->data->name;
2076 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2087 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2092 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2093 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2094 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2095 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2096 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2097 } else if (hw->retimer.mac_type ==
2098 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2099 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2100 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2101 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2102 ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
2109 ipn3ke_rpst_stats_get
2110 (struct rte_eth_dev *ethdev, struct rte_eth_stats *stats)
2112 uint16_t port_id = 0;
2116 struct rte_afu_device *afu_dev = NULL;
2117 struct ipn3ke_hw *hw = NULL;
2118 struct ipn3ke_rpst_hw_port_stats hw_stats;
2121 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2125 IPN3KE_AFU_PMD_ERR("Address to return statistics is NULL!");
2129 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2131 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2135 if (!afu_dev->shared.data) {
2136 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2140 hw = afu_dev->shared.data;
2142 ch = ethdev->data->name;
2144 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2155 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2160 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2161 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2165 stats->ipackets = hw_stats.rx_size_64
2166 + hw_stats.rx_size_65_127
2167 + hw_stats.rx_size_128_255
2168 + hw_stats.rx_size_256_511
2169 + hw_stats.rx_size_512_1023
2170 + hw_stats.rx_size_1024_1518
2171 + hw_stats.rx_size_big
2172 + hw_stats.rx_undersize
2173 + hw_stats.rx_fragments
2174 + hw_stats.rx_oversize
2175 + hw_stats.rx_jabber;
2176 stats->opackets = hw_stats.tx_size_64
2177 + hw_stats.tx_size_65_127
2178 + hw_stats.tx_size_128_255
2179 + hw_stats.tx_size_256_511
2180 + hw_stats.tx_size_512_1023
2181 + hw_stats.tx_size_1024_1518
2182 + hw_stats.tx_size_1519_to_max;
2183 stats->ibytes = hw_stats.eth.rx_bytes;
2184 stats->obytes = hw_stats.eth.tx_bytes;
2186 stats->ierrors = hw_stats.eth.rx_discards
2187 + hw_stats.eth.rx_unknown_protocol;
2188 stats->oerrors = hw_stats.eth.tx_discards
2189 + hw_stats.eth.tx_errors;
2190 stats->rx_nombuf = 0;
2191 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
2192 stats->q_ipackets[i] = 0;
2193 stats->q_opackets[i] = 0;
2194 stats->q_ibytes[i] = 0;
2195 stats->q_obytes[i] = 0;
2196 stats->q_errors[i] = 0;
2199 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2209 ipn3ke_rpst_xstats_get
2210 (struct rte_eth_dev *ethdev, struct rte_eth_xstat *xstats, unsigned int n)
2212 uint16_t port_id = 0;
2215 unsigned int i, count, prio;
2216 struct rte_afu_device *afu_dev = NULL;
2217 struct ipn3ke_hw *hw = NULL;
2218 struct ipn3ke_rpst_hw_port_stats hw_stats;
2219 struct rte_eth_stats stats;
2222 IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
2226 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2228 IPN3KE_AFU_PMD_ERR("afu device to get statistics is NULL!");
2232 if (!afu_dev->shared.data) {
2233 IPN3KE_AFU_PMD_ERR("hardware data to get statistics is NULL!");
2237 hw = afu_dev->shared.data;
2239 ch = ethdev->data->name;
2241 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2252 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2257 count = ipn3ke_rpst_xstats_calc_num();
2261 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2262 ipn3ke_rpst_read_25g_lineside_stats_registers(hw,
2266 ipn3ke_rpst_read_10g_lineside_stats_registers(hw,
2274 /* Get stats from ipn3ke_rpst_stats */
2275 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2276 xstats[count].value = *(uint64_t *)(((char *)&hw_stats.eth)
2277 + ipn3ke_rpst_stats_strings[i].offset);
2278 xstats[count].id = count;
2282 /* Get individual stats from ipn3ke_rpst_hw_port */
2283 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2284 xstats[count].value = *(uint64_t *)(((char *)(&hw_stats)) +
2285 ipn3ke_rpst_hw_port_strings[i].offset);
2286 xstats[count].id = count;
2290 /* Get individual stats from ipn3ke_rpst_rxq_pri */
2291 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2292 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2293 xstats[count].value =
2294 *(uint64_t *)(((char *)(&hw_stats)) +
2295 ipn3ke_rpst_rxq_prio_strings[i].offset +
2296 (sizeof(uint64_t) * prio));
2297 xstats[count].id = count;
2302 /* Get individual stats from ipn3ke_rpst_txq_prio */
2303 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2304 for (prio = 0; prio < IPN3KE_RPST_PRIO_XSTATS_CNT; prio++) {
2305 xstats[count].value =
2306 *(uint64_t *)(((char *)(&hw_stats)) +
2307 ipn3ke_rpst_txq_prio_strings[i].offset +
2308 (sizeof(uint64_t) * prio));
2309 xstats[count].id = count;
2318 ipn3ke_rpst_xstats_get_names
2319 (__rte_unused struct rte_eth_dev *dev,
2320 struct rte_eth_xstat_name *xstats_names,
2321 __rte_unused unsigned int limit)
2323 unsigned int count = 0;
2324 unsigned int i, prio;
2327 return ipn3ke_rpst_xstats_calc_num();
2329 /* Note: limit checked in rte_eth_xstats_names() */
2331 /* Get stats from ipn3ke_rpst_stats */
2332 for (i = 0; i < IPN3KE_RPST_ETH_XSTATS_CNT; i++) {
2333 snprintf(xstats_names[count].name,
2334 sizeof(xstats_names[count].name),
2336 ipn3ke_rpst_stats_strings[i].name);
2340 /* Get individual stats from ipn3ke_rpst_hw_port */
2341 for (i = 0; i < IPN3KE_RPST_HW_PORT_XSTATS_CNT; i++) {
2342 snprintf(xstats_names[count].name,
2343 sizeof(xstats_names[count].name),
2345 ipn3ke_rpst_hw_port_strings[i].name);
2349 /* Get individual stats from ipn3ke_rpst_rxq_pri */
2350 for (i = 0; i < IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT; i++) {
2351 for (prio = 0; prio < 8; prio++) {
2352 snprintf(xstats_names[count].name,
2353 sizeof(xstats_names[count].name),
2356 ipn3ke_rpst_rxq_prio_strings[i].name);
2361 /* Get individual stats from ipn3ke_rpst_txq_prio */
2362 for (i = 0; i < IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT; i++) {
2363 for (prio = 0; prio < 8; prio++) {
2364 snprintf(xstats_names[count].name,
2365 sizeof(xstats_names[count].name),
2368 ipn3ke_rpst_txq_prio_strings[i].name);
2376 ipn3ke_update_link(struct rte_rawdev *rawdev,
2377 uint16_t port, struct rte_eth_link *link)
2379 uint64_t line_link_bitmap = 0;
2380 enum ifpga_rawdev_link_speed link_speed;
2382 rawdev->dev_ops->attr_get(rawdev,
2383 "LineSideLinkStatus",
2384 (uint64_t *)&line_link_bitmap);
2386 /* Parse the link status */
2387 if ((1 << port) & line_link_bitmap)
2388 link->link_status = 1;
2390 link->link_status = 0;
2392 IPN3KE_AFU_PMD_DEBUG("port is %d\n", port);
2393 IPN3KE_AFU_PMD_DEBUG("link->link_status is %d\n", link->link_status);
2395 rawdev->dev_ops->attr_get(rawdev,
2396 "LineSideLinkSpeed",
2397 (uint64_t *)&link_speed);
2398 switch (link_speed) {
2399 case IFPGA_RAWDEV_LINK_SPEED_10GB:
2400 link->link_speed = RTE_ETH_SPEED_NUM_10G;
2402 case IFPGA_RAWDEV_LINK_SPEED_25GB:
2403 link->link_speed = RTE_ETH_SPEED_NUM_25G;
2406 IPN3KE_AFU_PMD_ERR("Unknown link speed info %u", link_speed);
2412 * Set device link up.
2415 ipn3ke_rpst_dev_set_link_up(struct rte_eth_dev *dev)
2417 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2418 struct rte_eth_dev *pf;
2421 if (rpst->i40e_pf_eth) {
2422 ret = rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2423 pf = rpst->i40e_pf_eth;
2424 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2431 * Set device link down.
2434 ipn3ke_rpst_dev_set_link_down(struct rte_eth_dev *dev)
2436 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
2437 struct rte_eth_dev *pf;
2440 if (rpst->i40e_pf_eth) {
2441 ret = rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2442 pf = rpst->i40e_pf_eth;
2443 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2450 ipn3ke_rpst_link_update(struct rte_eth_dev *ethdev,
2451 __rte_unused int wait_to_complete)
2453 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2454 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2455 struct rte_rawdev *rawdev;
2456 struct rte_eth_link link;
2457 struct rte_eth_dev *pf;
2459 memset(&link, 0, sizeof(link));
2461 link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
2462 link.link_autoneg = !(ethdev->data->dev_conf.link_speeds &
2463 RTE_ETH_LINK_SPEED_FIXED);
2465 rawdev = hw->rawdev;
2466 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2468 if (!rpst->ori_linfo.link_status &&
2470 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Up\n", rpst->port_id);
2471 rpst->ori_linfo.link_status = link.link_status;
2472 rpst->ori_linfo.link_speed = link.link_speed;
2474 rte_eth_linkstatus_set(ethdev, &link);
2476 if (rpst->i40e_pf_eth) {
2477 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Up\n",
2478 rpst->i40e_pf_eth_port_id);
2479 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2480 pf = rpst->i40e_pf_eth;
2481 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2483 } else if (rpst->ori_linfo.link_status &&
2484 !link.link_status) {
2485 IPN3KE_AFU_PMD_DEBUG("Update Rpst %d Down\n",
2487 rpst->ori_linfo.link_status = link.link_status;
2488 rpst->ori_linfo.link_speed = link.link_speed;
2490 rte_eth_linkstatus_set(ethdev, &link);
2492 if (rpst->i40e_pf_eth) {
2493 IPN3KE_AFU_PMD_DEBUG("Update FVL PF %d Down\n",
2494 rpst->i40e_pf_eth_port_id);
2495 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2496 pf = rpst->i40e_pf_eth;
2497 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2505 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst)
2507 struct ipn3ke_hw *hw;
2508 struct rte_rawdev *rawdev;
2509 struct rte_eth_link link;
2510 struct rte_eth_dev *pf;
2517 memset(&link, 0, sizeof(link));
2519 link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
2520 link.link_autoneg = !(rpst->ethdev->data->dev_conf.link_speeds &
2521 RTE_ETH_LINK_SPEED_FIXED);
2523 rawdev = hw->rawdev;
2524 ipn3ke_update_link(rawdev, rpst->port_id, &link);
2526 if (!rpst->ori_linfo.link_status &&
2528 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Up\n", rpst->port_id);
2529 rpst->ori_linfo.link_status = link.link_status;
2530 rpst->ori_linfo.link_speed = link.link_speed;
2532 rte_eth_linkstatus_set(rpst->ethdev, &link);
2534 if (rpst->i40e_pf_eth) {
2535 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Up\n",
2536 rpst->i40e_pf_eth_port_id);
2537 rte_eth_dev_set_link_up(rpst->i40e_pf_eth_port_id);
2538 pf = rpst->i40e_pf_eth;
2539 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2541 } else if (rpst->ori_linfo.link_status &&
2542 !link.link_status) {
2543 IPN3KE_AFU_PMD_DEBUG("Check Rpst %d Down\n", rpst->port_id);
2544 rpst->ori_linfo.link_status = link.link_status;
2545 rpst->ori_linfo.link_speed = link.link_speed;
2547 rte_eth_linkstatus_set(rpst->ethdev, &link);
2549 if (rpst->i40e_pf_eth) {
2550 IPN3KE_AFU_PMD_DEBUG("Check FVL PF %d Down\n",
2551 rpst->i40e_pf_eth_port_id);
2552 rte_eth_dev_set_link_down(rpst->i40e_pf_eth_port_id);
2553 pf = rpst->i40e_pf_eth;
2554 (*rpst->i40e_pf_eth->dev_ops->link_update)(pf, 1);
2562 ipn3ke_rpst_scan_handle_request(__rte_unused void *param)
2564 struct ipn3ke_rpst *rpst;
2571 TAILQ_FOREACH(rpst, &ipn3ke_rpst_list, next) {
2572 if (rpst->i40e_pf_eth &&
2573 rpst->ethdev->data->dev_started &&
2574 rpst->i40e_pf_eth->data->dev_started)
2575 ipn3ke_rpst_link_check(rpst);
2577 if (++num > SCAN_NUM)
2578 rte_delay_us(1 * MS);
2580 rte_delay_us(50 * MS);
2582 if (num == 0xffffff)
2590 ipn3ke_rpst_scan_check(void)
2594 if (ipn3ke_rpst_scan_num == 1) {
2595 ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
2598 ipn3ke_rpst_scan_handle_request, NULL);
2600 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2603 } else if (ipn3ke_rpst_scan_num == 0) {
2604 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2606 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2608 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2610 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2619 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2621 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2622 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2623 uint32_t rddata, val;
2625 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2626 /* Enable all unicast */
2627 (*hw->f_mac_read)(hw,
2629 IPN3KE_MAC_RX_FRAME_CONTROL,
2633 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2635 (*hw->f_mac_write)(hw,
2637 IPN3KE_MAC_RX_FRAME_CONTROL,
2646 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2648 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2649 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2650 uint32_t rddata, val;
2652 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2653 /* Disable all unicast */
2654 (*hw->f_mac_read)(hw,
2656 IPN3KE_MAC_RX_FRAME_CONTROL,
2660 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2662 (*hw->f_mac_write)(hw,
2664 IPN3KE_MAC_RX_FRAME_CONTROL,
2673 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2675 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2676 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2677 uint32_t rddata, val;
2679 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2680 /* Enable all unicast */
2681 (*hw->f_mac_read)(hw,
2683 IPN3KE_MAC_RX_FRAME_CONTROL,
2687 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2688 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2690 (*hw->f_mac_write)(hw,
2692 IPN3KE_MAC_RX_FRAME_CONTROL,
2701 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2703 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2704 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2705 uint32_t rddata, val;
2707 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2708 /* Disable all unicast */
2709 (*hw->f_mac_read)(hw,
2711 IPN3KE_MAC_RX_FRAME_CONTROL,
2715 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2716 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2718 (*hw->f_mac_write)(hw,
2720 IPN3KE_MAC_RX_FRAME_CONTROL,
2729 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2730 struct rte_ether_addr *mac_addr)
2732 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2733 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2736 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2737 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2741 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2742 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2744 /* Set mac address */
2745 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2746 (*hw->f_mac_write)(hw,
2748 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2751 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2752 (*hw->f_mac_write)(hw,
2754 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2763 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2766 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2767 struct rte_eth_dev_data *dev_data = ethdev->data;
2769 /* mtu setting is forbidden if port is start */
2770 /* make sure NIC port is stopped */
2771 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2772 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2773 "be stopped before configuration",
2774 rpst->i40e_pf_eth->data->port_id);
2777 /* mtu setting is forbidden if port is start */
2778 if (dev_data->dev_started) {
2779 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2780 "be stopped before configuration",
2785 if (rpst->i40e_pf_eth) {
2786 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2789 rpst->i40e_pf_eth->data->mtu = mtu;
2796 ipn3ke_afu_flow_ops_get(struct rte_eth_dev *ethdev,
2797 const struct rte_flow_ops **ops)
2799 struct ipn3ke_hw *hw;
2800 struct ipn3ke_rpst *rpst;
2805 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2806 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2809 *ops = &ipn3ke_flow_ops;
2810 else if (rpst->i40e_pf_eth)
2811 (*rpst->i40e_pf_eth->dev_ops->flow_ops_get)(ethdev, ops);
2818 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2819 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2821 .dev_configure = ipn3ke_rpst_dev_configure,
2822 .dev_start = ipn3ke_rpst_dev_start,
2823 .dev_stop = ipn3ke_rpst_dev_stop,
2824 .dev_close = ipn3ke_rpst_dev_close,
2825 .dev_reset = ipn3ke_rpst_dev_reset,
2827 .stats_get = ipn3ke_rpst_stats_get,
2828 .xstats_get = ipn3ke_rpst_xstats_get,
2829 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2830 .stats_reset = ipn3ke_rpst_stats_reset,
2831 .xstats_reset = ipn3ke_rpst_stats_reset,
2833 .flow_ops_get = ipn3ke_afu_flow_ops_get,
2835 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2836 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2837 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2838 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2839 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2840 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2842 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2843 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2844 .link_update = ipn3ke_rpst_link_update,
2846 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2847 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2848 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2849 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2850 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2851 .mtu_set = ipn3ke_rpst_mtu_set,
2853 .tm_ops_get = ipn3ke_tm_ops_get,
2856 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2857 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2863 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2864 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2870 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2872 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2873 struct ipn3ke_rpst *representor_param =
2874 (struct ipn3ke_rpst *)init_params;
2876 if (representor_param->port_id >= representor_param->hw->port_num)
2879 if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
2882 rpst->ethdev = ethdev;
2883 rpst->switch_domain_id = representor_param->switch_domain_id;
2884 rpst->port_id = representor_param->port_id;
2885 rpst->hw = representor_param->hw;
2886 rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
2887 rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
2888 if (rpst->i40e_pf_eth)
2889 ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
2892 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2893 if (!ethdev->data->mac_addrs) {
2894 IPN3KE_AFU_PMD_ERR("Failed to "
2895 "allocated memory for storing mac address");
2899 if (rpst->hw->tm_hw_enable)
2900 ipn3ke_tm_init(rpst);
2902 /* Set representor device ops */
2903 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2905 /* No data-path, but need stub Rx/Tx functions to avoid crash
2906 * when testing with the likes of testpmd.
2908 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2909 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2911 ethdev->data->nb_rx_queues = 1;
2912 ethdev->data->nb_tx_queues = 1;
2914 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2917 if (!ethdev->data->mac_addrs) {
2918 IPN3KE_AFU_PMD_ERR("Failed to "
2919 "allocated memory for storing mac address");
2923 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
2924 RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
2926 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2927 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2928 ipn3ke_rpst_scan_num++;
2929 ipn3ke_rpst_scan_check();
2930 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2936 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2938 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2940 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2941 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2942 ipn3ke_rpst_scan_num--;
2943 ipn3ke_rpst_scan_check();
2944 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);