@@ -1117,6 +1117,77 @@ static void efx_remove_port(struct efx_nic *efx)
1117
1117
*
1118
1118
**************************************************************************/
1119
1119
1120
+ static LIST_HEAD (efx_primary_list );
1121
+ static LIST_HEAD (efx_unassociated_list );
1122
+
1123
+ static bool efx_same_controller (struct efx_nic * left , struct efx_nic * right )
1124
+ {
1125
+ return left -> type == right -> type &&
1126
+ left -> vpd_sn && right -> vpd_sn &&
1127
+ !strcmp (left -> vpd_sn , right -> vpd_sn );
1128
+ }
1129
+
1130
+ static void efx_associate (struct efx_nic * efx )
1131
+ {
1132
+ struct efx_nic * other , * next ;
1133
+
1134
+ if (efx -> primary == efx ) {
1135
+ /* Adding primary function; look for secondaries */
1136
+
1137
+ netif_dbg (efx , probe , efx -> net_dev , "adding to primary list\n" );
1138
+ list_add_tail (& efx -> node , & efx_primary_list );
1139
+
1140
+ list_for_each_entry_safe (other , next , & efx_unassociated_list ,
1141
+ node ) {
1142
+ if (efx_same_controller (efx , other )) {
1143
+ list_del (& other -> node );
1144
+ netif_dbg (other , probe , other -> net_dev ,
1145
+ "moving to secondary list of %s %s\n" ,
1146
+ pci_name (efx -> pci_dev ),
1147
+ efx -> net_dev -> name );
1148
+ list_add_tail (& other -> node ,
1149
+ & efx -> secondary_list );
1150
+ other -> primary = efx ;
1151
+ }
1152
+ }
1153
+ } else {
1154
+ /* Adding secondary function; look for primary */
1155
+
1156
+ list_for_each_entry (other , & efx_primary_list , node ) {
1157
+ if (efx_same_controller (efx , other )) {
1158
+ netif_dbg (efx , probe , efx -> net_dev ,
1159
+ "adding to secondary list of %s %s\n" ,
1160
+ pci_name (other -> pci_dev ),
1161
+ other -> net_dev -> name );
1162
+ list_add_tail (& efx -> node ,
1163
+ & other -> secondary_list );
1164
+ efx -> primary = other ;
1165
+ return ;
1166
+ }
1167
+ }
1168
+
1169
+ netif_dbg (efx , probe , efx -> net_dev ,
1170
+ "adding to unassociated list\n" );
1171
+ list_add_tail (& efx -> node , & efx_unassociated_list );
1172
+ }
1173
+ }
1174
+
1175
+ static void efx_dissociate (struct efx_nic * efx )
1176
+ {
1177
+ struct efx_nic * other , * next ;
1178
+
1179
+ list_del (& efx -> node );
1180
+ efx -> primary = NULL ;
1181
+
1182
+ list_for_each_entry_safe (other , next , & efx -> secondary_list , node ) {
1183
+ list_del (& other -> node );
1184
+ netif_dbg (other , probe , other -> net_dev ,
1185
+ "moving to unassociated list\n" );
1186
+ list_add_tail (& other -> node , & efx_unassociated_list );
1187
+ other -> primary = NULL ;
1188
+ }
1189
+ }
1190
+
1120
1191
/* This configures the PCI device to enable I/O and DMA. */
1121
1192
static int efx_init_io (struct efx_nic * efx )
1122
1193
{
@@ -2214,6 +2285,8 @@ static int efx_register_netdev(struct efx_nic *efx)
2214
2285
efx_init_tx_queue_core_txq (tx_queue );
2215
2286
}
2216
2287
2288
+ efx_associate (efx );
2289
+
2217
2290
rtnl_unlock ();
2218
2291
2219
2292
rc = device_create_file (& efx -> pci_dev -> dev , & dev_attr_phy_type );
@@ -2227,6 +2300,7 @@ static int efx_register_netdev(struct efx_nic *efx)
2227
2300
2228
2301
fail_registered :
2229
2302
rtnl_lock ();
2303
+ efx_dissociate (efx );
2230
2304
unregister_netdevice (net_dev );
2231
2305
fail_locked :
2232
2306
efx -> state = STATE_UNINIT ;
@@ -2568,6 +2642,8 @@ static int efx_init_struct(struct efx_nic *efx,
2568
2642
int i ;
2569
2643
2570
2644
/* Initialise common structures */
2645
+ INIT_LIST_HEAD (& efx -> node );
2646
+ INIT_LIST_HEAD (& efx -> secondary_list );
2571
2647
spin_lock_init (& efx -> biu_lock );
2572
2648
#ifdef CONFIG_SFC_MTD
2573
2649
INIT_LIST_HEAD (& efx -> mtd_list );
@@ -2586,6 +2662,8 @@ static int efx_init_struct(struct efx_nic *efx,
2586
2662
NET_IP_ALIGN ? (efx -> rx_prefix_size + NET_IP_ALIGN ) % 4 : 0 ;
2587
2663
efx -> rx_packet_hash_offset =
2588
2664
efx -> type -> rx_hash_offset - efx -> type -> rx_prefix_size ;
2665
+ efx -> rx_packet_ts_offset =
2666
+ efx -> type -> rx_ts_offset - efx -> type -> rx_prefix_size ;
2589
2667
spin_lock_init (& efx -> stats_lock );
2590
2668
mutex_init (& efx -> mac_lock );
2591
2669
efx -> phy_op = & efx_dummy_phy_operations ;
@@ -2626,6 +2704,8 @@ static void efx_fini_struct(struct efx_nic *efx)
2626
2704
for (i = 0 ; i < EFX_MAX_CHANNELS ; i ++ )
2627
2705
kfree (efx -> channel [i ]);
2628
2706
2707
+ kfree (efx -> vpd_sn );
2708
+
2629
2709
if (efx -> workqueue ) {
2630
2710
destroy_workqueue (efx -> workqueue );
2631
2711
efx -> workqueue = NULL ;
@@ -2670,6 +2750,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
2670
2750
2671
2751
/* Mark the NIC as fini, then stop the interface */
2672
2752
rtnl_lock ();
2753
+ efx_dissociate (efx );
2673
2754
dev_close (efx -> net_dev );
2674
2755
efx_disable_interrupts (efx );
2675
2756
rtnl_unlock ();
@@ -2696,12 +2777,12 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
2696
2777
* always appear within the first 512 bytes.
2697
2778
*/
2698
2779
#define SFC_VPD_LEN 512
2699
- static void efx_print_product_vpd (struct efx_nic * efx )
2780
+ static void efx_probe_vpd_strings (struct efx_nic * efx )
2700
2781
{
2701
2782
struct pci_dev * dev = efx -> pci_dev ;
2702
2783
char vpd_data [SFC_VPD_LEN ];
2703
2784
ssize_t vpd_size ;
2704
- int i , j ;
2785
+ int ro_start , ro_size , i , j ;
2705
2786
2706
2787
/* Get the vpd data from the device */
2707
2788
vpd_size = pci_read_vpd (dev , 0 , sizeof (vpd_data ), vpd_data );
@@ -2711,14 +2792,15 @@ static void efx_print_product_vpd(struct efx_nic *efx)
2711
2792
}
2712
2793
2713
2794
/* Get the Read only section */
2714
- i = pci_vpd_find_tag (vpd_data , 0 , vpd_size , PCI_VPD_LRDT_RO_DATA );
2715
- if (i < 0 ) {
2795
+ ro_start = pci_vpd_find_tag (vpd_data , 0 , vpd_size , PCI_VPD_LRDT_RO_DATA );
2796
+ if (ro_start < 0 ) {
2716
2797
netif_err (efx , drv , efx -> net_dev , "VPD Read-only not found\n" );
2717
2798
return ;
2718
2799
}
2719
2800
2720
- j = pci_vpd_lrdt_size (& vpd_data [i ]);
2721
- i += PCI_VPD_LRDT_TAG_SIZE ;
2801
+ ro_size = pci_vpd_lrdt_size (& vpd_data [ro_start ]);
2802
+ j = ro_size ;
2803
+ i = ro_start + PCI_VPD_LRDT_TAG_SIZE ;
2722
2804
if (i + j > vpd_size )
2723
2805
j = vpd_size - i ;
2724
2806
@@ -2738,6 +2820,27 @@ static void efx_print_product_vpd(struct efx_nic *efx)
2738
2820
2739
2821
netif_info (efx , drv , efx -> net_dev ,
2740
2822
"Part Number : %.*s\n" , j , & vpd_data [i ]);
2823
+
2824
+ i = ro_start + PCI_VPD_LRDT_TAG_SIZE ;
2825
+ j = ro_size ;
2826
+ i = pci_vpd_find_info_keyword (vpd_data , i , j , "SN" );
2827
+ if (i < 0 ) {
2828
+ netif_err (efx , drv , efx -> net_dev , "Serial number not found\n" );
2829
+ return ;
2830
+ }
2831
+
2832
+ j = pci_vpd_info_field_size (& vpd_data [i ]);
2833
+ i += PCI_VPD_INFO_FLD_HDR_SIZE ;
2834
+ if (i + j > vpd_size ) {
2835
+ netif_err (efx , drv , efx -> net_dev , "Incomplete serial number\n" );
2836
+ return ;
2837
+ }
2838
+
2839
+ efx -> vpd_sn = kmalloc (j + 1 , GFP_KERNEL );
2840
+ if (!efx -> vpd_sn )
2841
+ return ;
2842
+
2843
+ snprintf (efx -> vpd_sn , j + 1 , "%s" , & vpd_data [i ]);
2741
2844
}
2742
2845
2743
2846
@@ -2834,7 +2937,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
2834
2937
netif_info (efx , probe , efx -> net_dev ,
2835
2938
"Solarflare NIC detected\n" );
2836
2939
2837
- efx_print_product_vpd (efx );
2940
+ efx_probe_vpd_strings (efx );
2838
2941
2839
2942
/* Set up basic I/O (BAR mappings etc) */
2840
2943
rc = efx_init_io (efx );
0 commit comments