Re: umb(4) supports for SIMCom SIM7600

2021-09-25 Thread Shawn Chiou
Hi,

I tested it on my thinkpad X230 with OpenBSD -current amd64.

I can get the following messages from console after AT commands issued.

umb0 at uhub0 port 2 configuration 1 interface 5 "SIMCOM INCORPORATED
> SimTech, Incorporated" rev 2.00/3.18 addr 2
> ugen2 at uhub0 port 2 configuration 1 "SIMCOM INCORPORATED SimTech,
> Incorporated" rev 2.00/3.18 addr 2
>

The device connects to INTERNET when it is up.

umb0: flags=8851 mtu 1434
> index 7 priority 6 llprio 3
> roaming disabled registration home network
> state up cell-class LTE rssi -101dBm speed 47.7Mbps up 95.4Mbps
> down
> SIM initialized PIN valid (3 attempts left)
> subscriber-id 466891003015519 ICC-id 89886891000658005192
> device SIMCOM_SIM7600G-H IMEI 868822040711739 firmware
> LE20B03SIM7600M22
> provider  provider-id 46689
> dns 172.24.9.21 10.9.121.102
> groups: egress
> status: active
> inet 100.80.19.216 --> 100.80.19.217 netmask 0xfff0
>

And I can traceroute or ping via the device.

X230$ traceroute 168.95.1.1
> traceroute to 168.95.1.1 (168.95.1.1), 64 hops max, 40 byte packets
>  1  * * *
>  2  10.11.209.64 (10.11.209.64)  33.62 ms  15.621 ms  15.953 ms
>  3  10.11.30.34 (10.11.30.34)  15.849 ms  15.981 ms  16.889 ms
>  4  10.9.3.49 (10.9.3.49)  15.823 ms  15.87 ms  15.857 ms
>  5  10.9.166.105 (10.9.166.105)  15.909 ms  15.898 ms  16.858 ms
>  6  10.9.166.90 (10.9.166.90)  15.864 ms  15.902 ms  15.954 ms
>  7  202.144.222.130 (202.144.222.130)  15.939 ms  17.88 ms 202.144.222.222
> (202.144.222.222)  25.773 ms
>  8  r4209-s2.hinet.net (203.75.228.94)  26.89 ms  15.921 ms  15.973 ms
>  9  210-59-204-129.hinet-ip.hinet.net (210.59.204.129)  16.892 ms  18.772
> ms  16.885 ms
> 10  dns.hinet.net (168.95.1.1)  16.93 ms !C  15.869 ms !C  16.758 ms !C
> X230$ ping dns.hinet.net
> ping: Warning: dns.hinet.net has multiple addresses; using 168.95.192.1
> PING dns.hinet.net (168.95.192.1): 56 data bytes
> 64 bytes from 168.95.192.1: icmp_seq=0 ttl=54 time=18.378 ms
> 64 bytes from 168.95.192.1: icmp_seq=1 ttl=54 time=25.051 ms
> 64 bytes from 168.95.192.1: icmp_seq=2 ttl=54 time=24.953 ms
> ^C
> --- dns.hinet.net ping statistics ---
> 3 packets transmitted, 3 packets received, 0.0% packet loss
> round-trip min/avg/max/std-dev = 18.378/22.794/25.051/3.123 ms
>

It works properly!

On Fri, Sep 24, 2021 at 12:39 PM Kevin Lo  wrote:

