@@ -946,6 +946,68 @@ static void qed_update_pf_params(struct qed_dev *cdev,
946946 }
947947}
948948
949+ static void qed_slowpath_wq_stop (struct qed_dev * cdev )
950+ {
951+ int i ;
952+
953+ if (IS_VF (cdev ))
954+ return ;
955+
956+ for_each_hwfn (cdev , i ) {
957+ if (!cdev -> hwfns [i ].slowpath_wq )
958+ continue ;
959+
960+ flush_workqueue (cdev -> hwfns [i ].slowpath_wq );
961+ destroy_workqueue (cdev -> hwfns [i ].slowpath_wq );
962+ }
963+ }
964+
965+ static void qed_slowpath_task (struct work_struct * work )
966+ {
967+ struct qed_hwfn * hwfn = container_of (work , struct qed_hwfn ,
968+ slowpath_task .work );
969+ struct qed_ptt * ptt = qed_ptt_acquire (hwfn );
970+
971+ if (!ptt ) {
972+ queue_delayed_work (hwfn -> slowpath_wq , & hwfn -> slowpath_task , 0 );
973+ return ;
974+ }
975+
976+ if (test_and_clear_bit (QED_SLOWPATH_MFW_TLV_REQ ,
977+ & hwfn -> slowpath_task_flags ))
978+ qed_mfw_process_tlv_req (hwfn , ptt );
979+
980+ qed_ptt_release (hwfn , ptt );
981+ }
982+
983+ static int qed_slowpath_wq_start (struct qed_dev * cdev )
984+ {
985+ struct qed_hwfn * hwfn ;
986+ char name [NAME_SIZE ];
987+ int i ;
988+
989+ if (IS_VF (cdev ))
990+ return 0 ;
991+
992+ for_each_hwfn (cdev , i ) {
993+ hwfn = & cdev -> hwfns [i ];
994+
995+ snprintf (name , NAME_SIZE , "slowpath-%02x:%02x.%02x" ,
996+ cdev -> pdev -> bus -> number ,
997+ PCI_SLOT (cdev -> pdev -> devfn ), hwfn -> abs_pf_id );
998+
999+ hwfn -> slowpath_wq = alloc_workqueue (name , 0 , 0 );
1000+ if (!hwfn -> slowpath_wq ) {
1001+ DP_NOTICE (hwfn , "Cannot create slowpath workqueue\n" );
1002+ return - ENOMEM ;
1003+ }
1004+
1005+ INIT_DELAYED_WORK (& hwfn -> slowpath_task , qed_slowpath_task );
1006+ }
1007+
1008+ return 0 ;
1009+ }
1010+
9491011static int qed_slowpath_start (struct qed_dev * cdev ,
9501012 struct qed_slowpath_params * params )
9511013{
@@ -961,6 +1023,9 @@ static int qed_slowpath_start(struct qed_dev *cdev,
9611023 if (qed_iov_wq_start (cdev ))
9621024 goto err ;
9631025
1026+ if (qed_slowpath_wq_start (cdev ))
1027+ goto err ;
1028+
9641029 if (IS_PF (cdev )) {
9651030 rc = request_firmware (& cdev -> firmware , QED_FW_FILE_NAME ,
9661031 & cdev -> pdev -> dev );
@@ -1095,6 +1160,8 @@ static int qed_slowpath_start(struct qed_dev *cdev,
10951160
10961161 qed_iov_wq_stop (cdev , false);
10971162
1163+ qed_slowpath_wq_stop (cdev );
1164+
10981165 return rc ;
10991166}
11001167
@@ -1103,6 +1170,8 @@ static int qed_slowpath_stop(struct qed_dev *cdev)
11031170 if (!cdev )
11041171 return - ENODEV ;
11051172
1173+ qed_slowpath_wq_stop (cdev );
1174+
11061175 qed_ll2_dealloc_if (cdev );
11071176
11081177 if (IS_PF (cdev )) {
@@ -2089,8 +2158,88 @@ void qed_get_protocol_stats(struct qed_dev *cdev,
20892158 }
20902159}
20912160
2161+ int qed_mfw_tlv_req (struct qed_hwfn * hwfn )
2162+ {
2163+ DP_VERBOSE (hwfn -> cdev , NETIF_MSG_DRV ,
2164+ "Scheduling slowpath task [Flag: %d]\n" ,
2165+ QED_SLOWPATH_MFW_TLV_REQ );
2166+ smp_mb__before_atomic ();
2167+ set_bit (QED_SLOWPATH_MFW_TLV_REQ , & hwfn -> slowpath_task_flags );
2168+ smp_mb__after_atomic ();
2169+ queue_delayed_work (hwfn -> slowpath_wq , & hwfn -> slowpath_task , 0 );
2170+
2171+ return 0 ;
2172+ }
2173+
2174+ static void
2175+ qed_fill_generic_tlv_data (struct qed_dev * cdev , struct qed_mfw_tlv_generic * tlv )
2176+ {
2177+ struct qed_common_cb_ops * op = cdev -> protocol_ops .common ;
2178+ struct qed_eth_stats_common * p_common ;
2179+ struct qed_generic_tlvs gen_tlvs ;
2180+ struct qed_eth_stats stats ;
2181+ int i ;
2182+
2183+ memset (& gen_tlvs , 0 , sizeof (gen_tlvs ));
2184+ op -> get_generic_tlv_data (cdev -> ops_cookie , & gen_tlvs );
2185+
2186+ if (gen_tlvs .feat_flags & QED_TLV_IP_CSUM )
2187+ tlv -> flags .ipv4_csum_offload = true;
2188+ if (gen_tlvs .feat_flags & QED_TLV_LSO )
2189+ tlv -> flags .lso_supported = true;
2190+ tlv -> flags .b_set = true;
2191+
2192+ for (i = 0 ; i < QED_TLV_MAC_COUNT ; i ++ ) {
2193+ if (is_valid_ether_addr (gen_tlvs .mac [i ])) {
2194+ ether_addr_copy (tlv -> mac [i ], gen_tlvs .mac [i ]);
2195+ tlv -> mac_set [i ] = true;
2196+ }
2197+ }
2198+
2199+ qed_get_vport_stats (cdev , & stats );
2200+ p_common = & stats .common ;
2201+ tlv -> rx_frames = p_common -> rx_ucast_pkts + p_common -> rx_mcast_pkts +
2202+ p_common -> rx_bcast_pkts ;
2203+ tlv -> rx_frames_set = true;
2204+ tlv -> rx_bytes = p_common -> rx_ucast_bytes + p_common -> rx_mcast_bytes +
2205+ p_common -> rx_bcast_bytes ;
2206+ tlv -> rx_bytes_set = true;
2207+ tlv -> tx_frames = p_common -> tx_ucast_pkts + p_common -> tx_mcast_pkts +
2208+ p_common -> tx_bcast_pkts ;
2209+ tlv -> tx_frames_set = true;
2210+ tlv -> tx_bytes = p_common -> tx_ucast_bytes + p_common -> tx_mcast_bytes +
2211+ p_common -> tx_bcast_bytes ;
2212+ tlv -> rx_bytes_set = true;
2213+ }
2214+
20922215int qed_mfw_fill_tlv_data (struct qed_hwfn * hwfn , enum qed_mfw_tlv_type type ,
20932216 union qed_mfw_tlv_data * tlv_buf )
20942217{
2095- return - EINVAL ;
2218+ struct qed_dev * cdev = hwfn -> cdev ;
2219+ struct qed_common_cb_ops * ops ;
2220+
2221+ ops = cdev -> protocol_ops .common ;
2222+ if (!ops || !ops -> get_protocol_tlv_data || !ops -> get_generic_tlv_data ) {
2223+ DP_NOTICE (hwfn , "Can't collect TLV management info\n" );
2224+ return - EINVAL ;
2225+ }
2226+
2227+ switch (type ) {
2228+ case QED_MFW_TLV_GENERIC :
2229+ qed_fill_generic_tlv_data (hwfn -> cdev , & tlv_buf -> generic );
2230+ break ;
2231+ case QED_MFW_TLV_ETH :
2232+ ops -> get_protocol_tlv_data (cdev -> ops_cookie , & tlv_buf -> eth );
2233+ break ;
2234+ case QED_MFW_TLV_FCOE :
2235+ ops -> get_protocol_tlv_data (cdev -> ops_cookie , & tlv_buf -> fcoe );
2236+ break ;
2237+ case QED_MFW_TLV_ISCSI :
2238+ ops -> get_protocol_tlv_data (cdev -> ops_cookie , & tlv_buf -> iscsi );
2239+ break ;
2240+ default :
2241+ break ;
2242+ }
2243+
2244+ return 0 ;
20962245}
0 commit comments