summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/net/Kconfig6
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/mhi/Makefile6
-rw-r--r--drivers/net/mhi/mhi_net_device.c410
-rw-r--r--include/linux/if_mhi.h39
-rw-r--r--include/linux/l2mux.h102
-rw-r--r--include/linux/mhi.h55
-rw-r--r--include/linux/socket.h6
-rw-r--r--include/net/af_mhi.h38
-rw-r--r--include/net/mhdp.h43
-rw-r--r--include/net/mhi/dgram.h41
-rw-r--r--include/net/mhi/mhdp.h35
-rw-r--r--include/net/mhi/raw.h41
-rw-r--r--include/net/mhi/sched.h35
-rw-r--r--include/net/mhi/sock.h42
-rw-r--r--include/uapi/linux/if_ether.h3
16 files changed, 902 insertions, 1 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3835321b8cf3..6936a4465385 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -356,4 +356,10 @@ config VMXNET3
source "drivers/net/hyperv/Kconfig"
+config MHI_NETDEV
+ bool "MHI net device"
+ depends on MHI
+ help
+ This is the net device manadatory used by MHI stack
+
endif # NETDEVICES
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1d12f83f4cf4..86c7a835ec08 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -73,3 +73,4 @@ obj-$(CONFIG_USB_NET_RAW_IP) += usb/
obj-$(CONFIG_HYPERV_NET) += hyperv/
obj-$(CONFIG_NTB_NETDEV) += ntb_netdev.o
+obj-$(CONFIG_MHI_NETDEV) += mhi/
diff --git a/drivers/net/mhi/Makefile b/drivers/net/mhi/Makefile
new file mode 100644
index 000000000000..c303e321a389
--- /dev/null
+++ b/drivers/net/mhi/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for USB Network drivers
+#
+
+obj-$(CONFIG_MHI_NETDEV) += mhi_net_device.o
+
diff --git a/drivers/net/mhi/mhi_net_device.c b/drivers/net/mhi/mhi_net_device.c
new file mode 100644
index 000000000000..8574a8a4ad4d
--- /dev/null
+++ b/drivers/net/mhi/mhi_net_device.c
@@ -0,0 +1,410 @@
+/*
+* mhi_net_device.c
+*
+* Copyright (C) 2011 Renesas. All rights reserved.
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*/
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <linux/if_phonet.h>
+#include <linux/if_mhi.h>
+#include <linux/mhi.h>
+#include <linux/phonet.h>
+#include <linux/delay.h>
+#include <linux/l2mux.h>
+#include <linux/etherdevice.h>
+#include <linux/platform_device.h>
+#include <net/phonet/pn_dev.h>
+#include <linux/mii.h>
+#include <linux/usb.h>
+
+#include <linux/usb/usbnet.h>
+#include <linux/wakelock.h>
+
+
+/*
+#define HSIC_USE_DEBUG
+#define DUMP_FRAMES_DEBUG
+*/
+
+#ifndef PN_DEV_HOST
+#define PN_DEV_HOST 0x00
+#endif
+
+#ifdef HSIC_USE_DEBUG
+#define DPRINTK(...) printk(KERN_DEBUG __VA_ARGS__)
+#else
+#define DPRINTK(...)
+#endif
+
+#define EPRINTK(...) printk(KERN_EMERG __VA_ARGS__)
+
+/*private struct*/
+struct mhi_data {
+ struct net_device *net_dev;
+ struct net_device *master;
+};
+
+u32 debug_nb_crash_modem;
+struct wake_lock wake_no_suspend;
+
+static int mhi_net_device_xmit(struct sk_buff *skb, struct net_device *dev);
+static int mhi_net_device_ioctl(struct net_device *dev,
+ struct ifreq *ifr,
+ int cmd);
+static int mhi_net_device_set_mtu(struct net_device *dev, int new_mtu);
+static int mhi_net_device_open(struct net_device *dev);
+static int mhi_net_device_close(struct net_device *dev);
+static int mhi_net_dev_recv(struct sk_buff *skb,
+ struct net_device *dev,
+ struct packet_type *type,
+ struct net_device *orig_dev);
+
+static struct packet_type modem_packet_type __read_mostly = {
+ .type = cpu_to_be16(0x9876),
+ .func = mhi_net_dev_recv,
+};
+
+static int mhi_net_dev_recv(
+ struct sk_buff *skb,
+ struct net_device *dev,
+ struct packet_type *type,
+ struct net_device *orig_dev)
+{
+ DPRINTK("mhi_net_dev_recv\n");
+ wake_lock_timeout(&wake_no_suspend, 1 * HZ);
+ return l2mux_skb_rx(skb, __dev_get_by_name(&init_net, "mhi0"));
+}
+
+
+static const struct net_device_ops mhi_net_device_ops = {
+ .ndo_open = mhi_net_device_open,
+ .ndo_stop = mhi_net_device_close,
+ .ndo_start_xmit = mhi_net_device_xmit,
+ .ndo_do_ioctl = mhi_net_device_ioctl,
+ .ndo_change_mtu = mhi_net_device_set_mtu,
+};
+
+static void mhi_net_device_setup(struct net_device *dev)
+{
+ dev->features = 0 ;
+ dev->netdev_ops = &mhi_net_device_ops;
+ dev->destructor = free_netdev;
+ dev->type = ARPHRD_MHI;
+ dev->flags = IFF_POINTOPOINT | IFF_NOARP;
+ dev->mtu = MHI_MAX_MTU;
+ dev->hard_header_len = 4;
+ dev->dev_addr[0] = PN_MEDIA_MODEM_HOST_IF;
+ dev->addr_len = 1;
+ dev->tx_queue_len = 2000;
+}
+
+static int mhi_net_device_ioctl(struct net_device *dev,
+ struct ifreq *ifr,
+ int cmd)
+{
+ struct if_phonet_req *req = (struct if_phonet_req *)ifr;
+ DPRINTK("mhi_net_device_ioctl\n");
+
+ switch (cmd) {
+ case SIOCPNGAUTOCONF:
+
+ req->ifr_phonet_autoconf.device = PN_DEV_HOST;
+ phonet_route_add(dev, 0x60);
+ phonet_route_add(dev, 0x44);
+ phonet_route_add(dev, 0x64);
+
+ break;
+ }
+ return 0;
+}
+
+static int mhi_net_device_set_mtu(struct net_device *dev, int new_mtu)
+{
+ DPRINTK("mhi_net_device_set_mtu\n");
+
+ if ((new_mtu < MHI_MIN_MTU) || (new_mtu > MHI_MAX_MTU))
+ return -EINVAL;
+
+ dev->mtu = new_mtu;
+
+ return 0;
+}
+
+
+static int mhi_net_device_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct mhi_data *priv = netdev_priv(dev);
+ int err;
+
+ /* Call l2mux registered function, according to skb->protocol */
+ err = l2mux_skb_tx(skb, dev);
+ if (unlikely(err))
+ goto drop;
+
+#ifdef HSIC_USE_DEBUG
+{
+ struct l2muxhdr *l2hdr;
+ unsigned l3pid;
+ unsigned l3len;
+
+ /* L2MUX header */
+ l2hdr = l2mux_hdr(skb);
+
+ /* proto id and length in L2 header */
+ l3pid = l2mux_get_proto(l2hdr);
+ l3len = l2mux_get_length(l2hdr);
+
+ DPRINTK("L2MUX: TX dev:%d skb_len:%d l3_len:%d l3_pid:%d\n",
+ skb->dev->ifindex, skb->len, l3len, l3pid);
+}
+#endif
+
+ /* Update TX statistics */
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+
+ if (skb_shinfo(skb)->nr_frags) {
+ EPRINTK("MHI net device doesn't support SG.\n");
+ BUG();
+ }
+
+ skb->protocol = ARPHRD_ETHER;
+
+ if (!priv->master)
+ BUG();
+
+ skb->dev = priv->master;
+
+ eth_header(skb, skb->dev, ARPHRD_ETHER, NULL, NULL, skb->len);
+
+#ifdef DUMP_FRAMES_DEBUG
+{
+ int i;
+ int len = skb->len;
+ u8 *ptr = skb->data;
+
+ for (i = 0; i < len; i++) {
+ if (i%8 == 0)
+ DPRINTK("MHI mhi_net_device_xmit : TX [%04X] ", i);
+ DPRINTK(" 0x%02X", ptr[i]);
+ if (i%8 == 7 || i == len-1)
+ DPRINTK("\n");
+ }
+}
+#endif
+
+ /* Send to NCM class */
+ err = dev_queue_xmit(skb);
+
+ if (err) {
+ EPRINTK(" mhi_net_device_xmit dev_queue_xmit error DROP\n");
+ goto drop;
+ }
+
+ return 0;
+
+drop:
+ dev->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+
+ DPRINTK("\n mhi_net_device_xmit: dropped");
+
+ return 0;
+}
+
+
+static int mhi_net_device_open(struct net_device *dev)
+{
+ struct mhi_data *priv = netdev_priv(dev);
+ struct net_device *usb_net_device;
+ int flags;
+
+ DPRINTK("mhi_net_device_open\n");
+
+ priv->master = NULL;
+
+ usb_net_device = __dev_get_by_name(&init_net, "usb0");
+
+ if (usb_net_device &&
+ (usb_net_device->dev_addr[0] == 0x74) &&
+ (usb_net_device->dev_addr[1] == 0x90) &&
+ (usb_net_device->dev_addr[2] == 0x50)) {
+ EPRINTK("Renesas HSIC netdevice mounted (usb0)\n");
+ priv->master = usb_net_device;
+ } else {
+ usb_net_device = __dev_get_by_name(&init_net, "usb1");
+ if (usb_net_device &&
+ (usb_net_device->dev_addr[0] == 0x74) &&
+ (usb_net_device->dev_addr[1] == 0x90) &&
+ (usb_net_device->dev_addr[2] == 0x50)) {
+ EPRINTK("Renesas HSIC netdevice mounted (usb1)\n");
+ priv->master = usb_net_device;
+ }
+ }
+
+ if (!priv->master) {
+ DPRINTK(" Renesas HSIC netdevice not mounted yet\n");
+ return -EAGAIN;
+ }
+
+ usbnet_pause_rx(netdev_priv(priv->master));
+
+ flags = priv->master->flags;
+ flags |= IFF_UP | IFF_RUNNING;
+
+ /* UP usb netdevice */
+ dev_change_flags(priv->master, flags);
+
+ return 0;
+}
+
+static int mhi_device_notify(struct notifier_block *me, unsigned long what,
+ void *arg)
+{
+ struct net_device *dev = arg;
+
+ if ((dev->dev_addr[0] == 0x74) &&
+ (dev->dev_addr[1] == 0x90) &&
+ (dev->dev_addr[2] == 0x50) &&
+ (what == NETDEV_CHANGE)) {
+ usbnet_resume_rx(netdev_priv(dev));
+ }
+
+ return 0;
+}
+
+static struct notifier_block mhi_device_notifier = {
+ .notifier_call = mhi_device_notify,
+ .priority = 0,
+};
+
+static int mhi_net_device_close(struct net_device *dev)
+{
+ struct mhi_data *priv = netdev_priv(dev);
+ int flags;
+
+ EPRINTK("Modem crash occurs - NB modem reboot since power on : %d\n",
+ ++debug_nb_crash_modem);
+
+ if (!priv->master)
+ BUG();
+
+ flags = priv->master->flags;
+ flags &= ~(IFF_UP | IFF_RUNNING);
+
+ /* Down usb netdevice*/
+ dev_change_flags(priv->master, flags);
+
+ priv->master = NULL;
+
+ return 0;
+}
+
+
+static int mhi_net_device_probe(struct platform_device *dev)
+{
+ struct mhi_data *priv = NULL;
+ struct net_device *ndev;
+ int err;
+
+ DPRINTK(" mhi_net_device_probe\n");
+
+ ndev = alloc_netdev(sizeof(struct mhi_data),
+ "mhi%d",
+ mhi_net_device_setup);
+
+ if (ndev == NULL)
+ return -ENOMEM;
+
+ priv = netdev_priv(ndev);
+ priv->net_dev = ndev;
+
+ SET_NETDEV_DEV(ndev, &dev->dev);
+
+ err = register_netdev(ndev);
+
+ if (err < 0) {
+ dev_err(&dev->dev, "Register netdev failed (%d)\n", err);
+ free_netdev(ndev);
+ goto out1;
+ }
+
+ return 0;
+
+out1:
+ unregister_netdev(ndev);
+
+ return err;
+}
+
+static int mhi_net_device_remove(struct platform_device *dev)
+{
+ struct mhi_data *priv = platform_get_drvdata(dev);
+
+ DPRINTK(" mhi_net_device_remove\n");
+
+ unregister_netdev(priv->net_dev);
+
+ return 0;
+}
+
+
+static struct platform_driver mhi_net_device_driver = {
+ .driver = {
+ .name = "mhi_net_device"
+ },
+ .probe = mhi_net_device_probe,
+ .remove = mhi_net_device_remove,
+};
+
+
+static int __init mhi_net_device_init(void)
+{
+ DPRINTK("mhi_net_device_init\n");
+
+ platform_driver_register(&mhi_net_device_driver);
+
+ register_netdevice_notifier(&mhi_device_notifier);
+
+ dev_add_pack(&modem_packet_type);
+
+ wake_lock_init(&wake_no_suspend,
+ WAKE_LOCK_SUSPEND,
+ "MHI no suspend after HSIC RX");
+
+ return 0;
+}
+
+static void __exit mhi_net_device_exit(void)
+{
+ platform_driver_unregister(&mhi_net_device_driver);
+
+ unregister_netdevice_notifier(&mhi_device_notifier);
+
+ dev_remove_pack(&modem_packet_type);
+}
+
+late_initcall(mhi_net_device_init);
+module_exit(mhi_net_device_exit);
+
+MODULE_AUTHOR("RMC");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/if_mhi.h b/include/linux/if_mhi.h
new file mode 100644
index 000000000000..98f20f429009
--- /dev/null
+++ b/include/linux/if_mhi.h
@@ -0,0 +1,39 @@
+/*
+ * File: if_mhi.h
+ *
+ * 'Modem-Host Interface' kernel definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+*/
+
+#ifndef LINUX_IF_MHI_H
+#define LINUX_IF_MHI_H
+
+/*
+ * Packet sizes
+ */
+
+#define MHI_MIN_MTU 260
+#define MHI_MAX_MTU 65540
+
+#define MHI_MTU MHI_MAX_MTU
+
+/*
+ * Ioctl definitions
+ */
+
+
+#endif /* LINUX_IF_MHI_H */
diff --git a/include/linux/l2mux.h b/include/linux/l2mux.h
new file mode 100644
index 000000000000..4f9dab8cf78a
--- /dev/null
+++ b/include/linux/l2mux.h
@@ -0,0 +1,102 @@
+/*
+ * File: l2mux.h
+ *
+ * MHI L2MUX kernel definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef LINUX_L2MUX_H
+#define LINUX_L2MUX_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+
+/* Official L3 protocol IDs */
+#define MHI_L3_PHONET 0x00
+#define MHI_L3_FILE 0x01
+#define MHI_L3_AUDIO 0x02
+#define MHI_L3_SECURITY 0x03
+#define MHI_L3_TEST 0x04
+#define MHI_L3_TEST_PRIO 0x05
+#define MHI_L3_XFILE 0x06
+#define MHI_L3_MHDP_DL 0x07
+#define MHI_L3_MHDP_UL 0x08
+#define MHI_L3_AUX_HOST 0x09
+#define MHI_L3_THERMAL 0xC1
+#define MHI_L3_HIGH_PRIO_TEST 0xFD
+#define MHI_L3_MED_PRIO_TEST 0xFE
+#define MHI_L3_LOW_PRIO_TEST 0xFF
+
+/* 256 possible protocols */
+#define MHI_L3_NPROTO 256
+
+/* Special value for ANY */
+#define MHI_L3_ANY 0xFFFF
+
+typedef int (l2mux_skb_fn)(struct sk_buff *skb, struct net_device *dev);
+
+struct l2muxhdr {
+ __u8 l3_len[3];
+ __u8 l3_prot;
+} __packed;
+
+#define L2MUX_HDR_SIZE (sizeof(struct l2muxhdr))
+
+
+static inline struct l2muxhdr *l2mux_hdr(struct sk_buff *skb)
+{
+ return (struct l2muxhdr *)skb_mac_header(skb);
+}
+
+static inline void l2mux_set_proto(struct l2muxhdr *hdr, int proto)
+{
+ hdr->l3_prot = proto;
+}
+
+static inline int l2mux_get_proto(struct l2muxhdr *hdr)
+{
+ return hdr->l3_prot;
+}
+
+static inline void l2mux_set_length(struct l2muxhdr *hdr, unsigned len)
+{
+ hdr->l3_len[0] = (len) & 0xFF;
+ hdr->l3_len[1] = (len >> 8) & 0xFF;
+ hdr->l3_len[2] = (len >> 16) & 0xFF;
+}
+
+static inline unsigned l2mux_get_length(struct l2muxhdr *hdr)
+{
+ return (((unsigned)hdr->l3_len[2]) << 16) |
+ (((unsigned)hdr->l3_len[1]) << 8) |
+ ((unsigned)hdr->l3_len[0]);
+}
+
+extern int l2mux_netif_rx_register(int l3, l2mux_skb_fn *rx_fn);
+extern int l2mux_netif_rx_unregister(int l3);
+
+extern int l2mux_netif_tx_register(int pt, l2mux_skb_fn *rx_fn);
+extern int l2mux_netif_tx_unregister(int pt);
+
+extern int l2mux_skb_rx(struct sk_buff *skb, struct net_device *dev);
+extern int l2mux_skb_tx(struct sk_buff *skb, struct net_device *dev);
+
+
+#endif /* LINUX_L2MUX_H */
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
new file mode 100644
index 000000000000..ba131350ee80
--- /dev/null
+++ b/include/linux/mhi.h
@@ -0,0 +1,55 @@
+/*
+ * file mhi.h
+ *
+ * Modem-Host Interface (MHI) kernel interface
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef LINUX_MHI_H
+#define LINUX_MHI_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+#include <net/sock.h>
+#include <asm/byteorder.h>
+
+
+struct mhi_sock {
+ struct sock sk;
+ int sk_l3proto;
+ int sk_ifindex;
+};
+
+struct sockaddr_mhi {
+ sa_family_t sa_family;
+ int sa_ifindex;
+ __u8 sa_zero[sizeof(struct sockaddr)
+ - sizeof(sa_family_t) - sizeof(int)];
+};
+
+
+static inline struct mhi_sock *mhi_sk(struct sock *sk)
+{
+ return (struct mhi_sock *)sk;
+}
+
+static inline struct sockaddr_mhi *sa_mhi(struct sockaddr *sa)
+{
+ return (struct sockaddr_mhi *)sa;
+}
+
+#endif
diff --git a/include/linux/socket.h b/include/linux/socket.h
index b10ce4b341ea..1bdbcf26cb9e 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -179,7 +179,9 @@ struct ucred {
#define AF_ALG 38 /* Algorithm sockets */
#define AF_NFC 39 /* NFC sockets */
#define AF_VSOCK 40 /* vSockets */
-#define AF_MAX 41 /* For now.. */
+#define AF_MHI 41 /* MHI sockets */
+#define AF_RAW 42 /* RAW sockets */
+#define AF_MAX 43 /* For now.. */
/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
@@ -223,6 +225,8 @@ struct ucred {
#define PF_ALG AF_ALG
#define PF_NFC AF_NFC
#define PF_VSOCK AF_VSOCK
+#define PF_MHI AF_MHI
+#define PF_RAW AF_RAW
#define PF_MAX AF_MAX
/* Maximum queue length specifiable by listen. */
diff --git a/include/net/af_mhi.h b/include/net/af_mhi.h
new file mode 100644
index 000000000000..be571b7c28a8
--- /dev/null
+++ b/include/net/af_mhi.h
@@ -0,0 +1,38 @@
+/*
+ * File: net/af_mhi.h
+ *
+ * MHI Protocol Family kernel definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __LINUX_NET_AFMHI_H
+#define __LINUX_NET_AFMHI_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+
+extern int mhi_register_protocol(int protocol);
+extern int mhi_unregister_protocol(int protocol);
+extern int mhi_protocol_registered(int protocol);
+
+extern int mhi_skb_send(struct sk_buff *skb, struct net_device *dev, u8 proto);
+
+
+#endif /* __LINUX_NET_AFMHI_H */
diff --git a/include/net/mhdp.h b/include/net/mhdp.h
new file mode 100644
index 000000000000..1b8558e74ab9
--- /dev/null
+++ b/include/net/mhdp.h
@@ -0,0 +1,43 @@
+/*
+ * File: mhdp.h
+ *
+ * Modem-Host Interface (MHI) - MHDP kernel interface
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __NET_MHDP_H
+#define __NET_MHDP_H
+
+struct mhdp_tunnel_parm {
+ char name[IFNAMSIZ];
+ int pdn_id;
+ char master_interface[IFNAMSIZ];
+};
+
+struct mhdp_tunnel {
+ struct mhdp_tunnel *next;
+ struct net_device *dev;
+ struct mhdp_tunnel_parm parms;
+ struct net_device *master_dev;
+ struct sk_buff *skb;
+};
+
+#define SIOCADDPDNID (SIOCDEVPRIVATE + 1)
+#define SIOCDELPDNID (SIOCDEVPRIVATE + 2)
+#define SIOCRESETMHDP (SIOCDEVPRIVATE + 3)
+
+#endif /* __NET_MHDP_H */
diff --git a/include/net/mhi/dgram.h b/include/net/mhi/dgram.h
new file mode 100644
index 000000000000..ceb34d58f5ae
--- /dev/null
+++ b/include/net/mhi/dgram.h
@@ -0,0 +1,41 @@
+/*
+ * File: mhi/dgram.h
+ *
+ * MHI DGRAM socket definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef MHI_DGRAM_H
+#define MHI_DGRAM_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+
+extern int mhi_dgram_sock_create(
+ struct net *net,
+ struct socket *sock,
+ int proto,
+ int kern);
+
+extern int mhi_dgram_proto_init(void);
+extern void mhi_dgram_proto_exit(void);
+
+
+#endif /* MHI_DGRAM_H */
diff --git a/include/net/mhi/mhdp.h b/include/net/mhi/mhdp.h
new file mode 100644
index 000000000000..7ec1591cb8d3
--- /dev/null
+++ b/include/net/mhi/mhdp.h
@@ -0,0 +1,35 @@
+/*
+ * File: mhdp.h
+ *
+ * Modem-Host Interface (MHI) - MHDP kernel interface
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __NET_MHI_MHDP_H
+#define __NET_MHI_MHDP_H
+
+struct mhdp_tunnel_parm {
+ char name[IFNAMSIZ];
+ char master[IFNAMSIZ];
+ int pdn_id;
+};
+
+#define SIOCADDPDNID (SIOCDEVPRIVATE + 1)
+#define SIOCDELPDNID (SIOCDEVPRIVATE + 2)
+#define SIOCRESETMHDP (SIOCDEVPRIVATE + 3)
+
+#endif /* __NET_MHI_MHDP_H */
diff --git a/include/net/mhi/raw.h b/include/net/mhi/raw.h
new file mode 100644
index 000000000000..7c2edba4f111
--- /dev/null
+++ b/include/net/mhi/raw.h
@@ -0,0 +1,41 @@
+/*
+ * File: mhi/raw.h
+ *
+ * MHI RAW socket definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef MHI_RAW_H
+#define MHI_RAW_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+
+extern int mhi_raw_sock_create(
+ struct net *net,
+ struct socket *sock,
+ int proto,
+ int kern);
+
+extern int mhi_raw_proto_init(void);
+extern void mhi_raw_proto_exit(void);
+
+
+#endif /* MHI_RAW_H */
diff --git a/include/net/mhi/sched.h b/include/net/mhi/sched.h
new file mode 100644
index 000000000000..8ff4b420c70a
--- /dev/null
+++ b/include/net/mhi/sched.h
@@ -0,0 +1,35 @@
+/*
+ * File: mhi/sock.h
+ *
+ * MHI socket definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef MHI_SCHED_H
+#define MHI_SCHED_H
+
+#define MHI_NOTIFY_QUEUE_LOW 19
+#define MHI_NOTIFY_QUEUE_HIGH 20
+
+extern int mhi_register_queue_notifier(struct Qdisc *sch,
+ struct notifier_block *nb, unsigned long cl);
+
+extern int mhi_unregister_queue_notifier(struct Qdisc *sch,
+ struct notifier_block *nb, unsigned long cl);
+
+
+#endif /* MHI_SCHED_H */
diff --git a/include/net/mhi/sock.h b/include/net/mhi/sock.h
new file mode 100644
index 000000000000..170c892ec171
--- /dev/null
+++ b/include/net/mhi/sock.h
@@ -0,0 +1,42 @@
+/*
+ * File: mhi/sock.h
+ *
+ * MHI socket definitions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef MHI_SOCK_H
+#define MHI_SOCK_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+extern const struct proto_ops mhi_socket_ops;
+
+extern int mhi_sock_rcv_unicast(struct sk_buff *skb, u8 l3prot, u32 l3len);
+extern int mhi_sock_rcv_multicast(struct sk_buff *skb, u8 l3prot, u32 l3len);
+
+extern void mhi_sock_hash(struct sock *sk);
+extern void mhi_sock_unhash(struct sock *sk);
+
+extern int mhi_sock_init(void);
+extern void mhi_sock_exit(void);
+
+
+#endif /* MHI_SOCK_H */
diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
index ade07f1c491a..c7e57ee54e97 100644
--- a/include/uapi/linux/if_ether.h
+++ b/include/uapi/linux/if_ether.h
@@ -125,6 +125,9 @@
#define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */
#define ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */
#define ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */
+#define ETH_P_MHI 0x00F8 /* Renesas MHI protocol */
+#define ETH_P_RAW 0x00F9 /* RAW access to frames */
+#define ETH_P_MHDP 0x00FA /* MHDP data frames */
/*
* This is an Ethernet frame header.