> Hi,
>
> The diff below enables umb(4) support for SIMCom SIM7600.
>
> The SIM7600 is a mbim compatible chip, you'll need to switch it into mbim
> mode via specific AT-commands (AT+CUSBPIDSWITCH=9003,1,1 and AT+CLANMODE=1)
> over the serial port.
>
> umb0 at uhub1 port 2 "SIMCOM INCORPORATED SimTech, Incorporated" rev
> 2.00/3.18 addr 3
>
> ok?
>
> Index: share/man/man4/umb.4
> ===
> RCS file: /cvs/src/share/man/man4/umb.4,v
> retrieving revision 1.13
> diff -u -p -u -p -r1.13 umb.4
> --- share/man/man4/umb.418 May 2021 14:23:03 -  1.13
> +++ share/man/man4/umb.424 Sep 2021 01:12:22 -
> @@ -50,6 +50,7 @@ The following devices should work:
>  .\" .It Huawei ME906s -- attaches but needs more work
>  .It Medion Mobile S4222 (MediaTek OEM)
>  .It Quectel EC25
> +.It SIMCom SIM7600
>  .It Sierra Wireless EM7345
>  .It Sierra Wireless EM7455
>  .It Sierra Wireless EM8805
> Index: sys/dev/usb/if_umb.c
> ===
> RCS file: /cvs/src/sys/dev/usb/if_umb.c,v
> retrieving revision 1.46
> diff -u -p -u -p -r1.46 if_umb.c
> --- sys/dev/usb/if_umb.c4 Jul 2021 19:22:31 -   1.46
> +++ sys/dev/usb/if_umb.c24 Sep 2021 01:12:24 -
> @@ -256,6 +256,12 @@ const struct umb_quirk umb_quirks[] = {
>   0,
>   0
> },
> +
> +   { { USB_VENDOR_SIMCOM, USB_PRODUCT_SIMCOM_SIM7600 },
> + 0,
> + 1,
> + UMATCH_VENDOR_PRODUCT
> +   },
>  };
>
>  #define umb_lookup(vid, pid)   \
> Index: sys/dev/usb/usbdevs
> ===
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.741
> diff -u -p -u -p -r1.741 usbdevs
> --- sys/dev/usb/usbdevs 31 Aug 2021 22:55:56 -  1.741
> +++ sys/dev/usb/usbdevs 24 Sep 2021 01:12:24 -
> @@ -4123,6 +4123,7 @@ product SILICONPORTALS YAPPHONE   0x0201  Y
>
>  /* Simcom products */
>  product SIMCOM SIM7600E0x9001  SIM7600E modem
> +product SIMCOM SIM7600 0x9003  SIM7600 LTE
>
>  /* Sirius Technologies products */
>  product SIRIUS ROADSTER0x0001  NetComm Roadster II 56
>
>

-- 
<https://about.me/shawn.chiou?promo=email_sig_source=product_medium=email_sig_campaign=edit_panel_content=thumb>
Shawn Chiou
about.me/shawn.chiou
<https://about.me/shawn.chiou?promo=email_sig_source=product_medium=email_sig_campaign=edit_panel_content=thumb>


Re: umsm(4)/umb(4) supports for Quectel EC25

