Skip to content

Commit fc4c655

Browse files
lsun100jwrdegoede
authored andcommitted
platform/mellanox: mlxbf-tmfifo: Drop jumbo frames
This commit drops over-sized network packets to avoid tmfifo queue stuck. Fixes: 1357dfd ("platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc") Signed-off-by: Liming Sun <limings@nvidia.com> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: David Thompson <davthompson@nvidia.com> Link: https://lore.kernel.org/r/9318936c2447f76db475c985ca6d91f057efcd41.1693322547.git.limings@nvidia.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 78034cb commit fc4c655

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/platform/mellanox/mlxbf-tmfifo.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static u8 mlxbf_tmfifo_net_default_mac[ETH_ALEN] = {
224224
static efi_char16_t mlxbf_tmfifo_efi_name[] = L"RshimMacAddr";
225225

226226
/* Maximum L2 header length. */
227-
#define MLXBF_TMFIFO_NET_L2_OVERHEAD 36
227+
#define MLXBF_TMFIFO_NET_L2_OVERHEAD (ETH_HLEN + VLAN_HLEN)
228228

229229
/* Supported virtio-net features. */
230230
#define MLXBF_TMFIFO_NET_FEATURES \
@@ -642,13 +642,14 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring,
642642
* flag is set.
643643
*/
644644
static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
645-
struct vring_desc *desc,
645+
struct vring_desc **desc,
646646
bool is_rx, bool *vring_change)
647647
{
648648
struct mlxbf_tmfifo *fifo = vring->fifo;
649649
struct virtio_net_config *config;
650650
struct mlxbf_tmfifo_msg_hdr hdr;
651651
int vdev_id, hdr_len;
652+
bool drop_rx = false;
652653

653654
/* Read/Write packet header. */
654655
if (is_rx) {
@@ -668,8 +669,8 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
668669
if (ntohs(hdr.len) >
669670
__virtio16_to_cpu(virtio_legacy_is_little_endian(),
670671
config->mtu) +
671-
MLXBF_TMFIFO_NET_L2_OVERHEAD)
672-
return;
672+
MLXBF_TMFIFO_NET_L2_OVERHEAD)
673+
drop_rx = true;
673674
} else {
674675
vdev_id = VIRTIO_ID_CONSOLE;
675676
hdr_len = 0;
@@ -684,16 +685,25 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
684685

685686
if (!tm_dev2)
686687
return;
687-
vring->desc = desc;
688+
vring->desc = *desc;
688689
vring = &tm_dev2->vrings[MLXBF_TMFIFO_VRING_RX];
689690
*vring_change = true;
690691
}
692+
693+
if (drop_rx && !IS_VRING_DROP(vring)) {
694+
if (vring->desc_head)
695+
mlxbf_tmfifo_release_pkt(vring);
696+
*desc = &vring->drop_desc;
697+
vring->desc_head = *desc;
698+
vring->desc = *desc;
699+
}
700+
691701
vring->pkt_len = ntohs(hdr.len) + hdr_len;
692702
} else {
693703
/* Network virtio has an extra header. */
694704
hdr_len = (vring->vdev_id == VIRTIO_ID_NET) ?
695705
sizeof(struct virtio_net_hdr) : 0;
696-
vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, desc);
706+
vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, *desc);
697707
hdr.type = (vring->vdev_id == VIRTIO_ID_NET) ?
698708
VIRTIO_ID_NET : VIRTIO_ID_CONSOLE;
699709
hdr.len = htons(vring->pkt_len - hdr_len);
@@ -742,7 +752,7 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,
742752

743753
/* Beginning of a packet. Start to Rx/Tx packet header. */
744754
if (vring->pkt_len == 0) {
745-
mlxbf_tmfifo_rxtx_header(vring, desc, is_rx, &vring_change);
755+
mlxbf_tmfifo_rxtx_header(vring, &desc, is_rx, &vring_change);
746756
(*avail)--;
747757

748758
/* Return if new packet is for another ring. */

0 commit comments

Comments
 (0)