@@ -2086,6 +2086,92 @@ static inline void efx_ef10_push_tx_desc(struct efx_tx_queue *tx_queue,
20862086 ER_DZ_TX_DESC_UPD , tx_queue -> queue );
20872087}
20882088
2089+ /* Add Firmware-Assisted TSO v2 option descriptors to a queue.
2090+ */
2091+ static int efx_ef10_tx_tso_desc (struct efx_tx_queue * tx_queue ,
2092+ struct sk_buff * skb ,
2093+ bool * data_mapped )
2094+ {
2095+ struct efx_tx_buffer * buffer ;
2096+ struct tcphdr * tcp ;
2097+ struct iphdr * ip ;
2098+
2099+ u16 ipv4_id ;
2100+ u32 seqnum ;
2101+ u32 mss ;
2102+
2103+ EFX_BUG_ON_PARANOID (tx_queue -> tso_version != 2 );
2104+
2105+ mss = skb_shinfo (skb )-> gso_size ;
2106+
2107+ if (unlikely (mss < 4 )) {
2108+ WARN_ONCE (1 , "MSS of %u is too small for TSO v2\n" , mss );
2109+ return - EINVAL ;
2110+ }
2111+
2112+ ip = ip_hdr (skb );
2113+ if (ip -> version == 4 ) {
2114+ /* Modify IPv4 header if needed. */
2115+ ip -> tot_len = 0 ;
2116+ ip -> check = 0 ;
2117+ ipv4_id = ip -> id ;
2118+ } else {
2119+ /* Modify IPv6 header if needed. */
2120+ struct ipv6hdr * ipv6 = ipv6_hdr (skb );
2121+
2122+ ipv6 -> payload_len = 0 ;
2123+ ipv4_id = 0 ;
2124+ }
2125+
2126+ tcp = tcp_hdr (skb );
2127+ seqnum = ntohl (tcp -> seq );
2128+
2129+ buffer = efx_tx_queue_get_insert_buffer (tx_queue );
2130+
2131+ buffer -> flags = EFX_TX_BUF_OPTION ;
2132+ buffer -> len = 0 ;
2133+ buffer -> unmap_len = 0 ;
2134+ EFX_POPULATE_QWORD_5 (buffer -> option ,
2135+ ESF_DZ_TX_DESC_IS_OPT , 1 ,
2136+ ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
2137+ ESF_DZ_TX_TSO_OPTION_TYPE ,
2138+ ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A ,
2139+ ESF_DZ_TX_TSO_IP_ID , ipv4_id ,
2140+ ESF_DZ_TX_TSO_TCP_SEQNO , seqnum
2141+ );
2142+ ++ tx_queue -> insert_count ;
2143+
2144+ buffer = efx_tx_queue_get_insert_buffer (tx_queue );
2145+
2146+ buffer -> flags = EFX_TX_BUF_OPTION ;
2147+ buffer -> len = 0 ;
2148+ buffer -> unmap_len = 0 ;
2149+ EFX_POPULATE_QWORD_4 (buffer -> option ,
2150+ ESF_DZ_TX_DESC_IS_OPT , 1 ,
2151+ ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
2152+ ESF_DZ_TX_TSO_OPTION_TYPE ,
2153+ ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B ,
2154+ ESF_DZ_TX_TSO_TCP_MSS , mss
2155+ );
2156+ ++ tx_queue -> insert_count ;
2157+
2158+ return 0 ;
2159+ }
2160+
2161+ static u32 efx_ef10_tso_versions (struct efx_nic * efx )
2162+ {
2163+ struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
2164+ u32 tso_versions = 0 ;
2165+
2166+ if (nic_data -> datapath_caps &
2167+ (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN ))
2168+ tso_versions |= BIT (1 );
2169+ if (nic_data -> datapath_caps2 &
2170+ (1 << MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN ))
2171+ tso_versions |= BIT (2 );
2172+ return tso_versions ;
2173+ }
2174+
20892175static void efx_ef10_tx_init (struct efx_tx_queue * tx_queue )
20902176{
20912177 MCDI_DECLARE_BUF (inbuf , MC_CMD_INIT_TXQ_IN_LEN (EFX_MAX_DMAQ_SIZE * 8 /
@@ -2095,20 +2181,29 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
20952181 struct efx_channel * channel = tx_queue -> channel ;
20962182 struct efx_nic * efx = tx_queue -> efx ;
20972183 struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
2184+ bool tso_v2 = false;
20982185 size_t inlen ;
20992186 dma_addr_t dma_addr ;
21002187 efx_qword_t * txd ;
21012188 int rc ;
21022189 int i ;
21032190 BUILD_BUG_ON (MC_CMD_INIT_TXQ_OUT_LEN != 0 );
21042191
2192+ /* TSOv2 is a limited resource that can only be configured on a limited
2193+ * number of queues. TSO without checksum offload is not really a thing,
2194+ * so we only enable it for those queues.
2195+ */
2196+ if (csum_offload && (nic_data -> datapath_caps2 &
2197+ (1 << MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN ))) {
2198+ tso_v2 = true;
2199+ netif_dbg (efx , hw , efx -> net_dev , "Using TSOv2 for channel %u\n" ,
2200+ channel -> channel );
2201+ }
2202+
21052203 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_SIZE , tx_queue -> ptr_mask + 1 );
21062204 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_TARGET_EVQ , channel -> channel );
21072205 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_LABEL , tx_queue -> queue );
21082206 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_INSTANCE , tx_queue -> queue );
2109- MCDI_POPULATE_DWORD_2 (inbuf , INIT_TXQ_IN_FLAGS ,
2110- INIT_TXQ_IN_FLAG_IP_CSUM_DIS , !csum_offload ,
2111- INIT_TXQ_IN_FLAG_TCP_CSUM_DIS , !csum_offload );
21122207 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_OWNER_ID , 0 );
21132208 MCDI_SET_DWORD (inbuf , INIT_TXQ_IN_PORT_ID , nic_data -> vport_id );
21142209
@@ -2124,10 +2219,30 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
21242219
21252220 inlen = MC_CMD_INIT_TXQ_IN_LEN (entries );
21262221
2127- rc = efx_mcdi_rpc (efx , MC_CMD_INIT_TXQ , inbuf , inlen ,
2128- NULL , 0 , NULL );
2129- if (rc )
2130- goto fail ;
2222+ do {
2223+ MCDI_POPULATE_DWORD_3 (inbuf , INIT_TXQ_IN_FLAGS ,
2224+ /* This flag was removed from mcdi_pcol.h for
2225+ * the non-_EXT version of INIT_TXQ. However,
2226+ * firmware still honours it.
2227+ */
2228+ INIT_TXQ_EXT_IN_FLAG_TSOV2_EN , tso_v2 ,
2229+ INIT_TXQ_IN_FLAG_IP_CSUM_DIS , !csum_offload ,
2230+ INIT_TXQ_IN_FLAG_TCP_CSUM_DIS , !csum_offload );
2231+
2232+ rc = efx_mcdi_rpc_quiet (efx , MC_CMD_INIT_TXQ , inbuf , inlen ,
2233+ NULL , 0 , NULL );
2234+ if (rc == - ENOSPC && tso_v2 ) {
2235+ /* Retry without TSOv2 if we're short on contexts. */
2236+ tso_v2 = false;
2237+ netif_warn (efx , probe , efx -> net_dev ,
2238+ "TSOv2 context not available to segment in hardware. TCP performance may be reduced.\n" );
2239+ } else if (rc ) {
2240+ efx_mcdi_display_error (efx , MC_CMD_INIT_TXQ ,
2241+ MC_CMD_INIT_TXQ_EXT_IN_LEN ,
2242+ NULL , 0 , rc );
2243+ goto fail ;
2244+ }
2245+ } while (rc );
21312246
21322247 /* A previous user of this TX queue might have set us up the
21332248 * bomb by writing a descriptor to the TX push collector but
@@ -2146,8 +2261,11 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
21462261 ESF_DZ_TX_OPTION_IP_CSUM , csum_offload );
21472262 tx_queue -> write_count = 1 ;
21482263
2149- if (nic_data -> datapath_caps &
2150- (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN )) {
2264+ if (tso_v2 ) {
2265+ tx_queue -> handle_tso = efx_ef10_tx_tso_desc ;
2266+ tx_queue -> tso_version = 2 ;
2267+ } else if (nic_data -> datapath_caps &
2268+ (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN )) {
21512269 tx_queue -> tso_version = 1 ;
21522270 }
21532271
@@ -2202,6 +2320,25 @@ static inline void efx_ef10_notify_tx_desc(struct efx_tx_queue *tx_queue)
22022320 ER_DZ_TX_DESC_UPD_DWORD , tx_queue -> queue );
22032321}
22042322
2323+ #define EFX_EF10_MAX_TX_DESCRIPTOR_LEN 0x3fff
2324+
2325+ static unsigned int efx_ef10_tx_limit_len (struct efx_tx_queue * tx_queue ,
2326+ dma_addr_t dma_addr , unsigned int len )
2327+ {
2328+ if (len > EFX_EF10_MAX_TX_DESCRIPTOR_LEN ) {
2329+ /* If we need to break across multiple descriptors we should
2330+ * stop at a page boundary. This assumes the length limit is
2331+ * greater than the page size.
2332+ */
2333+ dma_addr_t end = dma_addr + EFX_EF10_MAX_TX_DESCRIPTOR_LEN ;
2334+
2335+ BUILD_BUG_ON (EFX_EF10_MAX_TX_DESCRIPTOR_LEN < EFX_PAGE_SIZE );
2336+ len = (end & (~(EFX_PAGE_SIZE - 1 ))) - dma_addr ;
2337+ }
2338+
2339+ return len ;
2340+ }
2341+
22052342static void efx_ef10_tx_write (struct efx_tx_queue * tx_queue )
22062343{
22072344 unsigned int old_write_count = tx_queue -> write_count ;
@@ -5469,6 +5606,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
54695606 .tx_init = efx_ef10_tx_init ,
54705607 .tx_remove = efx_ef10_tx_remove ,
54715608 .tx_write = efx_ef10_tx_write ,
5609+ .tx_limit_len = efx_ef10_tx_limit_len ,
54725610 .rx_push_rss_config = efx_ef10_vf_rx_push_rss_config ,
54735611 .rx_probe = efx_ef10_rx_probe ,
54745612 .rx_init = efx_ef10_rx_init ,
@@ -5575,6 +5713,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
55755713 .tx_init = efx_ef10_tx_init ,
55765714 .tx_remove = efx_ef10_tx_remove ,
55775715 .tx_write = efx_ef10_tx_write ,
5716+ .tx_limit_len = efx_ef10_tx_limit_len ,
55785717 .rx_push_rss_config = efx_ef10_pf_rx_push_rss_config ,
55795718 .rx_probe = efx_ef10_rx_probe ,
55805719 .rx_init = efx_ef10_rx_init ,
@@ -5634,6 +5773,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
56345773#endif
56355774 .get_mac_address = efx_ef10_get_mac_address_pf ,
56365775 .set_mac_address = efx_ef10_set_mac_address ,
5776+ .tso_versions = efx_ef10_tso_versions ,
56375777
56385778 .revision = EFX_REV_HUNT_A0 ,
56395779 .max_dma_mask = DMA_BIT_MASK (ESF_DZ_TX_KER_BUF_ADDR_WIDTH ),
0 commit comments