Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'atlantic-fixes'

Sudarsana Reddy Kalluru says:

====================
net: atlantic: 11-2021 fixes

The patch series contains fixes for atlantic driver to improve support
of latest AQC113 chipset.

Please consider applying it to 'net' tree.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+183 -54
+14 -13
drivers/net/ethernet/aquantia/atlantic/aq_common.h
··· 40 40 41 41 #define AQ_DEVICE_ID_AQC113DEV 0x00C0 42 42 #define AQ_DEVICE_ID_AQC113CS 0x94C0 43 + #define AQ_DEVICE_ID_AQC113CA 0x34C0 43 44 #define AQ_DEVICE_ID_AQC114CS 0x93C0 44 45 #define AQ_DEVICE_ID_AQC113 0x04C0 45 46 #define AQ_DEVICE_ID_AQC113C 0x14C0 46 47 #define AQ_DEVICE_ID_AQC115C 0x12C0 48 + #define AQ_DEVICE_ID_AQC116C 0x11C0 47 49 48 50 #define HW_ATL_NIC_NAME "Marvell (aQuantia) AQtion 10Gbit Network Adapter" 49 51 ··· 55 53 56 54 #define AQ_NIC_RATE_10G BIT(0) 57 55 #define AQ_NIC_RATE_5G BIT(1) 58 - #define AQ_NIC_RATE_5GSR BIT(2) 59 - #define AQ_NIC_RATE_2G5 BIT(3) 60 - #define AQ_NIC_RATE_1G BIT(4) 61 - #define AQ_NIC_RATE_100M BIT(5) 62 - #define AQ_NIC_RATE_10M BIT(6) 63 - #define AQ_NIC_RATE_1G_HALF BIT(7) 64 - #define AQ_NIC_RATE_100M_HALF BIT(8) 65 - #define AQ_NIC_RATE_10M_HALF BIT(9) 56 + #define AQ_NIC_RATE_2G5 BIT(2) 57 + #define AQ_NIC_RATE_1G BIT(3) 58 + #define AQ_NIC_RATE_100M BIT(4) 59 + #define AQ_NIC_RATE_10M BIT(5) 60 + #define AQ_NIC_RATE_1G_HALF BIT(6) 61 + #define AQ_NIC_RATE_100M_HALF BIT(7) 62 + #define AQ_NIC_RATE_10M_HALF BIT(8) 66 63 67 - #define AQ_NIC_RATE_EEE_10G BIT(10) 68 - #define AQ_NIC_RATE_EEE_5G BIT(11) 69 - #define AQ_NIC_RATE_EEE_2G5 BIT(12) 70 - #define AQ_NIC_RATE_EEE_1G BIT(13) 71 - #define AQ_NIC_RATE_EEE_100M BIT(14) 64 + #define AQ_NIC_RATE_EEE_10G BIT(9) 65 + #define AQ_NIC_RATE_EEE_5G BIT(10) 66 + #define AQ_NIC_RATE_EEE_2G5 BIT(11) 67 + #define AQ_NIC_RATE_EEE_1G BIT(12) 68 + #define AQ_NIC_RATE_EEE_100M BIT(13) 72 69 #define AQ_NIC_RATE_EEE_MSK (AQ_NIC_RATE_EEE_10G |\ 73 70 AQ_NIC_RATE_EEE_5G |\ 74 71 AQ_NIC_RATE_EEE_2G5 |\
+2
drivers/net/ethernet/aquantia/atlantic/aq_hw.h
··· 80 80 }; 81 81 82 82 struct aq_stats_s { 83 + u64 brc; 84 + u64 btc; 83 85 u64 uprc; 84 86 u64 mprc; 85 87 u64 bprc;
+8 -2
drivers/net/ethernet/aquantia/atlantic/aq_nic.c
··· 905 905 data[++i] = stats->mbtc; 906 906 data[++i] = stats->bbrc; 907 907 data[++i] = stats->bbtc; 908 - data[++i] = stats->ubrc + stats->mbrc + stats->bbrc; 909 - data[++i] = stats->ubtc + stats->mbtc + stats->bbtc; 908 + if (stats->brc) 909 + data[++i] = stats->brc; 910 + else 911 + data[++i] = stats->ubrc + stats->mbrc + stats->bbrc; 912 + if (stats->btc) 913 + data[++i] = stats->btc; 914 + else 915 + data[++i] = stats->ubtc + stats->mbtc + stats->bbtc; 910 916 data[++i] = stats->dma_pkt_rc; 911 917 data[++i] = stats->dma_pkt_tc; 912 918 data[++i] = stats->dma_oct_rc;
+6 -1
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
··· 49 49 { PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_AQC113), }, 50 50 { PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_AQC113C), }, 51 51 { PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_AQC115C), }, 52 + { PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_AQC113CA), }, 53 + { PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_AQC116C), }, 52 54 53 55 {} 54 56 }; ··· 87 85 { AQ_DEVICE_ID_AQC113CS, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc113, }, 88 86 { AQ_DEVICE_ID_AQC114CS, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc113, }, 89 87 { AQ_DEVICE_ID_AQC113C, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc113, }, 90 - { AQ_DEVICE_ID_AQC115C, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc113, }, 88 + { AQ_DEVICE_ID_AQC115C, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc115c, }, 89 + { AQ_DEVICE_ID_AQC113CA, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc113, }, 90 + { AQ_DEVICE_ID_AQC116C, AQ_HWREV_ANY, &hw_atl2_ops, &hw_atl2_caps_aqc116c, }, 91 + 91 92 }; 92 93 93 94 MODULE_DEVICE_TABLE(pci, aq_pci_tbl);
-3
drivers/net/ethernet/aquantia/atlantic/aq_vec.c
··· 362 362 { 363 363 unsigned int count; 364 364 365 - WARN_ONCE(!aq_vec_is_valid_tc(self, tc), 366 - "Invalid tc %u (#rx=%u, #tx=%u)\n", 367 - tc, self->rx_rings, self->tx_rings); 368 365 if (!aq_vec_is_valid_tc(self, tc)) 369 366 return 0; 370 367
+13 -2
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
··· 867 867 int hw_atl_utils_update_stats(struct aq_hw_s *self) 868 868 { 869 869 struct aq_stats_s *cs = &self->curr_stats; 870 + struct aq_stats_s curr_stats = *cs; 870 871 struct hw_atl_utils_mbox mbox; 872 + bool corrupted_stats = false; 871 873 872 874 hw_atl_utils_mpi_read_stats(self, &mbox); 873 875 874 - #define AQ_SDELTA(_N_) (self->curr_stats._N_ += \ 875 - mbox.stats._N_ - self->last_stats._N_) 876 + #define AQ_SDELTA(_N_) \ 877 + do { \ 878 + if (!corrupted_stats && \ 879 + ((s64)(mbox.stats._N_ - self->last_stats._N_)) >= 0) \ 880 + curr_stats._N_ += mbox.stats._N_ - self->last_stats._N_; \ 881 + else \ 882 + corrupted_stats = true; \ 883 + } while (0) 876 884 877 885 if (self->aq_link_status.mbps) { 878 886 AQ_SDELTA(uprc); ··· 900 892 AQ_SDELTA(bbrc); 901 893 AQ_SDELTA(bbtc); 902 894 AQ_SDELTA(dpc); 895 + 896 + if (!corrupted_stats) 897 + *cs = curr_stats; 903 898 } 904 899 #undef AQ_SDELTA 905 900
-3
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
··· 132 132 if (speed & AQ_NIC_RATE_5G) 133 133 rate |= FW2X_RATE_5G; 134 134 135 - if (speed & AQ_NIC_RATE_5GSR) 136 - rate |= FW2X_RATE_5G; 137 - 138 135 if (speed & AQ_NIC_RATE_2G5) 139 136 rate |= FW2X_RATE_2G5; 140 137
+18 -4
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c
··· 65 65 AQ_NIC_RATE_5G | 66 66 AQ_NIC_RATE_2G5 | 67 67 AQ_NIC_RATE_1G | 68 - AQ_NIC_RATE_1G_HALF | 69 68 AQ_NIC_RATE_100M | 70 - AQ_NIC_RATE_100M_HALF | 71 - AQ_NIC_RATE_10M | 72 - AQ_NIC_RATE_10M_HALF, 69 + AQ_NIC_RATE_10M, 70 + }; 71 + 72 + const struct aq_hw_caps_s hw_atl2_caps_aqc115c = { 73 + DEFAULT_BOARD_BASIC_CAPABILITIES, 74 + .media_type = AQ_HW_MEDIA_TYPE_TP, 75 + .link_speed_msk = AQ_NIC_RATE_2G5 | 76 + AQ_NIC_RATE_1G | 77 + AQ_NIC_RATE_100M | 78 + AQ_NIC_RATE_10M, 79 + }; 80 + 81 + const struct aq_hw_caps_s hw_atl2_caps_aqc116c = { 82 + DEFAULT_BOARD_BASIC_CAPABILITIES, 83 + .media_type = AQ_HW_MEDIA_TYPE_TP, 84 + .link_speed_msk = AQ_NIC_RATE_1G | 85 + AQ_NIC_RATE_100M | 86 + AQ_NIC_RATE_10M, 73 87 }; 74 88 75 89 static u32 hw_atl2_sem_act_rslvr_get(struct aq_hw_s *self)
+2
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.h
··· 9 9 #include "aq_common.h" 10 10 11 11 extern const struct aq_hw_caps_s hw_atl2_caps_aqc113; 12 + extern const struct aq_hw_caps_s hw_atl2_caps_aqc115c; 13 + extern const struct aq_hw_caps_s hw_atl2_caps_aqc116c; 12 14 extern const struct aq_hw_ops hw_atl2_ops; 13 15 14 16 #endif /* HW_ATL2_H */
+34 -4
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.h
··· 239 239 u8 minor; 240 240 u16 build; 241 241 } phy; 242 - u32 rsvd; 242 + u32 drv_iface_ver:4; 243 + u32 rsvd:28; 243 244 }; 244 245 245 246 struct link_status_s { ··· 425 424 u16 rsvd2; 426 425 }; 427 426 428 - struct statistics_s { 427 + struct statistics_a0_s { 429 428 struct { 430 429 u32 link_up; 431 430 u32 link_down; ··· 456 455 } msm; 457 456 u32 main_loop_cycles; 458 457 u32 reserve_fw_gap; 458 + }; 459 + 460 + struct __packed statistics_b0_s { 461 + u64 rx_good_octets; 462 + u64 rx_pause_frames; 463 + u64 rx_good_frames; 464 + u64 rx_errors; 465 + u64 rx_unicast_frames; 466 + u64 rx_multicast_frames; 467 + u64 rx_broadcast_frames; 468 + 469 + u64 tx_good_octets; 470 + u64 tx_pause_frames; 471 + u64 tx_good_frames; 472 + u64 tx_errors; 473 + u64 tx_unicast_frames; 474 + u64 tx_multicast_frames; 475 + u64 tx_broadcast_frames; 476 + 477 + u32 main_loop_cycles; 478 + }; 479 + 480 + struct __packed statistics_s { 481 + union __packed { 482 + struct statistics_a0_s a0; 483 + struct statistics_b0_s b0; 484 + }; 459 485 }; 460 486 461 487 struct filter_caps_s { ··· 573 545 u32 rsvd5; 574 546 }; 575 547 576 - struct fw_interface_out { 548 + struct __packed fw_interface_out { 577 549 struct transaction_counter_s transaction_id; 578 550 struct version_s version; 579 551 struct link_status_s link_status; ··· 597 569 struct core_dump_s core_dump; 598 570 u32 rsvd11; 599 571 struct statistics_s stats; 600 - u32 rsvd12; 601 572 struct filter_caps_s filter_caps; 602 573 struct device_caps_s device_caps; 603 574 u32 rsvd13; ··· 618 591 #define AQ_HOST_MODE_SLEEP_PROXY 2U 619 592 #define AQ_HOST_MODE_LOW_POWER 3U 620 593 #define AQ_HOST_MODE_SHUTDOWN 4U 594 + 595 + #define AQ_A2_FW_INTERFACE_A0 0 596 + #define AQ_A2_FW_INTERFACE_B0 1 621 597 622 598 int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops); 623 599
+86 -22
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c
··· 84 84 if (cnt > AQ_A2_FW_READ_TRY_MAX) 85 85 return -ETIME; 86 86 if (tid1.transaction_cnt_a != tid1.transaction_cnt_b) 87 - udelay(1); 87 + mdelay(1); 88 88 } while (tid1.transaction_cnt_a != tid1.transaction_cnt_b); 89 89 90 90 hw_atl2_mif_shared_buf_read(self, offset, (u32 *)data, dwords); ··· 154 154 { 155 155 link_options->rate_10G = !!(speed & AQ_NIC_RATE_10G); 156 156 link_options->rate_5G = !!(speed & AQ_NIC_RATE_5G); 157 - link_options->rate_N5G = !!(speed & AQ_NIC_RATE_5GSR); 157 + link_options->rate_N5G = link_options->rate_5G; 158 158 link_options->rate_2P5G = !!(speed & AQ_NIC_RATE_2G5); 159 159 link_options->rate_N2P5G = link_options->rate_2P5G; 160 160 link_options->rate_1G = !!(speed & AQ_NIC_RATE_1G); ··· 192 192 rate |= AQ_NIC_RATE_10G; 193 193 if (lkp_link_caps->rate_5G) 194 194 rate |= AQ_NIC_RATE_5G; 195 - if (lkp_link_caps->rate_N5G) 196 - rate |= AQ_NIC_RATE_5GSR; 197 195 if (lkp_link_caps->rate_2P5G) 198 196 rate |= AQ_NIC_RATE_2G5; 199 197 if (lkp_link_caps->rate_1G) ··· 333 335 return 0; 334 336 } 335 337 336 - static int aq_a2_fw_update_stats(struct aq_hw_s *self) 338 + static void aq_a2_fill_a0_stats(struct aq_hw_s *self, 339 + struct statistics_s *stats) 337 340 { 338 341 struct hw_atl2_priv *priv = (struct hw_atl2_priv *)self->priv; 339 - struct statistics_s stats; 342 + struct aq_stats_s *cs = &self->curr_stats; 343 + struct aq_stats_s curr_stats = *cs; 344 + bool corrupted_stats = false; 340 345 341 - hw_atl2_shared_buffer_read_safe(self, stats, &stats); 342 - 343 - #define AQ_SDELTA(_N_, _F_) (self->curr_stats._N_ += \ 344 - stats.msm._F_ - priv->last_stats.msm._F_) 346 + #define AQ_SDELTA(_N, _F) \ 347 + do { \ 348 + if (!corrupted_stats && \ 349 + ((s64)(stats->a0.msm._F - priv->last_stats.a0.msm._F)) >= 0) \ 350 + curr_stats._N += stats->a0.msm._F - priv->last_stats.a0.msm._F;\ 351 + else \ 352 + corrupted_stats = true; \ 353 + } while (0) 345 354 346 355 if (self->aq_link_status.mbps) { 347 356 AQ_SDELTA(uprc, rx_unicast_frames); ··· 367 362 AQ_SDELTA(mbtc, tx_multicast_octets); 368 363 AQ_SDELTA(bbrc, rx_broadcast_octets); 369 364 AQ_SDELTA(bbtc, tx_broadcast_octets); 365 + 366 + if (!corrupted_stats) 367 + *cs = curr_stats; 370 368 } 371 369 #undef AQ_SDELTA 372 - self->curr_stats.dma_pkt_rc = 373 - hw_atl_stats_rx_dma_good_pkt_counter_get(self); 374 - self->curr_stats.dma_pkt_tc = 375 - hw_atl_stats_tx_dma_good_pkt_counter_get(self); 376 - self->curr_stats.dma_oct_rc = 377 - hw_atl_stats_rx_dma_good_octet_counter_get(self); 378 - self->curr_stats.dma_oct_tc = 379 - hw_atl_stats_tx_dma_good_octet_counter_get(self); 380 - self->curr_stats.dpc = hw_atl_rpb_rx_dma_drop_pkt_cnt_get(self); 370 + 371 + } 372 + 373 + static void aq_a2_fill_b0_stats(struct aq_hw_s *self, 374 + struct statistics_s *stats) 375 + { 376 + struct hw_atl2_priv *priv = (struct hw_atl2_priv *)self->priv; 377 + struct aq_stats_s *cs = &self->curr_stats; 378 + struct aq_stats_s curr_stats = *cs; 379 + bool corrupted_stats = false; 380 + 381 + #define AQ_SDELTA(_N, _F) \ 382 + do { \ 383 + if (!corrupted_stats && \ 384 + ((s64)(stats->b0._F - priv->last_stats.b0._F)) >= 0) \ 385 + curr_stats._N += stats->b0._F - priv->last_stats.b0._F; \ 386 + else \ 387 + corrupted_stats = true; \ 388 + } while (0) 389 + 390 + if (self->aq_link_status.mbps) { 391 + AQ_SDELTA(uprc, rx_unicast_frames); 392 + AQ_SDELTA(mprc, rx_multicast_frames); 393 + AQ_SDELTA(bprc, rx_broadcast_frames); 394 + AQ_SDELTA(erpr, rx_errors); 395 + AQ_SDELTA(brc, rx_good_octets); 396 + 397 + AQ_SDELTA(uptc, tx_unicast_frames); 398 + AQ_SDELTA(mptc, tx_multicast_frames); 399 + AQ_SDELTA(bptc, tx_broadcast_frames); 400 + AQ_SDELTA(erpt, tx_errors); 401 + AQ_SDELTA(btc, tx_good_octets); 402 + 403 + if (!corrupted_stats) 404 + *cs = curr_stats; 405 + } 406 + #undef AQ_SDELTA 407 + } 408 + 409 + static int aq_a2_fw_update_stats(struct aq_hw_s *self) 410 + { 411 + struct hw_atl2_priv *priv = (struct hw_atl2_priv *)self->priv; 412 + struct aq_stats_s *cs = &self->curr_stats; 413 + struct statistics_s stats; 414 + struct version_s version; 415 + int err; 416 + 417 + err = hw_atl2_shared_buffer_read_safe(self, version, &version); 418 + if (err) 419 + return err; 420 + 421 + err = hw_atl2_shared_buffer_read_safe(self, stats, &stats); 422 + if (err) 423 + return err; 424 + 425 + if (version.drv_iface_ver == AQ_A2_FW_INTERFACE_A0) 426 + aq_a2_fill_a0_stats(self, &stats); 427 + else 428 + aq_a2_fill_b0_stats(self, &stats); 429 + 430 + cs->dma_pkt_rc = hw_atl_stats_rx_dma_good_pkt_counter_get(self); 431 + cs->dma_pkt_tc = hw_atl_stats_tx_dma_good_pkt_counter_get(self); 432 + cs->dma_oct_rc = hw_atl_stats_rx_dma_good_octet_counter_get(self); 433 + cs->dma_oct_tc = hw_atl_stats_tx_dma_good_octet_counter_get(self); 434 + cs->dpc = hw_atl_rpb_rx_dma_drop_pkt_cnt_get(self); 381 435 382 436 memcpy(&priv->last_stats, &stats, sizeof(stats)); 383 437 ··· 563 499 hw_atl2_shared_buffer_read_safe(self, version, &version); 564 500 565 501 /* A2 FW version is stored in reverse order */ 566 - return version.mac.major << 24 | 567 - version.mac.minor << 16 | 568 - version.mac.build; 502 + return version.bundle.major << 24 | 503 + version.bundle.minor << 16 | 504 + version.bundle.build; 569 505 } 570 506 571 507 int hw_atl2_utils_get_action_resolve_table_caps(struct aq_hw_s *self,