rmnet_usb.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __RMNET_USB_H
  13. #define __RMNET_USB_H
  14. #include <linux/mutex.h>
  15. #include <linux/usb.h>
  16. #include <linux/cdev.h>
  17. #include <linux/usb/ch9.h>
  18. #include <linux/usb/cdc.h>
  19. #define MAX_RMNET_DEVS 4
  20. #define MAX_RMNET_INSTS_PER_DEV 17
  21. #define TOTAL_RMNET_DEV_COUNT (MAX_RMNET_DEVS * MAX_RMNET_INSTS_PER_DEV)
  22. #define CTRL_DEV_MAX_LEN 10
  23. #define RMNET_CTRL_DEV_OPEN 0
  24. #define RMNET_CTRL_DEV_READY 1
  25. #define RMNET_CTRL_DEV_MUX_EN 2
  26. /*MUX header bit masks*/
  27. #define MUX_CTRL_MASK 0x1
  28. #define MUX_PAD_SHIFT 0x2
  29. /*max padding bytes for n byte alignment*/
  30. #define MAX_PAD_BYTES(n) (n-1)
  31. /*
  32. *MUX Header Format
  33. *BIT 0 : Mux type 0: Data, 1: control
  34. *BIT 1: Reserved
  35. *BIT 2-7: Pad bytes
  36. *BIT 8-15: Mux ID
  37. *BIT 16-31: PACKET_LEN_WITH_PADDING (Bytes)
  38. */
  39. struct mux_hdr {
  40. __u8 padding_info;
  41. __u8 mux_id;
  42. __le16 pkt_len_w_padding;
  43. } __packed;
  44. struct rmnet_ctrl_dev {
  45. /*for debugging purpose*/
  46. char name[CTRL_DEV_MAX_LEN];
  47. struct cdev cdev;
  48. struct device *devicep;
  49. unsigned ch_id;
  50. /*to identify the usb device*/
  51. unsigned id;
  52. struct usb_interface *intf;
  53. unsigned int int_pipe;
  54. struct urb *rcvurb;
  55. struct urb *inturb;
  56. struct usb_anchor tx_submitted;
  57. struct usb_anchor rx_submitted;
  58. void *rcvbuf;
  59. void *intbuf;
  60. struct usb_ctrlrequest *in_ctlreq;
  61. spinlock_t rx_lock;
  62. struct mutex dev_lock;
  63. struct list_head rx_list;
  64. wait_queue_head_t read_wait_queue;
  65. wait_queue_head_t open_wait_queue;
  66. struct workqueue_struct *wq;
  67. struct work_struct get_encap_work;
  68. unsigned long status;
  69. bool claimed;
  70. unsigned int mdm_wait_timeout;
  71. /*input control lines (DSR, CTS, CD, RI)*/
  72. unsigned int cbits_tolocal;
  73. /*output control lines (DTR, RTS)*/
  74. unsigned int cbits_tomdm;
  75. /*counters*/
  76. unsigned int snd_encap_cmd_cnt;
  77. unsigned int get_encap_resp_cnt;
  78. unsigned int resp_avail_cnt;
  79. unsigned int get_encap_failure_cnt;
  80. unsigned int set_ctrl_line_state_cnt;
  81. unsigned int tx_ctrl_err_cnt;
  82. unsigned int zlp_cnt;
  83. };
  84. extern struct workqueue_struct *usbnet_wq;
  85. extern int rmnet_usb_ctrl_start_rx(struct rmnet_ctrl_dev *);
  86. extern int rmnet_usb_ctrl_suspend(struct rmnet_ctrl_dev *dev);
  87. extern int rmnet_usb_ctrl_init(int num_devs, int insts_per_dev);
  88. extern void rmnet_usb_ctrl_exit(int num_devs, int insts_per_dev);
  89. extern int rmnet_usb_ctrl_probe(struct usb_interface *intf,
  90. struct usb_host_endpoint *int_in,
  91. unsigned long rmnet_devnum,
  92. unsigned long *data);
  93. extern void rmnet_usb_ctrl_disconnect(struct rmnet_ctrl_dev *);
  94. #endif /* __RMNET_USB_H*/