aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@linaro.org>2020-12-11 16:55:30 +0100
committerLoic Poulain <loic.poulain@linaro.org>2021-01-20 14:51:31 +0100
commitf0f1e246133be93b1417dcc94bb8ee5e9f2006b9 (patch)
tree83b2a93b6a54e5599c35bd03fe43bb3d6a829ebb
parent8c3493986027907bbdd7cb850b0ed0ec3f6916bd (diff)
net: mhi: Add raw IP mode support
MHI net is protocol agnostic, the payload protocol depends on the modem configuration, which can be either RMNET (IP muxing and aggregation) or raw IP. This patch adds support for incomming IPv4/IPv6 packets, that was previously unconditionnaly reported as RMNET packets. Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
-rw-r--r--drivers/net/mhi_net.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
index e3f9c0de70a7..478e78f17caa 100644
--- a/drivers/net/mhi_net.c
+++ b/drivers/net/mhi_net.c
@@ -121,7 +121,7 @@ static const struct net_device_ops mhi_netdev_ops = {
static void mhi_net_setup(struct net_device *ndev)
{
ndev->header_ops = NULL; /* No header */
- ndev->type = ARPHRD_NONE; /* QMAP... */
+ ndev->type = ARPHRD_RAWIP;
ndev->hard_header_len = 0;
ndev->addr_len = 0;
ndev->flags = IFF_POINTOPOINT | IFF_NOARP;
@@ -157,7 +157,18 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
u64_stats_add(&mhi_netdev->stats.rx_bytes, mhi_res->bytes_xferd);
u64_stats_update_end(&mhi_netdev->stats.rx_syncp);
- skb->protocol = htons(ETH_P_MAP);
+ switch (skb->data[0] & 0xf0) {
+ case 0x40:
+ skb->protocol = htons(ETH_P_IP);
+ break;
+ case 0x60:
+ skb->protocol = htons(ETH_P_IPV6);
+ break;
+ default:
+ skb->protocol = htons(ETH_P_MAP);
+ break;
+ }
+
skb_put(skb, mhi_res->bytes_xferd);
netif_rx(skb);
}