2021-05-16 Thread Shawn Chiou
t; Ta "PCI Express Mini Card"
>  .It Li "Sierra Wireless MC8755" Ta "PCI Express Mini Card"
>  .It Li "Sierra Wireless MC8775" Ta "PCI Express Mini Card"
>  .It Li "Sierra Wireless MC8790" Ta "PCI Express Mini Card"
> Index: sys/dev/usb/if_umb.c
> ===
> RCS file: /cvs/src/sys/dev/usb/if_umb.c,v
> retrieving revision 1.44
> diff -u -p -u -p -r1.44 if_umb.c
> --- sys/dev/usb/if_umb.c22 Apr 2021 14:06:59 -  1.44
> +++ sys/dev/usb/if_umb.c15 May 2021 09:05:35 -
> @@ -238,6 +238,13 @@ const struct umb_quirk umb_quirks[] = {
>   UMATCH_VENDOR_PRODUCT
> },
>
> +   { { USB_VENDOR_QUECTEL, USB_PRODUCT_QUECTEL_EC25 },
> + 0,
> + 1,
> + UMATCH_VENDOR_PRODUCT
> +   },
> +
> +
> { { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_ME906S },
>   UMBFLG_NDP_AT_END,
>   3,
> Index: sys/dev/usb/umsm.c
> ===
> RCS file: /cvs/src/sys/dev/usb/umsm.c,v
> retrieving revision 1.118
> diff -u -p -u -p -r1.118 umsm.c
> --- sys/dev/usb/umsm.c  31 Jul 2020 10:49:33 -  1.118
> +++ sys/dev/usb/umsm.c  15 May 2021 09:05:35 -
> @@ -173,6 +173,8 @@ static const struct umsm_type umsm_devs[
> {{ USB_VENDOR_QUANTA2, USB_PRODUCT_QUANTA2_UMASS }, DEV_UMASS4},
> {{ USB_VENDOR_QUANTA2, USB_PRODUCT_QUANTA2_Q101 }, 0},
>
> +   {{ USB_VENDOR_QUECTEL, USB_PRODUCT_QUECTEL_EC25 }, 0},
> +
> {{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_AC2746 }, 0},
> {{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_UMASS_INSTALLER }, DEV_UMASS4},
> {{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_UMASS_INSTALLER2 }, DEV_UMASS6},
> Index: sys/dev/usb/usbdevs
> ===
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.739
> diff -u -p -u -p -r1.739 usbdevs
> --- sys/dev/usb/usbdevs 25 Apr 2021 15:58:01 -  1.739
> +++ sys/dev/usb/usbdevs 15 May 2021 09:05:35 -
> @@ -644,6 +644,7 @@ vendor THINGM   0x27b8  ThingM
>  vendor ASUSTEK 0x2821  ASUSTeK Computer
>  vendor PIONEERDJ   0x2b73  Pioneer DJ
>  vendor PLANEX  0x2c02  Planex Communications
> +vendor QUECTEL 0x2c7c  Quectel
>  vendor CLUB3D  0x2d1c  Club 3D
>  vendor CLEVO   0x30da  CLEVO
>  vendor DYNABOOK    0x30f3  Dynabook
> @@ -3679,6 +3680,9 @@ product QUALCOMM2 MSM_PHONE   0x6000  CDMA
>  product QUANTA RT3070  0x0304  RT3070
>  product QUANTA2 UMASS  0x1000  Quanta USB MSM (umass mode)
>  product QUANTA2 Q101   0xea02  Quanta Q101 HSDPA USB modem
> +
> +/* Quectel products */
> +product QUECTEL EC25   0x0125  EC25 LTE
>
>  /* Quickshot products */
>  product QUICKSHOT STRIKEPAD0x6238  USB StrikePad
>
>

-- 
<https://about.me/shawn.chiou?promo=email_sig_source=product_medium=email_sig_campaign=edit_panel_content=thumb>
Shawn Chiou
about.me/shawn.chiou
<https://about.me/shawn.chiou?promo=email_sig_source=product_medium=email_sig_campaign=edit_panel_content=thumb>


Re: ure(4): add preliminary support for RTL8156

2019-12-04 Thread Shawn Chiou
@ -1553,7 +1809,6 @@ ure_txeof(struct usbd_xfer *xfer, void *
> ure_start(ifp);
>
> splx(s);
> -
>  }
>
>  int
> @@ -1573,8 +1828,7 @@ ure_tx_list_init(struct ure_softc *sc)
> c->uc_xfer = usbd_alloc_xfer(sc->ure_udev);
> if (c->uc_xfer == NULL)
> return ENOBUFS;
> -   c->uc_buf = usbd_alloc_buffer(c->uc_xfer,
> -   sc->ure_bufsz);
> +   c->uc_buf = usbd_alloc_buffer(c->uc_xfer,
> URE_TXBUFSZ);
> if (c->uc_buf == NULL) {
> usbd_free_xfer(c->uc_xfer);
> return ENOBUFS;
> @@ -1582,7 +1836,9 @@ ure_tx_list_init(struct ure_softc *sc)
> }
> }
>
> -   return 0;
> +   cd->tx_prod = cd->tx_cnt = 0;
> +
> +   return (0);
>  }
>
>  int
> @@ -1603,7 +1859,7 @@ ure_rx_list_init(struct ure_softc *sc)
> if (c->uc_xfer == NULL)
> return ENOBUFS;
> c->uc_buf = usbd_alloc_buffer(c->uc_xfer,
> -   sc->ure_bufsz);
> +   sc->ure_rxbufsz);
> if (c->uc_buf == NULL) {
> usbd_free_xfer(c->uc_xfer);
> return ENOBUFS;
> @@ -1611,7 +1867,7 @@ ure_rx_list_init(struct ure_softc *sc)
> }
> }
>
> -   return 0;
> +   return (0);
>  }
>
>  int
> @@ -1621,21 +1877,18 @@ ure_encap(struct ure_softc *sc, struct m
> usbd_status err;
> struct ure_txpkttxhdr;
> uint32_tfrm_len = 0;
> -   u_char  *buf;
>
> c = >ure_cdata.tx_chain[idx];
> -   buf = c->uc_buf;
>
> /* header */
> htolem32(_pktlen, m->m_pkthdr.len | URE_TXPKT_TX_FS |
> URE_TXPKT_TX_LS);
> txhdr.ure_rsvd0 = 0;
> -   memcpy(buf, , sizeof(txhdr));
> -   buf += sizeof(txhdr);
> +   memcpy(c->uc_buf, , sizeof(txhdr));
> frm_len = sizeof(txhdr);
>
> /* packet */
> -   m_copydata(m, 0, m->m_pkthdr.len, buf);
> +   m_copydata(m, 0, m->m_pkthdr.len, c->uc_buf + frm_len);
> frm_len += m->m_pkthdr.len;
>
> c->uc_mbuf = m;
> @@ -1647,9 +1900,8 @@ ure_encap(struct ure_softc *sc, struct m
> err = usbd_transfer(c->uc_xfer);
> if (err != USBD_IN_PROGRESS) {
> ure_stop(sc);
> -   return EIO;
> +   return (EIO);
> }
>
> -   sc->ure_cdata.tx_cnt++;
> -   return 0;
> +   return (0);
>  }
> Index: sys/dev/usb/if_urereg.h
> ===
> RCS file: /cvs/src/sys/dev/usb/if_urereg.h,v
> retrieving revision 1.7
> diff -u -p -u -p -r1.7 if_urereg.h
> --- sys/dev/usb/if_urereg.h 29 Aug 2019 08:55:06 -  1.7
> +++ sys/dev/usb/if_urereg.h 3 Dec 2019 08:29:41 -
> @@ -41,10 +41,10 @@
>  #defineURE_BYTE_EN_BYTE0x11
>  #defineURE_BYTE_EN_SIX_BYTES   0x3f
>
> -#defineURE_FRAMELEN(mtu)   \
> +#define URE_FRAMELEN(mtu)  \
> (mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN)
> -#defineURE_JUMBO_FRAMELEN  (9 * 1024)
> -#defineURE_JUMBO_MTU   \
> +#define URE_JUMBO_FRAMELEN (9 * 1024)
> +#define URE_JUMBO_MTU  \
> (URE_JUMBO_FRAMELEN - ETHER_HDR_LEN - ETHER_CRC_LEN -   \
>  ETHER_VLAN_ENCAP_LEN)
>
> @@ -310,6 +310,14 @@
>  /* URE_PLA_EXTRA_STATUS */
>  #defineURE_LINK_CHANGE_FLAG0x0100
>
> +/* URE_PLA_PHYSTATUS */
> +#define URE_PHYSTATUS_FDX  0x0001
> +#define URE_PHYSTATUS_LINK 0x0002
> +#define URE_PHYSTATUS_10MBPS   0x0004
> +#define URE_PHYSTATUS_100MBPS  0x0008
> +#define URE_PHYSTATUS_1000MBPS 0x0010
> +#define URE_PHYSTATUS_2500MBPS 0x0400
> +
>  /* URE_USB_USB2PHY */
>  #defineURE_USB2PHY_SUSPEND 0x0001
>  #defineURE_USB2PHY_L1  0x0002
> @@ -432,6 +440,8 @@
>  #defineURE_ADC_EN  0x0080
>  #defineURE_CKADSEL_L   0x0100
>
> +#define URE_ADV_2500TFDX   0x0080
> +
>  #defineURE_MCU_TYPE_PLA0x0100
>  #defineURE_MCU_TYPE_USB0x
>
> @@ -470,11 +480,13 @@ struct ure_txpkt {
>  #define URE_ENDPT_TX   1
>  #define URE_ENDPT_MAX  2
>
> -#defineURE_TX_LIST_CNT 1
> +#defineURE_TX_LIST_CNT 4
>  #defineURE_RX_LIST_CNT 1
>  #defineURE_RX_BUF_ALIGNsizeof(uint64_t)
>
> -#defineURE_BUFSZ   16384
> +#defineURE_TXBUFSZ 16384
> +#defineURE_8152_RXBUFSZ16384
> +#defineURE_8153_RXBUFSZ32768
>
>  struct ure_chain {
> struct ure_softc*uc_sc;
> @@ -489,9 +501,7 @@ struct ure_cdata {
> struct ure_chaintx_chain[URE_TX_LIST_CNT];
> struct ure_chainrx_chain[URE_RX_LIST_CNT];
> int tx_prod;
> -   int tx_const;
> int tx_cnt;
> -   int rx_prod;
>  };
>
>  struct ure_softc {
> @@ -508,6 +518,7 @@ struct ure_softc {
> /* ethernet */
> struct arpcom   ure_ac;
> struct mii_data ure_mii;
> +   struct ifmedia  ure_ifmedia;
> struct rwlock   ure_mii_lock;
> int ure_refcnt;
>
> @@ -515,7 +526,7 @@ struct ure_softc {
> struct timeout  ure_stat_ch;
>
> struct timeval  ure_rx_notice;
> -   int ure_bufsz;
> +   int ure_rxbufsz;
>
> int ure_phyno;
>
> @@ -523,6 +534,7 @@ struct ure_softc {
>  #defineURE_FLAG_LINK   0x0001
>  #defineURE_FLAG_8152   0x1000  /* RTL8152 */
>  #defineURE_FLAG_8153B  0x2000  /* RTL8153B */
> +#defineURE_FLAG_8156   0x4000  /* RTL8156 */
>
> u_int   ure_chip;
>  #defineURE_CHIP_VER_4C00   0x01
> Index: sys/dev/usb/usbdevs
> ===
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.701
> diff -u -p -u -p -r1.701 usbdevs
> --- sys/dev/usb/usbdevs 27 Aug 2019 17:59:58 -  1.701
> +++ sys/dev/usb/usbdevs 3 Dec 2019 08:29:41 -
> @@ -3597,6 +3597,7 @@ product REALTEK RTL8150   0x8150  RTL8150
>  product REALTEK RTL81510x8151  RTL8151 PNA
>  product REALTEK RTL81520x8152  RTL8152
>  product REALTEK RTL81530x8153  RTL8153
> +product REALTEK RTL81560x8156  RTL8156
>  product REALTEK RTL8188CE_00x8170  RTL8188CE
>  product REALTEK RTL81710x8171  RTL8171
>  product REALTEK RTL81720x8172  RTL8172
>
>
I've tested with Asustor as-u2.5g.

ure0 at uhub0 port 6 configuration 1 interface 0 "Realtek USB
10/100/1G/2.5G LAN" rev 3.20/30.00 addr 2

ure0: RTL8156 (0x7030), address 00:24:27:88:00:a1

It works properly as usual.

Thank you,

Shawn
-- 


[image: --]

Shawn Chiou
[image: https://]about.me/shawn.chiou
<https://about.me/shawn.chiou?promo=email_sig_source=email_sig_medium=email_sig_campaign=external_links>