linux/drivers/net/usb/sierra_net.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * USB-to-WWAN Driver for Sierra Wireless modems
 *
 * Copyright (C) 2008, 2009, 2010 Paxton Smith, Matthew Safar, Rory Filer
 *                          <[email protected]>
 *
 * Portions of this based on the cdc_ether driver by David Brownell (2003-2005)
 * and Ole Andre Vadla Ravnas (ActiveSync) (2006).
 *
 * IMPORTANT DISCLAIMER: This driver is not commercially supported by
 * Sierra Wireless. Use at your own risk.
 */

#define DRIVER_VERSION
#define DRIVER_AUTHOR
#define DRIVER_DESC
static const char driver_name[] =;

/* if defined debug messages enabled */
/*#define	DEBUG*/

#include <linux/module.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/usb.h>
#include <linux/usb/cdc.h>
#include <net/ip.h>
#include <net/udp.h>
#include <linux/unaligned.h>
#include <linux/usb/usbnet.h>

#define SWI_USB_REQUEST_GET_FW_ATTR
#define SWI_GET_FW_ATTR_MASK

/* atomic counter partially included in MAC address to make sure 2 devices
 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
 */
static	atomic_t iface_counter =;

/*
 * SYNC Timer Delay definition used to set the expiry time
 */
#define SIERRA_NET_SYNCDELAY

/* Max. MTU supported. The modem buffers are limited to 1500 */
#define SIERRA_NET_MAX_SUPPORTED_MTU

/* The SIERRA_NET_USBCTL_BUF_LEN defines a buffer size allocated for control
 * message reception ... and thus the max. received packet.
 * (May be the cause for parse_hip returning -EINVAL)
 */
#define SIERRA_NET_USBCTL_BUF_LEN

/* Overriding the default usbnet rx_urb_size */
#define SIERRA_NET_RX_URB_SIZE

/* Private data structure */
struct sierra_net_data {};

struct param {};

/* HIP message type */
#define SIERRA_NET_HIP_EXTENDEDID
#define SIERRA_NET_HIP_HSYNC_ID
#define SIERRA_NET_HIP_RESTART_ID
#define SIERRA_NET_HIP_MSYNC_ID
#define SIERRA_NET_HIP_SHUTD_ID

#define SIERRA_NET_HIP_EXT_IP_IN_ID
#define SIERRA_NET_HIP_EXT_IP_OUT_ID

/* 3G UMTS Link Sense Indication definitions */
#define SIERRA_NET_HIP_LSI_UMTSID

/* Reverse Channel Grant Indication HIP message */
#define SIERRA_NET_HIP_RCGI

/* LSI Protocol types */
#define SIERRA_NET_PROTOCOL_UMTS
#define SIERRA_NET_PROTOCOL_UMTS_DS
/* LSI Coverage */
#define SIERRA_NET_COVERAGE_NONE
#define SIERRA_NET_COVERAGE_NOPACKET

/* LSI Session */
#define SIERRA_NET_SESSION_IDLE
/* LSI Link types */
#define SIERRA_NET_AS_LINK_TYPE_IPV4
#define SIERRA_NET_AS_LINK_TYPE_IPV6

struct lsi_umts {} __packed;

struct lsi_umts_single {} __packed;

struct lsi_umts_dual {} __packed;

#define SIERRA_NET_LSI_COMMON_LEN
#define SIERRA_NET_LSI_UMTS_LEN
#define SIERRA_NET_LSI_UMTS_STATUS_LEN
#define SIERRA_NET_LSI_UMTS_DS_LEN
#define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN

/* Our own net device operations structure */
static const struct net_device_ops sierra_net_device_ops =;

/* get private data associated with passed in usbnet device */
static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
{}

/* set private data associated with passed in usbnet device */
static inline void sierra_net_set_private(struct usbnet *dev,
			struct sierra_net_data *priv)
{}

/* is packet IPv4/IPv6 */
static inline int is_ip(struct sk_buff *skb)
{}

/*
 * check passed in packet and make sure that:
 *  - it is linear (no scatter/gather)
 *  - it is ethernet (mac_header properly set)
 */
static int check_ethip_packet(struct sk_buff *skb, struct usbnet *dev)
{}

static const u8 *save16bit(struct param *p, const u8 *datap)
{}

static const u8 *save8bit(struct param *p, const u8 *datap)
{}

/*----------------------------------------------------------------------------*
 *                              BEGIN HIP                                     *
 *----------------------------------------------------------------------------*/
/* HIP header */
#define SIERRA_NET_HIP_HDR_LEN
/* Extended HIP header */
#define SIERRA_NET_HIP_EXT_HDR_LEN

struct hip_hdr {};

static int parse_hip(const u8 *buf, const u32 buflen, struct hip_hdr *hh)
{}

static void build_hip(u8 *buf, const u16 payloadlen,
		struct sierra_net_data *priv)
{}
/*----------------------------------------------------------------------------*
 *                              END HIP                                       *
 *----------------------------------------------------------------------------*/

static int sierra_net_send_cmd(struct usbnet *dev,
		u8 *cmd, int cmdlen, const char * cmd_name)
{}

static int sierra_net_send_sync(struct usbnet *dev)
{}

static void sierra_net_set_ctx_index(struct sierra_net_data *priv, u8 ctx_ix)
{}

static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
{}

static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
		struct hip_hdr	*hh)
{}

static void sierra_net_dosync(struct usbnet *dev)
{}

static void sierra_net_kevent(struct work_struct *work)
{}

static void sierra_net_defer_kevent(struct usbnet *dev, int work)
{}

/*
 * Sync Retransmit Timer Handler. On expiry, kick the work queue
 */
static void sierra_sync_timer(struct timer_list *t)
{}

static void sierra_net_status(struct usbnet *dev, struct urb *urb)
{}

static void sierra_net_get_drvinfo(struct net_device *net,
		struct ethtool_drvinfo *info)
{}

static u32 sierra_net_get_link(struct net_device *net)
{}

static const struct ethtool_ops sierra_net_ethtool_ops =;

static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap)
{}

/*
 * collects the bulk endpoints, the status endpoint.
 */
static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
{}

static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
{}

static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev,
		struct sk_buff *skb, int len)
{}

/* ---------------------------- Receive data path ----------------------*/
static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{}

/* ---------------------------- Transmit data path ----------------------*/
static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
					   struct sk_buff *skb, gfp_t flags)
{}

static const struct driver_info sierra_net_info_direct_ip =;

static int
sierra_net_probe(struct usb_interface *udev, const struct usb_device_id *prod)
{}

#define DIRECT_IP_DEVICE(vend, prod)

static const struct usb_device_id products[] =;
MODULE_DEVICE_TABLE(usb, products);

/* We are based on usbnet, so let it handle the USB driver specifics */
static struct usb_driver sierra_net_driver =;

module_usb_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_VERSION();
MODULE_LICENSE();