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) ?
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;
79 dev_info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE;
80 dev_info->tx_offload_capa =
81 DEV_TX_OFFLOAD_VLAN_INSERT |
82 DEV_TX_OFFLOAD_QINQ_INSERT |
83 DEV_TX_OFFLOAD_IPV4_CKSUM |
84 DEV_TX_OFFLOAD_UDP_CKSUM |
85 DEV_TX_OFFLOAD_TCP_CKSUM |
86 DEV_TX_OFFLOAD_SCTP_CKSUM |
87 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
88 DEV_TX_OFFLOAD_TCP_TSO |
89 DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
90 DEV_TX_OFFLOAD_GRE_TNL_TSO |
91 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
92 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
93 DEV_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;
100 dev_info->switch_info.name = ethdev->device->name;
101 dev_info->switch_info.domain_id = rpst->switch_domain_id;
102 dev_info->switch_info.port_id = rpst->port_id;
108 ipn3ke_rpst_dev_configure(__rte_unused struct rte_eth_dev *dev)
114 ipn3ke_rpst_dev_start(struct rte_eth_dev *dev)
116 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
117 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
118 struct rte_rawdev *rawdev;
121 char attr_name[IPN3KE_RAWDEV_ATTR_LEN_MAX];
125 memset(attr_name, 0, sizeof(attr_name));
126 snprintf(attr_name, IPN3KE_RAWDEV_ATTR_LEN_MAX, "%s",
128 rawdev->dev_ops->attr_get(rawdev, attr_name, &base_mac);
129 rte_ether_addr_copy((struct rte_ether_addr *)&base_mac,
132 rte_ether_addr_copy(&rpst->mac_addr, &dev->data->mac_addrs[0]);
133 dev->data->mac_addrs->addr_bytes[RTE_ETHER_ADDR_LEN - 1] =
134 (uint8_t)rpst->port_id + 1;
136 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
137 /* Set mac address */
138 rte_memcpy(((char *)(&val)),
139 (char *)&dev->data->mac_addrs->addr_bytes[0],
141 (*hw->f_mac_write)(hw,
143 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
146 rte_memcpy(((char *)(&val)),
147 (char *)&dev->data->mac_addrs->addr_bytes[4],
149 (*hw->f_mac_write)(hw,
151 IPN3KE_MAC_PRIMARY_MAC_ADDR1,
155 /* Enable the TX path */
156 ipn3ke_xmac_tx_enable(hw, rpst->port_id, 0);
158 /* Disables source address override */
159 ipn3ke_xmac_smac_ovd_dis(hw, rpst->port_id, 0);
161 /* Enable the RX path */
162 ipn3ke_xmac_rx_enable(hw, rpst->port_id, 0);
164 /* Clear line side TX statistics counters */
165 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 0);
167 /* Clear line side RX statistics counters */
168 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 0);
170 /* Clear NIC side TX statistics counters */
171 ipn3ke_xmac_tx_clr_10G_stcs(hw, rpst->port_id, 1);
173 /* Clear NIC side RX statistics counters */
174 ipn3ke_xmac_rx_clr_10G_stcs(hw, rpst->port_id, 1);
175 } else if (hw->retimer.mac_type ==
176 IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
177 /* Clear line side TX statistics counters */
178 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 0);
180 /* Clear line side RX statistics counters */
181 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 0);
183 /* Clear NIC side TX statistics counters */
184 ipn3ke_xmac_tx_clr_25G_stcs(hw, rpst->port_id, 1);
186 /* Clear NIC side RX statistics counters */
187 ipn3ke_xmac_rx_clr_25G_stcs(hw, rpst->port_id, 1);
190 ipn3ke_rpst_link_update(dev, 0);
196 ipn3ke_rpst_dev_stop(struct rte_eth_dev *dev)
198 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
199 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
201 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
202 /* Disable the TX path */
203 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
205 /* Disable the RX path */
206 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
213 ipn3ke_rpst_dev_close(struct rte_eth_dev *dev)
215 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
216 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
218 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
221 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
222 /* Disable the TX path */
223 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
225 /* Disable the RX path */
226 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
233 * Reset PF device only to re-initialize resources in PMD layer
236 ipn3ke_rpst_dev_reset(struct rte_eth_dev *dev)
238 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
239 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
241 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
242 /* Disable the TX path */
243 ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
245 /* Disable the RX path */
246 ipn3ke_xmac_rx_disable(hw, rpst->port_id, 0);
253 ipn3ke_rpst_rx_queue_start(__rte_unused struct rte_eth_dev *dev,
254 __rte_unused uint16_t rx_queue_id)
260 ipn3ke_rpst_rx_queue_stop(__rte_unused struct rte_eth_dev *dev,
261 __rte_unused uint16_t rx_queue_id)
267 ipn3ke_rpst_tx_queue_start(__rte_unused struct rte_eth_dev *dev,
268 __rte_unused uint16_t tx_queue_id)
274 ipn3ke_rpst_tx_queue_stop(__rte_unused struct rte_eth_dev *dev,
275 __rte_unused uint16_t tx_queue_id)
281 ipn3ke_rpst_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
282 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
283 __rte_unused unsigned int socket_id,
284 __rte_unused const struct rte_eth_rxconf *rx_conf,
285 __rte_unused struct rte_mempool *mp)
291 ipn3ke_rpst_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
292 __rte_unused uint16_t queue_idx, __rte_unused uint16_t nb_desc,
293 __rte_unused unsigned int socket_id,
294 __rte_unused const struct rte_eth_txconf *tx_conf)
299 /* Statistics collected by each port, VSI, VEB, and S-channel */
300 struct ipn3ke_rpst_eth_stats {
301 uint64_t tx_bytes; /* gotc */
302 uint64_t tx_multicast; /* mptc */
303 uint64_t tx_broadcast; /* bptc */
304 uint64_t tx_unicast; /* uptc */
305 uint64_t tx_discards; /* tdpc */
306 uint64_t tx_errors; /* tepc */
307 uint64_t rx_bytes; /* gorc */
308 uint64_t rx_multicast; /* mprc */
309 uint64_t rx_broadcast; /* bprc */
310 uint64_t rx_unicast; /* uprc */
311 uint64_t rx_discards; /* rdpc */
312 uint64_t rx_unknown_protocol; /* rupp */
315 /* store statistics names and its offset in stats structure */
316 struct ipn3ke_rpst_xstats_name_offset {
317 char name[RTE_ETH_XSTATS_NAME_SIZE];
321 static const struct ipn3ke_rpst_xstats_name_offset
322 ipn3ke_rpst_stats_strings[] = {
323 {"tx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
325 {"tx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
327 {"tx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
329 {"tx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
331 {"rx_multicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
333 {"rx_broadcast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
335 {"rx_unicast_packets", offsetof(struct ipn3ke_rpst_eth_stats,
337 {"rx_dropped_packets", offsetof(struct ipn3ke_rpst_eth_stats,
339 {"rx_unknown_protocol_packets", offsetof(struct ipn3ke_rpst_eth_stats,
340 rx_unknown_protocol)},
343 #define IPN3KE_RPST_ETH_XSTATS_CNT (sizeof(ipn3ke_rpst_stats_strings) / \
344 sizeof(ipn3ke_rpst_stats_strings[0]))
346 #define IPN3KE_RPST_PRIO_XSTATS_CNT 8
348 /* Statistics collected by the MAC */
349 struct ipn3ke_rpst_hw_port_stats {
350 /* eth stats collected by the port */
351 struct ipn3ke_rpst_eth_stats eth;
353 /* additional port specific stats */
354 uint64_t tx_dropped_link_down;
356 uint64_t illegal_bytes;
357 uint64_t error_bytes;
358 uint64_t mac_local_faults;
359 uint64_t mac_remote_faults;
360 uint64_t rx_length_errors;
361 uint64_t link_xon_rx;
362 uint64_t link_xoff_rx;
363 uint64_t priority_xon_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
364 uint64_t priority_xoff_rx[IPN3KE_RPST_PRIO_XSTATS_CNT];
365 uint64_t link_xon_tx;
366 uint64_t link_xoff_tx;
367 uint64_t priority_xon_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
368 uint64_t priority_xoff_tx[IPN3KE_RPST_PRIO_XSTATS_CNT];
369 uint64_t priority_xon_2_xoff[IPN3KE_RPST_PRIO_XSTATS_CNT];
371 uint64_t rx_size_65_127;
372 uint64_t rx_size_128_255;
373 uint64_t rx_size_256_511;
374 uint64_t rx_size_512_1023;
375 uint64_t rx_size_1024_1518;
376 uint64_t rx_size_big;
377 uint64_t rx_undersize;
378 uint64_t rx_fragments;
379 uint64_t rx_oversize;
382 uint64_t tx_size_65_127;
383 uint64_t tx_size_128_255;
384 uint64_t tx_size_256_511;
385 uint64_t tx_size_512_1023;
386 uint64_t tx_size_1024_1518;
387 uint64_t tx_size_1519_to_max;
388 uint64_t mac_short_packet_dropped;
389 uint64_t checksum_error;
390 /* flow director stats */
391 uint64_t fd_atr_match;
392 uint64_t fd_sb_match;
393 uint64_t fd_atr_tunnel_match;
394 uint32_t fd_atr_status;
395 uint32_t fd_sb_status;
397 uint32_t tx_lpi_status;
398 uint32_t rx_lpi_status;
399 uint64_t tx_lpi_count;
400 uint64_t rx_lpi_count;
403 static const struct ipn3ke_rpst_xstats_name_offset
404 ipn3ke_rpst_hw_port_strings[] = {
405 {"tx_link_down_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
406 tx_dropped_link_down)},
407 {"rx_crc_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
409 {"rx_illegal_byte_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
411 {"rx_error_bytes", offsetof(struct ipn3ke_rpst_hw_port_stats,
413 {"mac_local_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
415 {"mac_remote_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
417 {"rx_length_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
419 {"tx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
421 {"rx_xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
423 {"tx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
425 {"rx_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
427 {"rx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
429 {"rx_size_65_to_127_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
431 {"rx_size_128_to_255_packets",
432 offsetof(struct ipn3ke_rpst_hw_port_stats,
434 {"rx_size_256_to_511_packets",
435 offsetof(struct ipn3ke_rpst_hw_port_stats,
437 {"rx_size_512_to_1023_packets",
438 offsetof(struct ipn3ke_rpst_hw_port_stats,
440 {"rx_size_1024_to_1518_packets",
441 offsetof(struct ipn3ke_rpst_hw_port_stats,
443 {"rx_size_1519_to_max_packets",
444 offsetof(struct ipn3ke_rpst_hw_port_stats,
446 {"rx_undersized_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
448 {"rx_oversize_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
450 {"rx_mac_short_dropped", offsetof(struct ipn3ke_rpst_hw_port_stats,
451 mac_short_packet_dropped)},
452 {"rx_fragmented_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
454 {"rx_jabber_errors", offsetof(struct ipn3ke_rpst_hw_port_stats,
456 {"tx_size_64_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
458 {"tx_size_65_to_127_packets",
459 offsetof(struct ipn3ke_rpst_hw_port_stats,
461 {"tx_size_128_to_255_packets",
462 offsetof(struct ipn3ke_rpst_hw_port_stats,
464 {"tx_size_256_to_511_packets",
465 offsetof(struct ipn3ke_rpst_hw_port_stats,
467 {"tx_size_512_to_1023_packets",
468 offsetof(struct ipn3ke_rpst_hw_port_stats,
470 {"tx_size_1024_to_1518_packets",
471 offsetof(struct ipn3ke_rpst_hw_port_stats,
473 {"tx_size_1519_to_max_packets",
474 offsetof(struct ipn3ke_rpst_hw_port_stats,
475 tx_size_1519_to_max)},
476 {"rx_flow_director_atr_match_packets",
477 offsetof(struct ipn3ke_rpst_hw_port_stats,
479 {"rx_flow_director_sb_match_packets",
480 offsetof(struct ipn3ke_rpst_hw_port_stats,
482 {"tx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
484 {"rx_low_power_idle_status", offsetof(struct ipn3ke_rpst_hw_port_stats,
486 {"tx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
488 {"rx_low_power_idle_count", offsetof(struct ipn3ke_rpst_hw_port_stats,
492 #define IPN3KE_RPST_HW_PORT_XSTATS_CNT (sizeof(ipn3ke_rpst_hw_port_strings) \
493 / sizeof(ipn3ke_rpst_hw_port_strings[0]))
495 static const struct ipn3ke_rpst_xstats_name_offset
496 ipn3ke_rpst_rxq_prio_strings[] = {
497 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
499 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
503 #define IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_rxq_prio_strings) \
504 / sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
506 static const struct ipn3ke_rpst_xstats_name_offset
507 ipn3ke_rpst_txq_prio_strings[] = {
508 {"xon_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
510 {"xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
512 {"xon_to_xoff_packets", offsetof(struct ipn3ke_rpst_hw_port_stats,
513 priority_xon_2_xoff)},
516 #define IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT (sizeof(ipn3ke_rpst_txq_prio_strings) \
517 / sizeof(ipn3ke_rpst_txq_prio_strings[0]))
520 ipn3ke_rpst_xstats_calc_num(void)
522 return IPN3KE_RPST_ETH_XSTATS_CNT
523 + IPN3KE_RPST_HW_PORT_XSTATS_CNT
524 + (IPN3KE_RPST_RXQ_PRIO_XSTATS_CNT
525 * IPN3KE_RPST_PRIO_XSTATS_CNT)
526 + (IPN3KE_RPST_TXQ_PRIO_XSTATS_CNT
527 * IPN3KE_RPST_PRIO_XSTATS_CNT);
531 ipn3ke_rpst_25g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
534 uint32_t tmp = 0x00000001;
535 /* Bit[0]: Software can set this bit to the value of 1
536 * to reset all of the TX statistics registers at the same time.
537 * This bit is selfclearing.
539 (*hw->f_mac_write)(hw,
541 IPN3KE_25G_TX_STATISTICS_CONFIG,
545 while (tmp & 0x00000001) {
547 (*hw->f_mac_read)(hw,
549 IPN3KE_25G_TX_STATISTICS_CONFIG,
552 if (tmp & 0x00000001)
560 ipn3ke_rpst_25g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
563 uint32_t tmp = 0x00000001;
564 /* Bit[0]: Software can set this bit to the value of 1
565 * to reset all of the RX statistics registers at the same time.
566 * This bit is selfclearing.
568 (*hw->f_mac_write)(hw,
570 IPN3KE_25G_RX_STATISTICS_CONFIG,
574 while (tmp & 0x00000001) {
576 (*hw->f_mac_read)(hw,
578 IPN3KE_25G_RX_STATISTICS_CONFIG,
581 if (tmp & 0x00000001)
589 ipn3ke_rpst_10g_nic_side_tx_stats_reset(struct ipn3ke_hw *hw,
594 /*Bit [0]: Set this register to 1 to clear all TX statistics
596 *The IP core clears this bit when all counters are cleared.
597 *Bits [31:1]: Reserved.
600 (*hw->f_mac_read)(hw,
602 IPN3KE_10G_TX_STATS_CLR,
606 (*hw->f_mac_write)(hw,
608 IPN3KE_10G_TX_STATS_CLR,
614 ipn3ke_rpst_10g_nic_side_rx_stats_reset(struct ipn3ke_hw *hw,
619 /*Bit [0]: Set this register to 1 to clear all RX statistics
621 *The IP core clears this bit when all counters are cleared.
622 *Bits [31:1]: Reserved
625 (*hw->f_mac_read)(hw,
627 IPN3KE_10G_RX_STATS_CLR,
631 (*hw->f_mac_write)(hw,
633 IPN3KE_10G_RX_STATS_CLR,
639 ipn3ke_rpst_read_64bits_statistics_register(uint32_t addr_lo,
640 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
642 uint32_t statistics_lo = 0x00000000;
643 uint32_t statistics_hi = 0x00000000;
644 uint64_t statistics = 0x0000000000000000;
646 (*hw->f_mac_read)(hw,
652 (*hw->f_mac_read)(hw,
658 statistics += statistics_hi;
659 statistics = statistics << IPN3KE_REGISTER_WIDTH;
660 statistics += statistics_lo;
666 ipn3ke_rpst_read_25g_lineside_stats_registers
667 (struct ipn3ke_hw *hw,
669 struct ipn3ke_rpst_hw_port_stats *hw_stats)
674 memset(hw_stats, 0, sizeof(*hw_stats));
676 /*check Tx statistics is real time.
677 *if statistics has been paused, make it real time.
680 (*hw->f_mac_read)(hw,
682 IPN3KE_25G_TX_STATISTICS_CONFIG,
686 if (tmp & IPN3KE_25G_TX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
688 (*hw->f_mac_write)(hw,
690 IPN3KE_25G_TX_STATISTICS_CONFIG,
696 (*hw->f_mac_read)(hw,
698 IPN3KE_25G_TX_STATISTICS_STATUS,
701 if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
703 (*hw->f_mac_read)(hw,
705 IPN3KE_25G_TX_STATISTICS_CONFIG,
709 (*hw->f_mac_write)(hw,
711 IPN3KE_25G_TX_STATISTICS_CONFIG,
716 /*check Rx statistics is real time.
717 *if statistics has been paused, make it real time.
720 (*hw->f_mac_read)(hw,
722 IPN3KE_25G_RX_STATISTICS_CONFIG,
725 if (tmp & IPN3KE_25G_RX_STATISTICS_CONFIG_SHADOW_REQUEST_MASK) {
727 (*hw->f_mac_write)(hw,
729 IPN3KE_25G_RX_STATISTICS_CONFIG,
735 (*hw->f_mac_read)(hw,
737 IPN3KE_25G_RX_STATISTICS_STATUS,
741 if (tmp & IPN3KE_25G_RX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
743 (*hw->f_mac_read)(hw,
745 IPN3KE_25G_RX_STATISTICS_CONFIG,
749 (*hw->f_mac_write)(hw,
751 IPN3KE_25G_RX_STATISTICS_CONFIG,
756 /* pause Tx counter to read the statistics */
758 (*hw->f_mac_read)(hw,
760 IPN3KE_25G_TX_STATISTICS_CONFIG,
764 (*hw->f_mac_write)(hw,
766 IPN3KE_25G_TX_STATISTICS_CONFIG,
770 /* pause Rx counter to read the statistics */
772 (*hw->f_mac_read)(hw,
774 IPN3KE_25G_RX_STATISTICS_CONFIG,
778 (*hw->f_mac_write)(hw,
780 IPN3KE_25G_RX_STATISTICS_CONFIG,
784 /*Number of transmitted frames less than 64 bytes
785 *and reporting a CRC error
787 statistics = ipn3ke_rpst_read_64bits_statistics_register(
788 IPN3KE_25G_CNTR_TX_FRAGMENTS_LO,
789 IPN3KE_25G_CNTR_TX_FRAGMENTS_HI,
791 hw_stats->eth.tx_errors += statistics;
792 hw_stats->crc_errors += statistics;
794 /*Number of transmitted oversized frames reporting a CRC error*/
795 statistics = ipn3ke_rpst_read_64bits_statistics_register(
796 IPN3KE_25G_CNTR_TX_JABBERS_LO,
797 IPN3KE_25G_CNTR_TX_JABBERS_HI,
799 hw_stats->eth.tx_errors += statistics;
800 hw_stats->crc_errors += statistics;
802 /* Number of transmitted packets with FCS errors */
803 statistics = ipn3ke_rpst_read_64bits_statistics_register(
804 IPN3KE_25G_CNTR_TX_FCS_LO,
805 IPN3KE_25G_CNTR_TX_FCS_HI,
807 hw_stats->eth.tx_errors += statistics;
808 hw_stats->checksum_error += statistics;
810 /*Number of transmitted frames with a frame of length at
811 *least 64 reporting a CRC error
813 statistics = ipn3ke_rpst_read_64bits_statistics_register(
814 IPN3KE_25G_CNTR_TX_CRCERR_LO,
815 IPN3KE_25G_CNTR_TX_CRCERR_HI,
817 hw_stats->eth.tx_errors += statistics;
818 hw_stats->crc_errors += statistics;
820 /*Number of errored multicast frames transmitted,
821 *excluding control frames
823 statistics = ipn3ke_rpst_read_64bits_statistics_register(
824 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_LO,
825 IPN3KE_25G_CNTR_TX_MCAST_DATA_ERR_HI,
827 hw_stats->eth.tx_errors += statistics;
829 /*Number of errored broadcast frames transmitted,
830 *excluding control frames
832 statistics = ipn3ke_rpst_read_64bits_statistics_register(
833 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_LO,
834 IPN3KE_25G_CNTR_TX_BCAST_DATA_ERR_HI,
836 hw_stats->eth.tx_errors += statistics;
838 /*Number of errored unicast frames transmitted,
839 *excluding control frames
841 statistics = ipn3ke_rpst_read_64bits_statistics_register(
842 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_LO,
843 IPN3KE_25G_CNTR_TX_UCAST_DATA_ERR_HI,
845 hw_stats->eth.tx_errors += statistics;
847 /* Number of errored multicast control frames transmitted */
848 statistics = ipn3ke_rpst_read_64bits_statistics_register(
849 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_LO,
850 IPN3KE_25G_CNTR_TX_MCAST_CTRL_ERR_HI,
852 hw_stats->eth.tx_errors += statistics;
854 /* Number of errored broadcast control frames transmitted */
855 statistics = ipn3ke_rpst_read_64bits_statistics_register(
856 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_LO,
857 IPN3KE_25G_CNTR_TX_BCAST_CTRL_ERR_HI,
859 hw_stats->eth.tx_errors += statistics;
861 /* Number of errored unicast control frames transmitted */
862 statistics = ipn3ke_rpst_read_64bits_statistics_register(
863 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_LO,
864 IPN3KE_25G_CNTR_TX_UCAST_CTRL_ERR_HI,
866 hw_stats->eth.tx_errors += statistics;
868 /* Number of errored pause frames transmitted */
869 statistics = ipn3ke_rpst_read_64bits_statistics_register(
870 IPN3KE_25G_CNTR_TX_PAUSE_ERR_LO,
871 IPN3KE_25G_CNTR_TX_PAUSE_ERR_HI,
873 hw_stats->eth.tx_errors += statistics;
875 /*Number of 64-byte transmitted frames,
876 *including the CRC field but excluding the preamble
879 statistics = ipn3ke_rpst_read_64bits_statistics_register(
880 IPN3KE_25G_CNTR_TX_64B_LO,
881 IPN3KE_25G_CNTR_TX_64B_HI,
883 hw_stats->tx_size_64 += statistics;
885 /* Number of transmitted frames between 65 and 127 bytes */
886 statistics = ipn3ke_rpst_read_64bits_statistics_register(
887 IPN3KE_25G_CNTR_TX_65_127B_LO,
888 IPN3KE_25G_CNTR_TX_65_127B_HI,
890 hw_stats->tx_size_65_127 += statistics;
892 /* Number of transmitted frames between 128 and 255 bytes */
893 statistics = ipn3ke_rpst_read_64bits_statistics_register(
894 IPN3KE_25G_CNTR_TX_128_255B_LO,
895 IPN3KE_25G_CNTR_TX_128_255B_HI,
897 hw_stats->tx_size_128_255 += statistics;
899 /* Number of transmitted frames between 256 and 511 bytes */
900 statistics = ipn3ke_rpst_read_64bits_statistics_register(
901 IPN3KE_25G_CNTR_TX_256_511B_LO,
902 IPN3KE_25G_CNTR_TX_256_511B_HI,
904 hw_stats->tx_size_256_511 += statistics;
906 /* Number of transmitted frames between 512 and 1023 bytes */
907 statistics = ipn3ke_rpst_read_64bits_statistics_register(
908 IPN3KE_25G_CNTR_TX_512_1023B_LO,
909 IPN3KE_25G_CNTR_TX_512_1023B_HI,
911 hw_stats->tx_size_512_1023 += statistics;
913 /* Number of transmitted frames between 1024 and 1518 bytes */
914 statistics = ipn3ke_rpst_read_64bits_statistics_register(
915 IPN3KE_25G_CNTR_TX_1024_1518B_LO,
916 IPN3KE_25G_CNTR_TX_1024_1518B_HI,
918 hw_stats->tx_size_1024_1518 += statistics;
920 /*Number of transmitted frames of size between 1519 bytes
921 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
924 statistics = ipn3ke_rpst_read_64bits_statistics_register(
925 IPN3KE_25G_CNTR_TX_1519_MAXB_LO,
926 IPN3KE_25G_CNTR_TX_1519_MAXB_HI,
928 hw_stats->tx_size_1519_to_max += statistics;
930 /*Number of oversized frames (frames with more bytes than the
931 *number specified in the MAX_TX_SIZE_CONFIG register)
934 statistics = ipn3ke_rpst_read_64bits_statistics_register(
935 IPN3KE_25G_CNTR_TX_OVERSIZE_LO,
936 IPN3KE_25G_CNTR_TX_OVERSIZE_HI,
939 /*Number of valid multicast frames transmitted,
940 *excluding control frames
942 statistics = ipn3ke_rpst_read_64bits_statistics_register(
943 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_LO,
944 IPN3KE_25G_CNTR_TX_MCAST_DATA_OK_HI,
946 hw_stats->eth.tx_multicast += statistics;
948 /*Number of valid broadcast frames transmitted,
949 *excluding control frames
951 statistics = ipn3ke_rpst_read_64bits_statistics_register(
952 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_LO,
953 IPN3KE_25G_CNTR_TX_BCAST_DATA_OK_HI,
955 hw_stats->eth.tx_broadcast += statistics;
957 /*Number of valid unicast frames transmitted,
958 *excluding control frames
960 statistics = ipn3ke_rpst_read_64bits_statistics_register(
961 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_LO,
962 IPN3KE_25G_CNTR_TX_UCAST_DATA_OK_HI,
964 hw_stats->eth.tx_unicast += statistics;
966 /*Number of valid multicast frames transmitted,
967 *excluding data frames
969 statistics = ipn3ke_rpst_read_64bits_statistics_register(
970 IPN3KE_25G_CNTR_TX_MCAST_CTRL_LO,
971 IPN3KE_25G_CNTR_TX_MCAST_CTRL_HI,
973 hw_stats->eth.tx_multicast += statistics;
975 /*Number of valid broadcast frames transmitted,
976 *excluding data frames
978 statistics = ipn3ke_rpst_read_64bits_statistics_register(
979 IPN3KE_25G_CNTR_TX_BCAST_CTRL_LO,
980 IPN3KE_25G_CNTR_TX_BCAST_CTRL_HI,
982 hw_stats->eth.tx_broadcast += statistics;
984 /*Number of valid unicast frames transmitted,
985 *excluding data frames
987 statistics = ipn3ke_rpst_read_64bits_statistics_register(
988 IPN3KE_25G_CNTR_TX_UCAST_CTRL_LO,
989 IPN3KE_25G_CNTR_TX_UCAST_CTRL_HI,
991 hw_stats->eth.tx_unicast += statistics;
993 /* Number of valid pause frames transmitted */
994 statistics = ipn3ke_rpst_read_64bits_statistics_register(
995 IPN3KE_25G_CNTR_TX_PAUSE_LO,
996 IPN3KE_25G_CNTR_TX_PAUSE_HI,
999 /*Number of transmitted runt packets. The IP core does not
1000 *transmit frames of length less than nine bytes.
1001 *The IP core pads frames of length nine bytes to 64 bytes to
1002 *extend them to 64 bytes. Therefore, this counter does not
1003 *increment in normal operating conditions.
1005 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1006 IPN3KE_25G_CNTR_TX_RUNT_LO,
1007 IPN3KE_25G_CNTR_TX_RUNT_HI,
1010 /*Number of transmitted payload bytes in frames with no FCS,
1011 *undersized, oversized, or payload length errors.
1012 *If VLAN detection is turned off for the TX MAC (bit[1]
1013 *of the TX_MAC_CONTROL register at offset 0x40A has
1014 *the value of 1), the IP core counts the VLAN header bytes
1015 *(4 bytes for VLAN and 8 bytes for stacked VLAN)
1016 *as payload bytes. This register is compliant with
1017 *the requirements for aOctetsTransmittedOK in section
1018 *5.2.2.1.8 of the IEEE Standard 802.3-2008.
1020 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1021 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_LO,
1022 IPN3KE_25G_TX_PAYLOAD_OCTETS_OK_HI,
1024 hw_stats->eth.tx_bytes += statistics;
1026 /*Number of transmitted bytes in frames with no FCS, undersized,
1027 *oversized, or payload length errors. This register is
1028 *compliant with the requirements for ifOutOctets in RFC3635
1029 *(Managed Objects for Ethernet-like Interface Types)
1030 *and TX etherStatsOctets in RFC2819(Remote Network Monitoring
1031 *Management Information Base (RMON)).
1033 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1034 IPN3KE_25G_TX_FRAME_OCTETS_OK_LO,
1035 IPN3KE_25G_TX_FRAME_OCTETS_OK_HI,
1038 /*Number of received frames less than 64 bytes
1039 *and reporting a CRC error
1041 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1042 IPN3KE_25G_CNTR_RX_FRAGMENTS_LO,
1043 IPN3KE_25G_CNTR_RX_FRAGMENTS_HI,
1045 hw_stats->eth.rx_discards += statistics;
1046 hw_stats->crc_errors += statistics;
1047 hw_stats->rx_length_errors += statistics;
1049 /* Number of received oversized frames reporting a CRC error */
1050 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1051 IPN3KE_25G_CNTR_RX_JABBERS_LO,
1052 IPN3KE_25G_CNTR_RX_JABBERS_HI,
1054 hw_stats->eth.rx_discards += statistics;
1055 hw_stats->crc_errors += statistics;
1056 hw_stats->rx_length_errors += statistics;
1058 /*Number of received packets with FCS errors.
1059 *This register maintains a count of the number of pulses
1060 *on the "l<n>_rx_fcs_error" or "rx_fcs_error" output signal
1062 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1063 IPN3KE_25G_CNTR_RX_FCS_LO,
1064 IPN3KE_25G_CNTR_RX_FCS_HI,
1066 hw_stats->eth.rx_discards += statistics;
1067 hw_stats->checksum_error += statistics;
1069 /*Number of received frames with a frame of length at least 64
1072 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1073 IPN3KE_25G_CNTR_RX_CRCERR_LO,
1074 IPN3KE_25G_CNTR_RX_CRCERR_HI,
1076 hw_stats->eth.rx_discards += statistics;
1077 hw_stats->crc_errors += statistics;
1079 /*Number of errored multicast frames received,
1080 *excluding control frames
1082 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1083 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_LO,
1084 IPN3KE_25G_CNTR_RX_MCAST_DATA_ERR_HI,
1086 hw_stats->eth.rx_discards += statistics;
1088 /*Number of errored broadcast frames received,
1089 *excluding control frames
1091 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1092 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_LO,
1093 IPN3KE_25G_CNTR_RX_BCAST_DATA_ERR_HI,
1095 hw_stats->eth.rx_discards += statistics;
1097 /*Number of errored unicast frames received,
1098 *excluding control frames
1100 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1101 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_LO,
1102 IPN3KE_25G_CNTR_RX_UCAST_DATA_ERR_HI,
1104 hw_stats->eth.rx_discards += statistics;
1106 /* Number of errored multicast control frames received */
1107 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1108 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_LO,
1109 IPN3KE_25G_CNTR_RX_MCAST_CTRL_ERR_HI,
1111 hw_stats->eth.rx_discards += statistics;
1113 /* Number of errored broadcast control frames received */
1114 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1115 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_LO,
1116 IPN3KE_25G_CNTR_RX_BCAST_CTRL_ERR_HI,
1118 hw_stats->eth.rx_discards += statistics;
1120 /* Number of errored unicast control frames received */
1121 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1122 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_LO,
1123 IPN3KE_25G_CNTR_RX_UCAST_CTRL_ERR_HI,
1125 hw_stats->eth.rx_discards += statistics;
1127 /* Number of errored pause frames received */
1128 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1129 IPN3KE_25G_CNTR_RX_PAUSE_ERR_LO,
1130 IPN3KE_25G_CNTR_RX_PAUSE_ERR_HI,
1132 hw_stats->eth.rx_discards += statistics;
1134 /*Number of 64-byte received frames,
1135 *including the CRC field but excluding the preamble
1138 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1139 IPN3KE_25G_CNTR_RX_64B_LO,
1140 IPN3KE_25G_CNTR_RX_64B_HI,
1142 hw_stats->rx_size_64 += statistics;
1144 /*Number of received frames between 65 and 127 bytes */
1145 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1146 IPN3KE_25G_CNTR_RX_65_127B_LO,
1147 IPN3KE_25G_CNTR_RX_65_127B_HI,
1149 hw_stats->rx_size_65_127 += statistics;
1151 /*Number of received frames between 128 and 255 bytes
1153 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1154 IPN3KE_25G_CNTR_RX_128_255B_LO,
1155 IPN3KE_25G_CNTR_RX_128_255B_HI,
1157 hw_stats->rx_size_128_255 += statistics;
1159 /*Number of received frames between 256 and 511 bytes
1161 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1162 IPN3KE_25G_CNTR_RX_256_511B_LO,
1163 IPN3KE_25G_CNTR_RX_256_511B_HI,
1165 hw_stats->rx_size_256_511 += statistics;
1167 /*Number of received frames between 512 and 1023 bytes
1169 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1170 IPN3KE_25G_CNTR_RX_512_1023B_LO,
1171 IPN3KE_25G_CNTR_RX_512_1023B_HI,
1173 hw_stats->rx_size_512_1023 += statistics;
1175 /*Number of received frames between 1024 and 1518 bytes
1177 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1178 IPN3KE_25G_CNTR_RX_1024_1518B_LO,
1179 IPN3KE_25G_CNTR_RX_1024_1518B_HI,
1181 hw_stats->rx_size_1024_1518 += statistics;
1183 /*Number of received frames of size between 1519 bytes
1184 *and the number of bytes specified in the MAX_TX_SIZE_CONFIG
1187 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1188 IPN3KE_25G_CNTR_RX_1519_MAXB_LO,
1189 IPN3KE_25G_CNTR_RX_1519_MAXB_HI,
1191 hw_stats->rx_size_big += statistics;
1193 /*Number of oversized frames (frames with more bytes
1194 *than the number specified in the MAX_TX_SIZE_CONFIG register)
1197 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1198 IPN3KE_25G_CNTR_RX_OVERSIZE_LO,
1199 IPN3KE_25G_CNTR_RX_OVERSIZE_HI,
1201 hw_stats->rx_jabber += statistics;
1203 /*Number of valid multicast frames received,
1204 *excluding control frames
1206 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1207 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_LO,
1208 IPN3KE_25G_CNTR_RX_MCAST_DATA_OK_HI,
1210 hw_stats->eth.rx_multicast += statistics;
1212 /*Number of valid broadcast frames received,
1213 *excluding control frames
1215 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1216 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_LO,
1217 IPN3KE_25G_CNTR_RX_BCAST_DATA_OK_HI,
1219 hw_stats->eth.rx_broadcast += statistics;
1221 /*Number of valid unicast frames received,
1222 *excluding control frames
1224 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1225 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_LO,
1226 IPN3KE_25G_CNTR_RX_UCAST_DATA_OK_HI,
1228 hw_stats->eth.rx_unicast += statistics;
1230 /*Number of valid multicast frames received,
1231 *excluding data frames
1233 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1234 IPN3KE_25G_CNTR_RX_MCAST_CTRL_LO,
1235 IPN3KE_25G_CNTR_RX_MCAST_CTRL_HI,
1237 hw_stats->eth.rx_multicast += statistics;
1239 /*Number of valid broadcast frames received,
1240 *excluding data frames
1242 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1243 IPN3KE_25G_CNTR_RX_BCAST_CTRL_LO,
1244 IPN3KE_25G_CNTR_RX_BCAST_CTRL_HI,
1246 hw_stats->eth.rx_broadcast += statistics;
1248 /*Number of valid unicast frames received,
1249 *excluding data frames
1251 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1252 IPN3KE_25G_CNTR_RX_UCAST_CTRL_LO,
1253 IPN3KE_25G_CNTR_RX_UCAST_CTRL_HI,
1255 hw_stats->eth.rx_unicast += statistics;
1257 /*Number of received pause frames, with or without error
1259 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1260 IPN3KE_25G_CNTR_RX_PAUSE_LO,
1261 IPN3KE_25G_CNTR_RX_PAUSE_HI,
1264 /*Number of received runt packets. A runt is a packet of size
1265 *less than 64 bytes but greater than eight bytes.
1266 *If a packet is eight bytes or smaller, it is considered
1267 *a decoding error and not a runt frame, and the IP core
1268 *does not flag it nor count it as a runt.
1270 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1271 IPN3KE_25G_CNTR_RX_RUNT_LO,
1272 IPN3KE_25G_CNTR_RX_RUNT_HI,
1275 /*Number of received payload bytes in frames with no FCS,
1276 *undersized, oversized, or payload length errors.
1277 *If VLAN detection is turned off for the RX MAC (bit [1] of the
1278 *"RXMAC_CONTROL" register at offset 0x50A has the value of 1),
1279 *the IP core counts the VLAN header bytes (4 bytes for VLAN and
1280 *8 bytes for stacked VLAN) as payload bytes.
1281 *This register is compliant with the requirements for
1282 *aOctetsReceivedOK in section 5.2.2.1.14 of the IEEE Standard
1285 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1286 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_LO,
1287 IPN3KE_25G_RX_PAYLOAD_OCTETS_OK_HI,
1289 hw_stats->eth.rx_bytes += statistics;
1291 /*Number of received bytes in frames with no FCS, undersized,
1292 *oversized, or payload length errors.
1293 *This register is compliant with the requirements for
1294 *ifInOctets in RFC3635 (Managed Objects for Ethernet-like
1295 *Interface Types) and RX etherStatsOctets in RFC2819
1296 *(Remote Network Monitoring Management Information Base
1299 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1300 IPN3KE_25G_RX_FRAME_OCTETS_OK_LO,
1301 IPN3KE_25G_RX_FRAME_OCTETS_OK_HI,
1304 /*resume Tx counter to real time
1307 (*hw->f_mac_read)(hw,
1309 IPN3KE_25G_TX_STATISTICS_CONFIG,
1313 (*hw->f_mac_write)(hw,
1315 IPN3KE_25G_TX_STATISTICS_CONFIG,
1319 /*resume Rx counter to real time
1322 (*hw->f_mac_read)(hw,
1324 IPN3KE_25G_RX_STATISTICS_CONFIG,
1328 (*hw->f_mac_write)(hw,
1330 IPN3KE_25G_RX_STATISTICS_CONFIG,
1338 ipn3ke_rpst_25g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
1341 uint32_t tmp = 0x00000001;
1342 /* Bit[0]: Software can set this bit to the value of 1
1343 * to reset all of the TX statistics registers at the same time.
1344 * This bit is selfclearing.
1346 (*hw->f_mac_write)(hw,
1348 IPN3KE_25G_TX_STATISTICS_CONFIG,
1352 while (tmp & 0x00000001) {
1354 (*hw->f_mac_read)(hw,
1356 IPN3KE_25G_TX_STATISTICS_CONFIG,
1359 if (tmp & 0x00000001)
1367 ipn3ke_rpst_25g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
1370 uint32_t tmp = 0x00000001;
1371 /* Bit[0]: Software can set this bit to the value of 1
1372 * to reset all of the RX statistics registers at the same time.
1373 * This bit is selfclearing.
1375 (*hw->f_mac_write)(hw,
1377 IPN3KE_25G_RX_STATISTICS_CONFIG,
1381 while (tmp & 0x00000001) {
1383 (*hw->f_mac_read)(hw,
1385 IPN3KE_25G_RX_STATISTICS_CONFIG,
1388 if (tmp & 0x00000001)
1396 ipn3ke_rpst_read_36bits_statistics_register(uint32_t addr_lo,
1397 uint32_t addr_hi, struct ipn3ke_hw *hw, uint16_t port_id)
1399 uint32_t statistics_lo = 0x00000000;
1400 uint32_t statistics_hi = 0x00000000;
1401 uint64_t statistics = 0x0000000000000000;
1403 (*hw->f_mac_read)(hw,
1408 (*hw->f_mac_read)(hw,
1413 statistics_hi &= IPN3KE_10G_STATS_HI_VALID_MASK;
1414 statistics += statistics_hi;
1415 statistics = statistics << IPN3KE_REGISTER_WIDTH;
1416 statistics += statistics_lo;
1421 ipn3ke_rpst_read_10g_lineside_stats_registers
1422 (struct ipn3ke_hw *hw,
1424 struct ipn3ke_rpst_hw_port_stats *hw_stats,
1425 struct rte_eth_stats *stats)
1427 uint64_t statistics = 0;
1429 memset(hw_stats, 0, sizeof(*hw_stats));
1430 memset(stats, 0, sizeof(*stats));
1432 /*36-bit statistics counter that collects the number of frames
1433 *that are successfully transmitted, including control frames.
1435 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1436 IPN3KE_10G_TX_STATS_FRAME_OK_LO,
1437 IPN3KE_10G_TX_STATS_FRAME_OK_HI,
1439 stats->opackets = statistics;
1441 /*36-bit statistics counter that collects the number of frames
1442 *that are successfully received, including control frames.
1444 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1445 IPN3KE_10G_RX_STATS_FRAME_OK_LO,
1446 IPN3KE_10G_RX_STATS_FRAME_OK_HI,
1448 stats->ipackets = statistics;
1450 /*36-bit statistics counter that collects the number of frames
1451 *transmitted with error, including control frames.
1453 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1454 IPN3KE_10G_TX_STATS_FRAME_ERR_LO,
1455 IPN3KE_10G_TX_STATS_FRAME_ERR_HI,
1457 stats->oerrors = statistics;
1458 hw_stats->eth.tx_errors = statistics;
1460 /*36-bit statistics counter that collects the number of frames
1461 *received with error, including control frames.
1463 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1464 IPN3KE_10G_RX_STATS_FRAME_ERR_LO,
1465 IPN3KE_10G_RX_STATS_FRAME_ERR_HI,
1467 stats->ierrors = statistics;
1468 hw_stats->eth.rx_discards = statistics;
1470 /*36-bit statistics counter that collects the number
1471 *of RX frames with CRC error.
1473 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1474 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_LO,
1475 IPN3KE_10G_RX_STATS_FRAME_CRC_ERR_HI,
1477 hw_stats->crc_errors = statistics;
1479 /*64-bit statistics counter that collects the payload length,
1480 *including the bytes in control frames.
1481 *The payload length is the number of data and padding bytes
1483 *If the tx_vlan_detection[0] register bit is set to 1,
1484 *the VLAN and stacked VLAN tags are counted as part of
1487 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1488 IPN3KE_10G_TX_STATS_OCTETS_OK_LO,
1489 IPN3KE_10G_TX_STATS_OCTETS_OK_HI,
1491 stats->obytes = statistics;
1492 hw_stats->eth.tx_bytes = statistics;
1494 /*64-bit statistics counter that collects the payload length,
1495 *including the bytes in control frames.
1496 *The payload length is the number of data and padding bytes
1498 *If the rx_vlan_detection[0] register bit is set to 1,
1499 *the VLAN and stacked VLAN tags are counted as part of
1502 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1503 IPN3KE_10G_RX_STATS_OCTETS_OK_LO,
1504 IPN3KE_10G_RX_STATS_OCTETS_OK_HI,
1506 stats->ibytes = statistics;
1507 hw_stats->eth.rx_bytes = statistics;
1509 /*36-bit statistics counter that collects the number of
1510 *valid pause frames transmitted.
1512 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1513 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1514 IPN3KE_10G_TX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1517 /*36-bit statistics counter that collects the number of
1518 *valid pause frames received.
1520 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1521 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_LO,
1522 IPN3KE_10G_RX_STATS_PAUSE_MAC_CTRL_FRAMES_HI,
1525 /*36-bit statistics counter that collects the number of frames
1526 *transmitted that are invalid and with error.
1528 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1529 IPN3KE_10G_TX_STATS_IF_ERRORS_LO,
1530 IPN3KE_10G_TX_STATS_IF_ERRORS_HI,
1533 /*36-bit statistics counter that collects the number of frames
1534 *received that are invalid and with error.
1536 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1537 IPN3KE_10G_RX_STATS_IF_ERRORS_LO,
1538 IPN3KE_10G_RX_STATS_IF_ERRORS_HI,
1541 /*36-bit statistics counter that collects the number of
1542 *good unicast frames transmitted,
1543 *excluding control frames.
1545 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1546 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_LO,
1547 IPN3KE_10G_TX_STATS_UNICAST_FRAME_OK_HI,
1549 hw_stats->eth.tx_unicast = statistics;
1551 /*36-bit statistics counter that collects the number of
1552 *good unicast frames received,
1553 *excluding control frames.
1555 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1556 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_LO,
1557 IPN3KE_10G_RX_STATS_UNICAST_FRAME_OK_HI,
1559 hw_stats->eth.rx_unicast = statistics;
1561 /*36-bit statistics counter that collects the number of
1562 *unicast frames transmitted with error,
1563 *excluding control frames.
1565 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1566 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_LO,
1567 IPN3KE_10G_TX_STATS_UNICAST_FRAME_ERR_HI,
1570 /*36-bit statistics counter that collects the number of
1571 *unicast frames received with error,
1572 *excluding control frames.
1574 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1575 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_LO,
1576 IPN3KE_10G_RX_STATS_UNICAST_FRAME_ERR_HI,
1579 /*36-bit statistics counter that collects the number of
1580 *good multicast frames transmitted,
1581 *excluding control frames.
1583 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1584 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_LO,
1585 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_OK_HI,
1587 hw_stats->eth.tx_multicast = statistics;
1589 /*36-bit statistics counter that collects the number of
1590 *good multicast frames received,
1591 *excluding control frames.
1593 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1594 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_LO,
1595 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_OK_HI,
1597 hw_stats->eth.rx_multicast = statistics;
1599 /*36-bit statistics counter that collects the number of
1600 *multicast frames transmitted with error,
1601 *excluding control frames.
1603 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1604 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_LO,
1605 IPN3KE_10G_TX_STATS_MULTICAST_FRAME_ERR_HI,
1608 /*36-bit statistics counter that collects the number
1609 *of multicast frames received with error,
1610 *excluding control frames.
1612 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1613 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_LO,
1614 IPN3KE_10G_RX_STATS_MULTICAST_FRAME_ERR_HI,
1617 /*36-bit statistics counter that collects the number of
1618 *good broadcast frames transmitted,
1619 *excluding control frames.
1621 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1622 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_LO,
1623 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_OK_HI,
1625 hw_stats->eth.tx_broadcast = statistics;
1627 /*36-bit statistics counter that collects the number of
1628 *good broadcast frames received,
1629 *excluding control frames.
1631 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1632 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_LO,
1633 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_OK_HI,
1635 hw_stats->eth.rx_broadcast = statistics;
1637 /*36-bit statistics counter that collects the number
1638 *of broadcast frames transmitted with error,
1639 *excluding control frames.
1641 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1642 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_LO,
1643 IPN3KE_10G_TX_STATS_BROADCAST_FRAME_ERR_HI,
1646 /*36-bit statistics counter that collects the number of
1647 *broadcast frames received with error,
1648 *excluding control frames.
1650 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1651 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_LO,
1652 IPN3KE_10G_RX_STATS_BROADCAST_FRAME_ERR_HI,
1655 /*64-bit statistics counter that collects the total number of
1656 *octets transmitted.
1657 *This count includes good, errored, and invalid frames.
1659 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1660 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_LO,
1661 IPN3KE_10G_TX_STATS_ETHER_STATS_OCTETS_HI,
1664 /*64-bit statistics counter that collects the total number of
1666 *This count includes good, errored, and invalid frames.
1668 statistics = ipn3ke_rpst_read_64bits_statistics_register(
1669 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_LO,
1670 IPN3KE_10G_RX_STATS_ETHER_STATS_OCTETS_HI,
1673 /*36-bit statistics counter that collects the total number of
1674 *good, errored, and invalid frames transmitted.
1676 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1677 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_LO,
1678 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_HI,
1681 /*36-bit statistics counter that collects the total number of
1682 *good, errored, and invalid frames received.
1684 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1685 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_LO,
1686 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_HI,
1689 /*36-bit statistics counter that collects the number of
1690 *undersized TX frames.
1692 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1693 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1694 IPN3KE_10G_TX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1697 /*36-bit statistics counter that collects the number of
1698 *undersized RX frames.
1700 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1701 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_LO,
1702 IPN3KE_10G_RX_STATS_ETHER_STATS_UNDER_SIZE_PKTS_HI,
1704 hw_stats->rx_undersize = statistics;
1706 /*36-bit statistics counter that collects the number of
1707 *TX frames whose length exceeds the maximum frame length
1710 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1711 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1712 IPN3KE_10G_TX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1715 /*36-bit statistics counter that collects the number of
1716 *RX frames whose length exceeds the maximum frame length
1719 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1720 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_LO,
1721 IPN3KE_10G_RX_STATS_ETHER_STATS_OVER_SIZE_PKTS_HI,
1723 hw_stats->rx_oversize = statistics;
1725 /*36-bit statistics counter that collects the number of
1727 *including the CRC field
1728 *but excluding the preamble and SFD bytes.
1729 *This count includes good, errored, and invalid frames.
1731 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1732 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1733 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1735 hw_stats->tx_size_64 = statistics;
1737 /*36-bit statistics counter that collects the number of
1739 *including the CRC field
1740 *but excluding the preamble and SFD bytes.
1741 *This count includes good, errored, and invalid frames.
1743 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1744 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_LO,
1745 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_64_OCTETS_HI,
1747 hw_stats->rx_size_64 = statistics;
1749 /*36-bit statistics counter that collects the number of
1750 *TX frames between the length of 65 and 127 bytes,
1751 *including the CRC field
1752 *but excluding the preamble and SFD bytes.
1753 *This count includes good, errored, and invalid frames.
1755 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1756 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1757 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1759 hw_stats->tx_size_65_127 = statistics;
1761 /*36-bit statistics counter that collects the number of
1762 *RX frames between the length of 65 and 127 bytes,
1763 *including the CRC field
1764 *but excluding the preamble and SFD bytes.
1765 *This count includes good, errored, and invalid frames.
1767 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1768 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_LO,
1769 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_65_127_OCTETS_HI,
1771 hw_stats->rx_size_65_127 = statistics;
1773 /*36-bit statistics counter that collects the number of
1774 *TX frames between the length of 128 and 255 bytes,
1775 *including the CRC field
1776 *but excluding the preamble and SFD bytes.
1777 *This count includes good, errored, and invalid frames.
1779 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1780 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1781 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1783 hw_stats->tx_size_128_255 = statistics;
1785 /*36-bit statistics counter that collects the number of
1786 *RX frames between the length of 128 and 255 bytes,
1787 *including the CRC field
1788 *but excluding the preamble and SFD bytes.
1789 *This count includes good, errored, and invalid frames.
1791 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1792 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_LO,
1793 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_128_255_OCTETS_HI,
1795 hw_stats->rx_size_128_255 = statistics;
1797 /*36-bit statistics counter that collects the number of
1798 *TX frames between the length of 256 and 511 bytes,
1799 *including the CRC field
1800 *but excluding the preamble and SFD bytes.
1801 *This count includes good, errored, and invalid frames.
1803 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1804 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1805 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1807 hw_stats->tx_size_256_511 = statistics;
1809 /*36-bit statistics counter that collects the number of
1810 *RX frames between the length of 256 and 511 bytes,
1811 *including the CRC field
1812 *but excluding the preamble and SFD bytes.
1813 *This count includes good, errored, and invalid frames.
1815 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1816 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_LO,
1817 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_256_511_OCTETS_HI,
1819 hw_stats->rx_size_256_511 = statistics;
1821 /*36-bit statistics counter that collects the number of
1822 *TX frames between the length of 512 and 1023 bytes,
1823 *including the CRC field
1824 *but excluding the preamble and SFD bytes.
1825 *This count includes good, errored, and invalid frames.
1827 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1828 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1829 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1831 hw_stats->tx_size_512_1023 = statistics;
1833 /*36-bit statistics counter that collects the number of
1834 *RX frames between the length of 512 and 1023 bytes,
1835 *including the CRC field
1836 *but excluding the preamble and SFD bytes.
1837 *This count includes good, errored, and invalid frames.
1839 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1840 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_LO,
1841 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_512_1023_OCTETS_HI,
1843 hw_stats->rx_size_512_1023 = statistics;
1845 /*36-bit statistics counter that collects the number of
1846 *TX frames between the length of 1024 and 1518 bytes,
1847 *including the CRC field but
1848 *excluding the preamble and SFD bytes.
1849 *This count includes good, errored, and invalid frames.
1851 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1852 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1853 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1855 hw_stats->tx_size_1024_1518 = statistics;
1857 /*36-bit statistics counter that collects the number of
1858 *RX frames between the length of 1024 and 1518 bytes,
1859 *including the CRC field
1860 *but excluding the preamble and SFD bytes.
1861 *This count includes good, errored, and invalid frames.
1863 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1864 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_LO,
1865 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1024_1518_OCTETS_HI,
1867 hw_stats->rx_size_1024_1518 = statistics;
1869 /*36-bit statistics counter that collects the number of
1870 *TX frames equal or more than the length of 1,519 bytes,
1871 *including the CRC field
1872 *but excluding the preamble and SFD bytes.
1873 *This count includes good, errored, and invalid frames.
1875 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1876 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1877 IPN3KE_10G_TX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1879 hw_stats->tx_size_1519_to_max = statistics;
1881 /*36-bit statistics counter that collects the number of
1882 *RX frames equal or more than the length of 1,519 bytes,
1883 *including the CRC field
1884 *but excluding the preamble and SFD bytes.
1885 *This count includes good,
1886 *errored, and invalid frames.
1888 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1889 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_LO,
1890 IPN3KE_10G_RX_STATS_ETHER_STATS_PKTS_1519_X_OCTETS_HI,
1892 hw_stats->rx_size_big = statistics;
1894 /*36-bit statistics counter that collects the total number of
1895 *RX frames with length less than 64 bytes and CRC error.
1896 *The MAC does not drop these frames.
1898 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1899 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_LO,
1900 IPN3KE_10G_RX_STATS_ETHER_STATS_FRAGMENTS_HI,
1903 /*36-bit statistics counter that collects the number of
1904 *oversized RX frames with CRC error.
1905 *The MAC does not drop these frames.
1907 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1908 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_LO,
1909 IPN3KE_10G_RX_STATS_ETHER_STATS_JABBERS_HI,
1912 /*36-bit statistics counter that collects the number of
1913 *RX frames with CRC error,
1914 *whose length is between 64 and the maximum frame length
1915 *specified in the register.
1916 *The MAC does not drop these frames.
1918 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1919 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_LO,
1920 IPN3KE_10G_RX_STATS_ETHER_STATS_CRC_ERR_HI,
1923 /*36-bit statistics counter that collects the number of
1924 *valid TX unicast control frames.
1926 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1927 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1928 IPN3KE_10G_TX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1930 hw_stats->eth.tx_unicast += statistics;
1932 /*36-bit statistics counter that collects the number of
1933 *valid RX unicast control frames.
1935 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1936 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_LO,
1937 IPN3KE_10G_RX_STATS_UNICAST_MAC_CTRL_FRAMES_HI,
1939 hw_stats->eth.rx_unicast += statistics;
1941 /*36-bit statistics counter that collects the number of
1942 *valid TX multicast control frames.
1944 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1945 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1946 IPN3KE_10G_TX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1948 hw_stats->eth.tx_multicast += statistics;
1950 /*36-bit statistics counter that collects the number of
1951 *valid RX multicast control frames.
1953 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1954 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_LO,
1955 IPN3KE_10G_RX_STATS_MULTICAST_MAC_CTRL_FRAMES_HI,
1957 hw_stats->eth.rx_multicast += statistics;
1959 /*36-bit statistics counter that collects the number of
1960 *valid TX broadcast control frames.
1962 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1963 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1964 IPN3KE_10G_TX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1966 hw_stats->eth.tx_broadcast += statistics;
1968 /*36-bit statistics counter that collects the number of
1969 *valid RX broadcast control frames.
1971 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1972 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_LO,
1973 IPN3KE_10G_RX_STATS_BROADCAST_MAC_CTRL_FRAMES_HI,
1975 hw_stats->eth.rx_broadcast += statistics;
1977 /*36-bit statistics counter that collects the number of
1978 *valid TX PFC frames.
1980 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1981 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1982 IPN3KE_10G_TX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1985 /*36-bit statistics counter that collects the number of
1986 *valid RX PFC frames.
1988 statistics = ipn3ke_rpst_read_36bits_statistics_register(
1989 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_LO,
1990 IPN3KE_10G_RX_STATS_PFC_MAC_CTRL_FRAMES_HI,
1997 ipn3ke_rpst_10g_lineside_tx_stats_reset(struct ipn3ke_hw *hw,
2002 /*Bit [0]: Set this register to 1 to clear all TX statistics
2004 *The IP core clears this bit when all counters are cleared.
2005 *Bits [31:1]: Reserved.
2008 (*hw->f_mac_read)(hw,
2010 IPN3KE_10G_TX_STATS_CLR,
2014 (*hw->f_mac_write)(hw,
2016 IPN3KE_10G_TX_STATS_CLR,
2022 ipn3ke_rpst_10g_lineside_rx_stats_reset(struct ipn3ke_hw *hw,
2027 /*Bit [0]: Set this register to 1 to clear all RX statistics
2029 *The IP core clears this bit when all counters are cleared.
2030 *Bits [31:1]: Reserved
2033 (*hw->f_mac_read)(hw,
2035 IPN3KE_10G_RX_STATS_CLR,
2039 (*hw->f_mac_write)(hw,
2041 IPN3KE_10G_RX_STATS_CLR,
2047 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
2049 uint16_t port_id = 0;
2052 struct rte_afu_device *afu_dev = NULL;
2053 struct ipn3ke_hw *hw = NULL;
2056 IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
2060 afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
2062 IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
2066 if (!afu_dev->shared.data) {
2067 IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
2071 hw = afu_dev->shared.data;
2073 ch = ethdev->data->name;
2075 IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
2086 IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
2091 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
2092 ipn3ke_rpst_25g_nic_side_tx_stats_reset(hw, port_id);
2093 ipn3ke_rpst_25g_nic_side_rx_stats_reset(hw, port_id);
2094 ipn3ke_rpst_25g_lineside_tx_stats_reset(hw, port_id);
2095 ipn3ke_rpst_25g_lineside_rx_stats_reset(hw, port_id);
2096 } else if (hw->retimer.mac_type ==
2097 IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2098 ipn3ke_rpst_10g_nic_side_tx_stats_reset(hw, port_id);
2099 ipn3ke_rpst_10g_nic_side_rx_stats_reset(hw, port_id);
2100 ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
2101 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 = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
2600 ipn3ke_rpst_scan_handle_request, NULL);
2602 IPN3KE_AFU_PMD_ERR("Fail to create ipn3ke rpst scan thread");
2605 } else if (ipn3ke_rpst_scan_num == 0) {
2606 ret = pthread_cancel(ipn3ke_rpst_scan_thread);
2608 IPN3KE_AFU_PMD_ERR("Can't cancel the thread");
2610 ret = pthread_join(ipn3ke_rpst_scan_thread, NULL);
2612 IPN3KE_AFU_PMD_ERR("Can't join the thread");
2621 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
2623 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2624 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2625 uint32_t rddata, val;
2627 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2628 /* Enable all unicast */
2629 (*hw->f_mac_read)(hw,
2631 IPN3KE_MAC_RX_FRAME_CONTROL,
2635 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2637 (*hw->f_mac_write)(hw,
2639 IPN3KE_MAC_RX_FRAME_CONTROL,
2648 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
2650 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2651 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2652 uint32_t rddata, val;
2654 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2655 /* Disable all unicast */
2656 (*hw->f_mac_read)(hw,
2658 IPN3KE_MAC_RX_FRAME_CONTROL,
2662 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLUCAST_MASK;
2664 (*hw->f_mac_write)(hw,
2666 IPN3KE_MAC_RX_FRAME_CONTROL,
2675 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
2677 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2678 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2679 uint32_t rddata, val;
2681 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2682 /* Enable all unicast */
2683 (*hw->f_mac_read)(hw,
2685 IPN3KE_MAC_RX_FRAME_CONTROL,
2689 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2690 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2692 (*hw->f_mac_write)(hw,
2694 IPN3KE_MAC_RX_FRAME_CONTROL,
2703 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
2705 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2706 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2707 uint32_t rddata, val;
2709 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2710 /* Disable all unicast */
2711 (*hw->f_mac_read)(hw,
2713 IPN3KE_MAC_RX_FRAME_CONTROL,
2717 val <<= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_SHIFT;
2718 val &= IPN3KE_MAC_RX_FRAME_CONTROL_EN_ALLMCAST_MASK;
2720 (*hw->f_mac_write)(hw,
2722 IPN3KE_MAC_RX_FRAME_CONTROL,
2731 ipn3ke_rpst_mac_addr_set(struct rte_eth_dev *ethdev,
2732 struct rte_ether_addr *mac_addr)
2734 struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2735 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2738 if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
2739 IPN3KE_AFU_PMD_ERR("Tried to set invalid MAC address.");
2743 if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
2744 rte_ether_addr_copy(&mac_addr[0], &rpst->mac_addr);
2746 /* Set mac address */
2747 rte_memcpy(((char *)(&val)), &mac_addr[0], sizeof(uint32_t));
2748 (*hw->f_mac_write)(hw,
2750 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2753 rte_memcpy(((char *)(&val)), &mac_addr[4], sizeof(uint16_t));
2754 (*hw->f_mac_write)(hw,
2756 IPN3KE_MAC_PRIMARY_MAC_ADDR0,
2765 ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu)
2768 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2769 struct rte_eth_dev_data *dev_data = ethdev->data;
2771 /* mtu setting is forbidden if port is start */
2772 /* make sure NIC port is stopped */
2773 if (rpst->i40e_pf_eth && rpst->i40e_pf_eth->data->dev_started) {
2774 IPN3KE_AFU_PMD_ERR("NIC port %d must "
2775 "be stopped before configuration",
2776 rpst->i40e_pf_eth->data->port_id);
2779 /* mtu setting is forbidden if port is start */
2780 if (dev_data->dev_started) {
2781 IPN3KE_AFU_PMD_ERR("FPGA port %d must "
2782 "be stopped before configuration",
2787 if (rpst->i40e_pf_eth) {
2788 ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth,
2791 rpst->i40e_pf_eth->data->mtu = mtu;
2798 ipn3ke_afu_flow_ops_get(struct rte_eth_dev *ethdev,
2799 const struct rte_flow_ops **ops)
2801 struct ipn3ke_hw *hw;
2802 struct ipn3ke_rpst *rpst;
2807 hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
2808 rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2811 *ops = &ipn3ke_flow_ops;
2812 else if (rpst->i40e_pf_eth)
2813 (*rpst->i40e_pf_eth->dev_ops->flow_ops_get)(ethdev, ops);
2820 static const struct eth_dev_ops ipn3ke_rpst_dev_ops = {
2821 .dev_infos_get = ipn3ke_rpst_dev_infos_get,
2823 .dev_configure = ipn3ke_rpst_dev_configure,
2824 .dev_start = ipn3ke_rpst_dev_start,
2825 .dev_stop = ipn3ke_rpst_dev_stop,
2826 .dev_close = ipn3ke_rpst_dev_close,
2827 .dev_reset = ipn3ke_rpst_dev_reset,
2829 .stats_get = ipn3ke_rpst_stats_get,
2830 .xstats_get = ipn3ke_rpst_xstats_get,
2831 .xstats_get_names = ipn3ke_rpst_xstats_get_names,
2832 .stats_reset = ipn3ke_rpst_stats_reset,
2833 .xstats_reset = ipn3ke_rpst_stats_reset,
2835 .flow_ops_get = ipn3ke_afu_flow_ops_get,
2837 .rx_queue_start = ipn3ke_rpst_rx_queue_start,
2838 .rx_queue_stop = ipn3ke_rpst_rx_queue_stop,
2839 .tx_queue_start = ipn3ke_rpst_tx_queue_start,
2840 .tx_queue_stop = ipn3ke_rpst_tx_queue_stop,
2841 .rx_queue_setup = ipn3ke_rpst_rx_queue_setup,
2842 .tx_queue_setup = ipn3ke_rpst_tx_queue_setup,
2844 .dev_set_link_up = ipn3ke_rpst_dev_set_link_up,
2845 .dev_set_link_down = ipn3ke_rpst_dev_set_link_down,
2846 .link_update = ipn3ke_rpst_link_update,
2848 .promiscuous_enable = ipn3ke_rpst_promiscuous_enable,
2849 .promiscuous_disable = ipn3ke_rpst_promiscuous_disable,
2850 .allmulticast_enable = ipn3ke_rpst_allmulticast_enable,
2851 .allmulticast_disable = ipn3ke_rpst_allmulticast_disable,
2852 .mac_addr_set = ipn3ke_rpst_mac_addr_set,
2853 .mtu_set = ipn3ke_rpst_mtu_set,
2855 .tm_ops_get = ipn3ke_tm_ops_get,
2858 static uint16_t ipn3ke_rpst_recv_pkts(__rte_unused void *rx_q,
2859 __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
2865 ipn3ke_rpst_xmit_pkts(__rte_unused void *tx_queue,
2866 __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
2872 ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
2874 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2875 struct ipn3ke_rpst *representor_param =
2876 (struct ipn3ke_rpst *)init_params;
2878 if (representor_param->port_id >= representor_param->hw->port_num)
2881 if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
2884 rpst->ethdev = ethdev;
2885 rpst->switch_domain_id = representor_param->switch_domain_id;
2886 rpst->port_id = representor_param->port_id;
2887 rpst->hw = representor_param->hw;
2888 rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
2889 rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
2890 if (rpst->i40e_pf_eth)
2891 ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
2894 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
2895 if (!ethdev->data->mac_addrs) {
2896 IPN3KE_AFU_PMD_ERR("Failed to "
2897 "allocated memory for storing mac address");
2901 if (rpst->hw->tm_hw_enable)
2902 ipn3ke_tm_init(rpst);
2904 /* Set representor device ops */
2905 ethdev->dev_ops = &ipn3ke_rpst_dev_ops;
2907 /* No data-path, but need stub Rx/Tx functions to avoid crash
2908 * when testing with the likes of testpmd.
2910 ethdev->rx_pkt_burst = ipn3ke_rpst_recv_pkts;
2911 ethdev->tx_pkt_burst = ipn3ke_rpst_xmit_pkts;
2913 ethdev->data->nb_rx_queues = 1;
2914 ethdev->data->nb_tx_queues = 1;
2916 ethdev->data->mac_addrs = rte_zmalloc("ipn3ke_afu_representor",
2919 if (!ethdev->data->mac_addrs) {
2920 IPN3KE_AFU_PMD_ERR("Failed to "
2921 "allocated memory for storing mac address");
2925 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
2926 RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
2928 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2929 TAILQ_INSERT_TAIL(&ipn3ke_rpst_list, rpst, next);
2930 ipn3ke_rpst_scan_num++;
2931 ipn3ke_rpst_scan_check();
2932 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);
2938 ipn3ke_rpst_uninit(struct rte_eth_dev *ethdev)
2940 struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev);
2942 rte_spinlock_lock(&ipn3ke_link_notify_list_lk);
2943 TAILQ_REMOVE(&ipn3ke_rpst_list, rpst, next);
2944 ipn3ke_rpst_scan_num--;
2945 ipn3ke_rpst_scan_check();
2946 rte_spinlock_unlock(&ipn3ke_link_notify_list_lk);