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

net: ftmac100: prepare data path for receiving single segment packets > 1514

Eliminate one check in the data path and move it elsewhere, to where our
real limitation is. We'll want to start processing "too long" frames in
the driver (currently there is a hardware MAC setting which drops
theses).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Link: https://lore.kernel.org/r/20221028183220.155948-1-saproj@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
55f6f3db 91e87045

+12 -17
+12 -17
drivers/net/ethernet/faraday/ftmac100.c
··· 218 218 return rxdes->rxdes0 & cpu_to_le32(FTMAC100_RXDES0_CRC_ERR); 219 219 } 220 220 221 - static bool ftmac100_rxdes_frame_too_long(struct ftmac100_rxdes *rxdes) 222 - { 223 - return rxdes->rxdes0 & cpu_to_le32(FTMAC100_RXDES0_FTL); 224 - } 225 - 226 221 static bool ftmac100_rxdes_runt(struct ftmac100_rxdes *rxdes) 227 222 { 228 223 return rxdes->rxdes0 & cpu_to_le32(FTMAC100_RXDES0_RUNT); ··· 332 337 error = true; 333 338 } 334 339 335 - if (unlikely(ftmac100_rxdes_frame_too_long(rxdes))) { 336 - if (net_ratelimit()) 337 - netdev_info(netdev, "rx frame too long\n"); 338 - 339 - netdev->stats.rx_length_errors++; 340 - error = true; 341 - } else if (unlikely(ftmac100_rxdes_runt(rxdes))) { 340 + if (unlikely(ftmac100_rxdes_runt(rxdes))) { 342 341 if (net_ratelimit()) 343 342 netdev_info(netdev, "rx runt\n"); 344 343 ··· 345 356 netdev->stats.rx_length_errors++; 346 357 error = true; 347 358 } 359 + /* 360 + * FTMAC100_RXDES0_FTL is not an error, it just indicates that the 361 + * frame is longer than 1518 octets. Receiving these is possible when 362 + * we told the hardware not to drop them, via FTMAC100_MACCR_RX_FTL. 363 + */ 348 364 349 365 return error; 350 366 } ··· 394 400 return true; 395 401 } 396 402 397 - /* 398 - * It is impossible to get multi-segment packets 399 - * because we always provide big enough receive buffers. 400 - */ 403 + /* We don't support multi-segment packets for now, so drop them. */ 401 404 ret = ftmac100_rxdes_last_segment(rxdes); 402 - BUG_ON(!ret); 405 + if (unlikely(!ret)) { 406 + netdev->stats.rx_length_errors++; 407 + ftmac100_rx_drop_packet(priv); 408 + return true; 409 + } 403 410 404 411 /* start processing */ 405 412 skb = netdev_alloc_skb_ip_align(netdev, 128);