Commit fc4c6558 authored by Liming Sun's avatar Liming Sun Committed by Hans de Goede

platform/mellanox: mlxbf-tmfifo: Drop jumbo frames

This commit drops over-sized network packets to avoid tmfifo
queue stuck.

Fixes: 1357dfd7 ("platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc")
Signed-off-by: default avatarLiming Sun <limings@nvidia.com>
Reviewed-by: default avatarVadim Pasternak <vadimp@nvidia.com>
Reviewed-by: default avatarDavid Thompson <davthompson@nvidia.com>
Link: https://lore.kernel.org/r/9318936c2447f76db475c985ca6d91f057efcd41.1693322547.git.limings@nvidia.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 78034cbe
...@@ -224,7 +224,7 @@ static u8 mlxbf_tmfifo_net_default_mac[ETH_ALEN] = { ...@@ -224,7 +224,7 @@ static u8 mlxbf_tmfifo_net_default_mac[ETH_ALEN] = {
static efi_char16_t mlxbf_tmfifo_efi_name[] = L"RshimMacAddr"; static efi_char16_t mlxbf_tmfifo_efi_name[] = L"RshimMacAddr";
/* Maximum L2 header length. */ /* Maximum L2 header length. */
#define MLXBF_TMFIFO_NET_L2_OVERHEAD 36 #define MLXBF_TMFIFO_NET_L2_OVERHEAD (ETH_HLEN + VLAN_HLEN)
/* Supported virtio-net features. */ /* Supported virtio-net features. */
#define MLXBF_TMFIFO_NET_FEATURES \ #define MLXBF_TMFIFO_NET_FEATURES \
...@@ -642,13 +642,14 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring, ...@@ -642,13 +642,14 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring,
* flag is set. * flag is set.
*/ */
static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
struct vring_desc *desc, struct vring_desc **desc,
bool is_rx, bool *vring_change) bool is_rx, bool *vring_change)
{ {
struct mlxbf_tmfifo *fifo = vring->fifo; struct mlxbf_tmfifo *fifo = vring->fifo;
struct virtio_net_config *config; struct virtio_net_config *config;
struct mlxbf_tmfifo_msg_hdr hdr; struct mlxbf_tmfifo_msg_hdr hdr;
int vdev_id, hdr_len; int vdev_id, hdr_len;
bool drop_rx = false;
/* Read/Write packet header. */ /* Read/Write packet header. */
if (is_rx) { if (is_rx) {
...@@ -669,7 +670,7 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, ...@@ -669,7 +670,7 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
__virtio16_to_cpu(virtio_legacy_is_little_endian(), __virtio16_to_cpu(virtio_legacy_is_little_endian(),
config->mtu) + config->mtu) +
MLXBF_TMFIFO_NET_L2_OVERHEAD) MLXBF_TMFIFO_NET_L2_OVERHEAD)
return; drop_rx = true;
} else { } else {
vdev_id = VIRTIO_ID_CONSOLE; vdev_id = VIRTIO_ID_CONSOLE;
hdr_len = 0; hdr_len = 0;
...@@ -684,16 +685,25 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, ...@@ -684,16 +685,25 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
if (!tm_dev2) if (!tm_dev2)
return; return;
vring->desc = desc; vring->desc = *desc;
vring = &tm_dev2->vrings[MLXBF_TMFIFO_VRING_RX]; vring = &tm_dev2->vrings[MLXBF_TMFIFO_VRING_RX];
*vring_change = true; *vring_change = true;
} }
if (drop_rx && !IS_VRING_DROP(vring)) {
if (vring->desc_head)
mlxbf_tmfifo_release_pkt(vring);
*desc = &vring->drop_desc;
vring->desc_head = *desc;
vring->desc = *desc;
}
vring->pkt_len = ntohs(hdr.len) + hdr_len; vring->pkt_len = ntohs(hdr.len) + hdr_len;
} else { } else {
/* Network virtio has an extra header. */ /* Network virtio has an extra header. */
hdr_len = (vring->vdev_id == VIRTIO_ID_NET) ? hdr_len = (vring->vdev_id == VIRTIO_ID_NET) ?
sizeof(struct virtio_net_hdr) : 0; sizeof(struct virtio_net_hdr) : 0;
vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, desc); vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, *desc);
hdr.type = (vring->vdev_id == VIRTIO_ID_NET) ? hdr.type = (vring->vdev_id == VIRTIO_ID_NET) ?
VIRTIO_ID_NET : VIRTIO_ID_CONSOLE; VIRTIO_ID_NET : VIRTIO_ID_CONSOLE;
hdr.len = htons(vring->pkt_len - hdr_len); hdr.len = htons(vring->pkt_len - hdr_len);
...@@ -742,7 +752,7 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, ...@@ -742,7 +752,7 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,
/* Beginning of a packet. Start to Rx/Tx packet header. */ /* Beginning of a packet. Start to Rx/Tx packet header. */
if (vring->pkt_len == 0) { if (vring->pkt_len == 0) {
mlxbf_tmfifo_rxtx_header(vring, desc, is_rx, &vring_change); mlxbf_tmfifo_rxtx_header(vring, &desc, is_rx, &vring_change);
(*avail)--; (*avail)--;
/* Return if new packet is for another ring. */ /* Return if new packet is for another ring. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment