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

Commit 731b9742 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: gadget: u_ether: Add support for ETH_P_MAP skb protocol type



In the case of RMNET IP mode and a packet is neither IPv4
nor IPv6, check if it supports ETH_P_MAP protocol type.
This allows upper layers to use the MAP protocol to handle
MUXing and de-MUXing of the skb accordingly.

Change-Id: I04f9bf3ad11d6dafcbeb271505f50b571148cb6c
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 7de48d1f
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -496,6 +496,31 @@ static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
	spin_unlock_irqrestore(&dev->req_lock, flags);
}

static __be16 ether_ip_type_trans(struct sk_buff *skb,
	struct net_device *dev)
{
	__be16	protocol = 0;

	skb->dev = dev;

	switch (skb->data[0] & 0xf0) {
	case 0x40:
		protocol = htons(ETH_P_IP);
		break;
	case 0x60:
		protocol = htons(ETH_P_IPV6);
		break;
	default:
		if ((skb->data[0] & 0x40) == 0x00)
			protocol = htons(ETH_P_MAP);
		else
			pr_debug_ratelimited("[%s] L3 protocol decode error: 0x%02x",
					dev->name, skb->data[0] & 0xf0);
	}

	return protocol;
}

static void process_rx_w(struct work_struct *work)
{
	struct eth_dev	*dev = container_of(work, struct eth_dev, rx_work);
@@ -515,7 +540,12 @@ static void process_rx_w(struct work_struct *work)
			dev_kfree_skb_any(skb);
			continue;
		}

		if (test_bit(RMNET_MODE_LLP_IP, &dev->flags))
			skb->protocol = ether_ip_type_trans(skb, dev->net);
		else
			skb->protocol = eth_type_trans(skb, dev->net);

		dev->net->stats.rx_packets++;
		dev->net->stats.rx_bytes += skb->len;