14 #include <linux/ethtool.h>
15 #include <linux/slab.h>
16 #include <linux/pci.h>
61 if (netif_carrier_ok(dev)) {
65 ethtool_cmd_speed_set(info, -1);
81 static void vxge_ethtool_gdrvinfo(
struct net_device *dev,
84 struct vxgedev *vdev = netdev_priv(dev);
105 static void vxge_ethtool_gregs(
struct net_device *dev,
111 u64 *reg_space = (
u64 *)space;
112 struct vxgedev *vdev = netdev_priv(dev);
117 for (index = 0; index < vdev->
no_of_vpath; index++) {
122 vdev->
vpaths[index].device_id,
126 "%s:%d Getting reg dump Failed",
143 static int vxge_ethtool_idnic(
struct net_device *dev,
146 struct vxgedev *vdev = netdev_priv(dev);
174 static void vxge_ethtool_getpause_data(
struct net_device *dev,
177 struct vxgedev *vdev = netdev_priv(dev);
193 static int vxge_ethtool_setpause_data(
struct net_device *dev,
196 struct vxgedev *vdev = netdev_priv(dev);
207 static void vxge_get_ethtool_stats(
struct net_device *dev,
214 struct vxgedev *vdev = netdev_priv(dev);
226 if (xmac_stats ==
NULL) {
228 "%s : %d Memory Allocation failed for xmac_stats",
235 if (sw_stats ==
NULL) {
238 "%s : %d Memory Allocation failed for sw_stats",
245 if (hw_stats ==
NULL) {
249 "%s : %d Memory Allocation failed for hw_stats",
259 "%s : %d Failure in getting xmac stats",
266 "%s : %d Failure in getting sw stats",
273 "%s : %d hw_stats_get error", __func__, __LINE__);
290 *ptr++ = vpath_info->
tx_stats.tx_ttl_eth_frms;
291 *ptr++ = vpath_info->
tx_stats.tx_ttl_eth_octets;
292 *ptr++ = vpath_info->
tx_stats.tx_data_octets;
293 *ptr++ = vpath_info->
tx_stats.tx_mcast_frms;
294 *ptr++ = vpath_info->
tx_stats.tx_bcast_frms;
295 *ptr++ = vpath_info->
tx_stats.tx_ucast_frms;
296 *ptr++ = vpath_info->
tx_stats.tx_tagged_frms;
297 *ptr++ = vpath_info->
tx_stats.tx_vld_ip;
298 *ptr++ = vpath_info->
tx_stats.tx_vld_ip_octets;
299 *ptr++ = vpath_info->
tx_stats.tx_icmp;
300 *ptr++ = vpath_info->
tx_stats.tx_tcp;
301 *ptr++ = vpath_info->
tx_stats.tx_rst_tcp;
302 *ptr++ = vpath_info->
tx_stats.tx_udp;
303 *ptr++ = vpath_info->
tx_stats.tx_unknown_protocol;
304 *ptr++ = vpath_info->
tx_stats.tx_lost_ip;
305 *ptr++ = vpath_info->
tx_stats.tx_parse_error;
306 *ptr++ = vpath_info->
tx_stats.tx_tcp_offload;
307 *ptr++ = vpath_info->
tx_stats.tx_retx_tcp_offload;
308 *ptr++ = vpath_info->
tx_stats.tx_lost_ip_offload;
309 *ptr++ = vpath_info->
rx_stats.rx_ttl_eth_frms;
310 *ptr++ = vpath_info->
rx_stats.rx_vld_frms;
311 *ptr++ = vpath_info->
rx_stats.rx_offload_frms;
312 *ptr++ = vpath_info->
rx_stats.rx_ttl_eth_octets;
313 *ptr++ = vpath_info->
rx_stats.rx_data_octets;
314 *ptr++ = vpath_info->
rx_stats.rx_offload_octets;
315 *ptr++ = vpath_info->
rx_stats.rx_vld_mcast_frms;
316 *ptr++ = vpath_info->
rx_stats.rx_vld_bcast_frms;
317 *ptr++ = vpath_info->
rx_stats.rx_accepted_ucast_frms;
318 *ptr++ = vpath_info->
rx_stats.rx_accepted_nucast_frms;
319 *ptr++ = vpath_info->
rx_stats.rx_tagged_frms;
320 *ptr++ = vpath_info->
rx_stats.rx_long_frms;
321 *ptr++ = vpath_info->
rx_stats.rx_usized_frms;
322 *ptr++ = vpath_info->
rx_stats.rx_osized_frms;
323 *ptr++ = vpath_info->
rx_stats.rx_frag_frms;
324 *ptr++ = vpath_info->
rx_stats.rx_jabber_frms;
325 *ptr++ = vpath_info->
rx_stats.rx_ttl_64_frms;
326 *ptr++ = vpath_info->
rx_stats.rx_ttl_65_127_frms;
327 *ptr++ = vpath_info->
rx_stats.rx_ttl_128_255_frms;
328 *ptr++ = vpath_info->
rx_stats.rx_ttl_256_511_frms;
329 *ptr++ = vpath_info->
rx_stats.rx_ttl_512_1023_frms;
330 *ptr++ = vpath_info->
rx_stats.rx_ttl_1024_1518_frms;
331 *ptr++ = vpath_info->
rx_stats.rx_ttl_1519_4095_frms;
332 *ptr++ = vpath_info->
rx_stats.rx_ttl_4096_8191_frms;
333 *ptr++ = vpath_info->
rx_stats.rx_ttl_8192_max_frms;
334 *ptr++ = vpath_info->
rx_stats.rx_ttl_gt_max_frms;
335 *ptr++ = vpath_info->
rx_stats.rx_ip;
336 *ptr++ = vpath_info->
rx_stats.rx_accepted_ip;
337 *ptr++ = vpath_info->
rx_stats.rx_ip_octets;
338 *ptr++ = vpath_info->
rx_stats.rx_err_ip;
339 *ptr++ = vpath_info->
rx_stats.rx_icmp;
340 *ptr++ = vpath_info->
rx_stats.rx_tcp;
341 *ptr++ = vpath_info->
rx_stats.rx_udp;
342 *ptr++ = vpath_info->
rx_stats.rx_err_tcp;
343 *ptr++ = vpath_info->
rx_stats.rx_lost_frms;
344 *ptr++ = vpath_info->
rx_stats.rx_lost_ip;
345 *ptr++ = vpath_info->
rx_stats.rx_lost_ip_offload;
346 *ptr++ = vpath_info->
rx_stats.rx_various_discard;
347 *ptr++ = vpath_info->
rx_stats.rx_sleep_discard;
348 *ptr++ = vpath_info->
rx_stats.rx_red_discard;
349 *ptr++ = vpath_info->
rx_stats.rx_queue_full_discard;
350 *ptr++ = vpath_info->
rx_stats.rx_mpa_ok_frms;
358 *ptr++ = xmac_stats->
aggr_stats[
k].tx_discarded_frms;
359 *ptr++ = xmac_stats->
aggr_stats[
k].tx_errored_frms;
364 *ptr++ = xmac_stats->
aggr_stats[
k].rx_discarded_frms;
365 *ptr++ = xmac_stats->
aggr_stats[
k].rx_errored_frms;
366 *ptr++ = xmac_stats->
aggr_stats[
k].rx_unknown_slow_proto_frms;
378 *ptr++ = xmac_stats->
port_stats[
k].tx_vld_ip_octets;
384 *ptr++ = xmac_stats->
port_stats[
k].tx_unknown_protocol;
385 *ptr++ = xmac_stats->
port_stats[
k].tx_pause_ctrl_frms;
386 *ptr++ = xmac_stats->
port_stats[
k].tx_marker_pdu_frms;
389 *ptr++ = xmac_stats->
port_stats[
k].tx_marker_resp_pdu_frms;
390 *ptr++ = xmac_stats->
port_stats[
k].tx_xgmii_char2_match;
391 *ptr++ = xmac_stats->
port_stats[
k].tx_xgmii_char1_match;
392 *ptr++ = xmac_stats->
port_stats[
k].tx_xgmii_column2_match;
393 *ptr++ = xmac_stats->
port_stats[
k].tx_xgmii_column1_match;
394 *ptr++ = xmac_stats->
port_stats[
k].tx_any_err_frms;
398 *ptr++ = xmac_stats->
port_stats[
k].rx_offload_frms;
401 *ptr++ = xmac_stats->
port_stats[
k].rx_offload_octets;
402 *ptr++ = xmac_stats->
port_stats[
k].rx_vld_mcast_frms;
403 *ptr++ = xmac_stats->
port_stats[
k].rx_vld_bcast_frms;
404 *ptr++ = xmac_stats->
port_stats[
k].rx_accepted_ucast_frms;
405 *ptr++ = xmac_stats->
port_stats[
k].rx_accepted_nucast_frms;
413 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_65_127_frms;
414 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_128_255_frms;
415 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_256_511_frms;
416 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_512_1023_frms;
417 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_1024_1518_frms;
418 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_1519_4095_frms;
419 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_4096_8191_frms;
420 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_8192_max_frms;
421 *ptr++ = xmac_stats->
port_stats[
k].rx_ttl_gt_max_frms;
431 *ptr++ = xmac_stats->
port_stats[
k].rx_pause_ctrl_frms;
432 *ptr++ = xmac_stats->
port_stats[
k].rx_unsup_ctrl_frms;
433 *ptr++ = xmac_stats->
port_stats[
k].rx_fcs_err_frms;
434 *ptr++ = xmac_stats->
port_stats[
k].rx_in_rng_len_err_frms;
435 *ptr++ = xmac_stats->
port_stats[
k].rx_out_rng_len_err_frms;
437 *ptr++ = xmac_stats->
port_stats[
k].rx_discarded_frms;
440 *ptr++ = xmac_stats->
port_stats[
k].rx_marker_pdu_frms;
442 *ptr++ = xmac_stats->
port_stats[
k].rx_unknown_pdu_frms;
443 *ptr++ = xmac_stats->
port_stats[
k].rx_marker_resp_pdu_frms;
445 *ptr++ = xmac_stats->
port_stats[
k].rx_illegal_pdu_frms;
446 *ptr++ = xmac_stats->
port_stats[
k].rx_switch_discard;
449 *ptr++ = xmac_stats->
port_stats[
k].rx_l2_mgmt_discard;
451 *ptr++ = xmac_stats->
port_stats[
k].rx_trash_discard;
452 *ptr++ = xmac_stats->
port_stats[
k].rx_buff_full_discard;
454 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_ctrl_err_cnt;
455 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_data_err_cnt;
456 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_char1_match;
457 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_err_sym;
458 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_column1_match;
459 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_char2_match;
461 *ptr++ = xmac_stats->
port_stats[
k].rx_xgmii_column2_match;
463 *ptr++ = xmac_stats->
port_stats[
k].rx_remote_fault;
476 *ptr++ = vpath_info->
error_stats.network_sustained_fault;
477 *ptr++ = vpath_info->
error_stats.network_sustained_ok;
478 *ptr++ = vpath_info->
error_stats.kdfcctl_fifo0_overwrite;
479 *ptr++ = vpath_info->
error_stats.kdfcctl_fifo0_poison;
480 *ptr++ = vpath_info->
error_stats.kdfcctl_fifo0_dma_error;
481 *ptr++ = vpath_info->
error_stats.dblgen_fifo0_overflow;
482 *ptr++ = vpath_info->
error_stats.statsb_pif_chain_error;
483 *ptr++ = vpath_info->
error_stats.statsb_drop_timeout;
484 *ptr++ = vpath_info->
error_stats.target_illegal_access;
488 *ptr++ = vpath_info->
error_stats.prc_rxdcm_sc_abort;
489 *ptr++ = vpath_info->
error_stats.prc_quanta_size_err;
490 *ptr++ = vpath_info->
ring_stats.common_stats.full_cnt;
491 *ptr++ = vpath_info->
ring_stats.common_stats.usage_cnt;
492 *ptr++ = vpath_info->
ring_stats.common_stats.usage_max;
494 reserve_free_swaps_cnt;
495 *ptr++ = vpath_info->
ring_stats.common_stats.total_compl_cnt;
497 *ptr++ = vpath_info->
ring_stats.rxd_t_code_err_cnt[j];
498 *ptr++ = vpath_info->
fifo_stats.common_stats.full_cnt;
499 *ptr++ = vpath_info->
fifo_stats.common_stats.usage_cnt;
500 *ptr++ = vpath_info->
fifo_stats.common_stats.usage_max;
502 reserve_free_swaps_cnt;
503 *ptr++ = vpath_info->
fifo_stats.common_stats.total_compl_cnt;
505 *ptr++ = vpath_info->
fifo_stats.total_buffers;
507 *ptr++ = vpath_info->
fifo_stats.txd_t_code_err_cnt[j];
551 *ptr++ = vdev->
stats.vpaths_open;
552 *ptr++ = vdev->
stats.vpath_open_fail;
553 *ptr++ = vdev->
stats.link_up;
554 *ptr++ = vdev->
stats.link_down;
557 *ptr += vdev->
vpaths[
k].fifo.stats.tx_frms;
558 *(ptr + 1) += vdev->
vpaths[k].fifo.stats.tx_errors;
559 *(ptr + 2) += vdev->
vpaths[
k].fifo.stats.tx_bytes;
560 *(ptr + 3) += vdev->
vpaths[k].fifo.stats.txd_not_free;
561 *(ptr + 4) += vdev->
vpaths[
k].fifo.stats.txd_out_of_desc;
562 *(ptr + 5) += vdev->
vpaths[k].ring.stats.rx_frms;
563 *(ptr + 6) += vdev->
vpaths[
k].ring.stats.rx_errors;
564 *(ptr + 7) += vdev->
vpaths[k].ring.stats.rx_bytes;
565 *(ptr + 8) += vdev->
vpaths[
k].ring.stats.rx_mcast;
566 *(ptr + 9) += vdev->
vpaths[k].fifo.stats.pci_map_fail +
567 vdev->
vpaths[k].ring.stats.pci_map_fail;
568 *(ptr + 10) += vdev->
vpaths[
k].ring.stats.skb_alloc_fail;
578 static void vxge_ethtool_get_strings(
struct net_device *dev,
u32 stringset,
583 struct vxgedev *vdev = netdev_priv(dev);
587 &stat_size, data,
"");
590 &stat_size, data, i);
592 &stat_size, data, i);
594 &stat_size, data, i);
596 &stat_size, data, i);
598 &stat_size, data, i);
600 &stat_size, data, i);
602 &stat_size, data, i);
604 &stat_size, data, i);
606 &stat_size, data, i);
608 &stat_size, data, i);
610 &stat_size, data, i);
612 &stat_size, data, i);
614 &stat_size, data, i);
616 &stat_size, data, i);
618 &stat_size, data, i);
620 &stat_size, data, i);
622 &stat_size, data, i);
624 &stat_size, data, i);
626 &stat_size, data, i);
628 &stat_size, data, i);
630 &stat_size, data, i);
632 &stat_size, data, i);
634 &stat_size, data, i);
636 &stat_size, data, i);
638 &stat_size, data, i);
640 &stat_size, data, i);
642 &stat_size, data, i);
644 &stat_size, data, i);
646 &stat_size, data, i);
648 &stat_size, data, i);
650 &stat_size, data, i);
652 &stat_size, data, i);
654 &stat_size, data, i);
656 &stat_size, data, i);
658 &stat_size, data, i);
660 &stat_size, data, i);
662 &stat_size, data, i);
664 &stat_size, data, i);
666 &stat_size, data, i);
668 &stat_size, data, i);
670 &stat_size, data, i);
672 &stat_size, data, i);
674 &stat_size, data, i);
676 &stat_size, data, i);
678 &stat_size, data, i);
680 &stat_size, data, i);
682 &stat_size, data, i);
684 &stat_size, data, i);
686 &stat_size, data, i);
688 &stat_size, data, i);
690 &stat_size, data, i);
692 &stat_size, data, i);
694 &stat_size, data, i);
696 &stat_size, data, i);
698 &stat_size, data, i);
700 &stat_size, data, i);
702 &stat_size, data, i);
704 &stat_size, data, i);
706 &stat_size, data, i);
708 &stat_size, data, i);
710 &stat_size, data, i);
714 &stat_size, data,
"");
717 &stat_size, data, i);
719 &stat_size, data, i);
721 &stat_size, data, i);
723 &stat_size, data, i);
725 &stat_size, data, i);
727 &stat_size, data, i);
729 &stat_size, data, i);
731 &stat_size, data, i);
733 &stat_size, data, i);
735 &stat_size, data, i);
737 &stat_size, data, i);
739 &stat_size, data, i);
741 &stat_size, data, i);
745 &stat_size, data,
"");
748 &stat_size, data, i);
750 &stat_size, data, i);
752 &stat_size, data, i);
754 &stat_size, data, i);
756 &stat_size, data, i);
758 &stat_size, data, i);
760 &stat_size, data, i);
762 &stat_size, data, i);
764 &stat_size, data, i);
766 &stat_size, data, i);
768 &stat_size, data, i);
770 &stat_size, data, i);
772 &stat_size, data, i);
774 &stat_size, data, i);
776 &stat_size, data, i);
778 &stat_size, data, i);
780 &stat_size, data, i);
782 &stat_size, data, i);
784 &stat_size, data, i);
786 &stat_size, data, i);
788 &stat_size, data, i);
790 &stat_size, data, i);
792 &stat_size, data, i);
794 &stat_size, data, i);
796 &stat_size, data, i);
798 &stat_size, data, i);
800 &stat_size, data, i);
802 &stat_size, data, i);
804 &stat_size, data, i);
806 &stat_size, data, i);
808 &stat_size, data, i);
810 &stat_size, data, i);
812 &stat_size, data, i);
814 &stat_size, data, i);
816 &stat_size, data, i);
818 &stat_size, data, i);
820 &stat_size, data, i);
822 &stat_size, data, i);
824 &stat_size, data, i);
826 &stat_size, data, i);
828 &stat_size, data, i);
830 &stat_size, data, i);
832 &stat_size, data, i);
834 &stat_size, data, i);
836 &stat_size, data, i);
838 &stat_size, data, i);
840 &stat_size, data, i);
842 &stat_size, data, i);
844 &stat_size, data, i);
846 &stat_size, data, i);
848 &stat_size, data, i);
850 &stat_size, data, i);
852 &stat_size, data, i);
854 &stat_size, data, i);
856 &stat_size, data, i);
858 &stat_size, data, i);
860 &stat_size, data, i);
862 &stat_size, data, i);
864 &stat_size, data, i);
866 &stat_size, data, i);
868 &stat_size, data, i);
870 &stat_size, data, i);
872 &stat_size, data, i);
874 &stat_size, data, i);
876 &stat_size, data, i);
878 &stat_size, data, i);
880 &stat_size, data, i);
882 &stat_size, data, i);
884 &stat_size, data, i);
886 &stat_size, data, i);
888 &stat_size, data, i);
890 &stat_size, data, i);
892 &stat_size, data, i);
894 &stat_size, data, i);
896 &stat_size, data, i);
898 &stat_size, data, i);
900 &stat_size, data, i);
902 &stat_size, data, i);
904 &stat_size, data, i);
906 &stat_size, data, i);
908 &stat_size, data, i);
910 &stat_size, data, i);
912 &stat_size, data, i);
914 &stat_size, data, i);
916 &stat_size, data, i);
918 &stat_size, data, i);
920 &stat_size, data, i);
922 &stat_size, data, i);
924 &stat_size, data, i);
926 &stat_size, data, i);
928 &stat_size, data, i);
930 &stat_size, data, i);
932 &stat_size, data, i);
934 &stat_size, data, i);
938 &stat_size, data,
"");
941 &stat_size, data, i);
943 &stat_size, data, i);
945 &stat_size, data, i);
947 &stat_size, data, i);
949 &stat_size, data, i);
951 &stat_size, data, i);
953 &stat_size, data, i);
955 &stat_size, data, i);
957 &stat_size, data, i);
959 &stat_size, data, i);
961 &stat_size, data, i);
963 &stat_size, data, i);
965 &stat_size, data, i);
967 &stat_size, data, i);
969 &stat_size, data, i);
971 &stat_size, data, i);
973 &stat_size, data, i);
975 &stat_size, data, i);
977 &stat_size, data, i);
979 &stat_size, data, i);
981 &stat_size, data, i);
984 &stat_size, data, j, i);
986 &stat_size, data, i);
988 &stat_size, data, i);
990 &stat_size, data, i);
992 &stat_size, data, i);
994 &stat_size, data, i);
996 &stat_size, data, i);
998 &stat_size, data, i);
1001 &stat_size, data, j, i);
1005 &stat_size, data,
"");
1008 &stat_size, data, i);
1010 &stat_size, data, i);
1012 &stat_size, data, i);
1014 &stat_size, data, i);
1016 &stat_size, data, i);
1018 &stat_size, data, i);
1020 &stat_size, data, i);
1022 &stat_size, data, i);
1024 &stat_size, data, i);
1026 &stat_size, data, i);
1028 &stat_size, data, i);
1030 &stat_size, data, i);
1032 &stat_size, data, i);
1034 &stat_size, data, i);
1036 &stat_size, data, i);
1038 &stat_size, data, i);
1040 &stat_size, data, i);
1042 &stat_size, data, i);
1044 &stat_size, data, i);
1046 &stat_size, data, i);
1048 &stat_size, data, i);
1050 &stat_size, data, i);
1052 &stat_size, data, i);
1054 &stat_size, data, i);
1056 &stat_size, data, i);
1058 &stat_size, data, i);
1060 &stat_size, data, i);
1063 memcpy(data + stat_size, ðtool_driver_stats_keys,
1064 sizeof(ethtool_driver_stats_keys));
1068 static int vxge_ethtool_get_regs_len(
struct net_device *dev)
1070 struct vxgedev *vdev = netdev_priv(dev);
1075 static int vxge_ethtool_get_sset_count(
struct net_device *dev,
int sset)
1077 struct vxgedev *vdev = netdev_priv(dev);
1096 struct vxgedev *vdev = netdev_priv(dev);
1104 if (netif_running(dev)) {
1106 "firmware\n", dev->
name);
1113 static const struct ethtool_ops vxge_ethtool_ops = {
1114 .get_settings = vxge_ethtool_gset,
1115 .set_settings = vxge_ethtool_sset,
1116 .get_drvinfo = vxge_ethtool_gdrvinfo,
1117 .get_regs_len = vxge_ethtool_get_regs_len,
1118 .get_regs = vxge_ethtool_gregs,
1120 .get_pauseparam = vxge_ethtool_getpause_data,
1121 .set_pauseparam = vxge_ethtool_setpause_data,
1122 .get_strings = vxge_ethtool_get_strings,
1123 .set_phys_id = vxge_ethtool_idnic,
1124 .get_sset_count = vxge_ethtool_get_sset_count,
1125 .get_ethtool_stats = vxge_get_ethtool_stats,
1126 .flash_device = vxge_fw_flash,