Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08d36f31 authored by Liming Sun's avatar Liming Sun Committed by Greg Kroah-Hartman
Browse files

platform/mellanox: mlxbf-tmfifo: Drop jumbo frames



[ Upstream commit fc4c655821546239abb3cf4274d66b9747aa87dd ]

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.com


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0507815a
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ static u8 mlxbf_tmfifo_net_default_mac[ETH_ALEN] = {
static efi_char16_t mlxbf_tmfifo_efi_name[] = L"RshimMacAddr";

/* 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. */
#define MLXBF_TMFIFO_NET_FEATURES \
@@ -623,13 +623,14 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring,
 * flag is set.
 */
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)
{
	struct mlxbf_tmfifo *fifo = vring->fifo;
	struct virtio_net_config *config;
	struct mlxbf_tmfifo_msg_hdr hdr;
	int vdev_id, hdr_len;
	bool drop_rx = false;

	/* Read/Write packet header. */
	if (is_rx) {
@@ -650,7 +651,7 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
			    __virtio16_to_cpu(virtio_legacy_is_little_endian(),
					      config->mtu) +
					      MLXBF_TMFIFO_NET_L2_OVERHEAD)
				return;
				drop_rx = true;
		} else {
			vdev_id = VIRTIO_ID_CONSOLE;
			hdr_len = 0;
@@ -665,16 +666,25 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,

			if (!tm_dev2)
				return;
			vring->desc = desc;
			vring->desc = *desc;
			vring = &tm_dev2->vrings[MLXBF_TMFIFO_VRING_RX];
			*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;
	} else {
		/* Network virtio has an extra header. */
		hdr_len = (vring->vdev_id == VIRTIO_ID_NET) ?
			   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) ?
			    VIRTIO_ID_NET : VIRTIO_ID_CONSOLE;
		hdr.len = htons(vring->pkt_len - hdr_len);
@@ -723,7 +733,7 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,

	/* Beginning of a packet. Start to Rx/Tx packet header. */
	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)--;

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