Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys modularize, and fix build error



details:   https://anonhg.NetBSD.org/src/rev/fed4f123f84d
branches:  trunk
changeset: 944860:fed4f123f84d
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Oct 14 10:26:59 2020 +0000

description:
modularize, and fix build error

diffstat:

 sys/dev/pci/if_vmx.c             |  60 ++++++++++++++++++++++++++++++++--------
 sys/modules/Makefile             |   3 +-
 sys/modules/if_vmx/Makefile      |  12 ++++++++
 sys/modules/if_vmx/if_vmx.ioconf |  10 ++++++
 4 files changed, 72 insertions(+), 13 deletions(-)

diffs (202 lines):

diff -r ef389a6b61db -r fed4f123f84d sys/dev/pci/if_vmx.c
--- a/sys/dev/pci/if_vmx.c      Wed Oct 14 10:19:10 2020 +0000
+++ b/sys/dev/pci/if_vmx.c      Wed Oct 14 10:26:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vmx.c,v 1.1 2020/10/14 10:19:11 ryo Exp $   */
+/*     $NetBSD: if_vmx.c,v 1.2 2020/10/14 10:26:59 ryo Exp $   */
 /*     $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $        */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.1 2020/10/14 10:19:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.2 2020/10/14 10:26:59 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -29,6 +29,7 @@
 #include <sys/bus.h>
 #include <sys/device.h>
 #include <sys/mbuf.h>
+#include <sys/module.h>
 #include <sys/sockio.h>
 #include <sys/pcq.h>
 #include <sys/workqueue.h>
@@ -536,7 +537,7 @@
 vmxnet3_txring_avail(struct vmxnet3_txring *txr)
 {
        int avail = txr->vxtxr_next - txr->vxtxr_head - 1;
-       return (avail < 0 ? txr->vxtxr_ndesc + avail : avail);
+       return (avail < 0 ? (int)txr->vxtxr_ndesc + avail : avail);
 }
 
 /*
@@ -1372,7 +1373,8 @@
        struct vmxnet3_txring *txr;
        struct vmxnet3_comp_ring *txc;
        size_t descsz, compsz;
-       int i, q, error;
+       u_int i;
+       int q, error;
 
        dev = sc->vmx_dev;
 
@@ -1424,7 +1426,8 @@
        struct vmxnet3_txring *txr;
        struct vmxnet3_comp_ring *txc;
        struct vmxnet3_txbuf *txb;
-       int i, q;
+       u_int i;
+       int q;
 
        for (q = 0; q < sc->vmx_ntxqueues; q++) {
                txq = &sc->vmx_queue[q].vxq_txqueue;
@@ -1460,7 +1463,8 @@
        struct vmxnet3_rxring *rxr;
        struct vmxnet3_comp_ring *rxc;
        int descsz, compsz;
-       int i, j, q, error;
+       u_int i, j;
+       int q, error;
 
        dev = sc->vmx_dev;
 
@@ -1536,7 +1540,8 @@
        struct vmxnet3_rxring *rxr;
        struct vmxnet3_comp_ring *rxc;
        struct vmxnet3_rxbuf *rxb;
-       int i, j, q;
+       u_int i, j;
+       int q;
 
        for (q = 0; q < sc->vmx_nrxqueues; q++) {
                rxq = &sc->vmx_queue[q].vxq_rxqueue;
@@ -2337,7 +2342,7 @@
        struct vmxnet3_rxdesc *rxd __diagused;
        struct vmxnet3_rxcompdesc *rxcd;
        struct mbuf *m, *m_head, *m_tail;
-       int idx, length;
+       u_int idx, length;
        bool more = false;
 
        sc = rxq->vxrxq_sc;
@@ -2648,7 +2653,7 @@
 {
        struct vmxnet3_txring *txr;
        struct vmxnet3_txbuf *txb;
-       int i;
+       u_int i;
 
        txr = &txq->vxtxq_cmd_ring;
 
@@ -2672,7 +2677,7 @@
 {
        struct vmxnet3_rxring *rxr;
        struct vmxnet3_rxbuf *rxb;
-       int i, j;
+       u_int i, j;
 
        if (rxq->vxrxq_mhead != NULL) {
                m_freem(rxq->vxrxq_mhead);
@@ -2780,7 +2785,8 @@
 {
        struct vmxnet3_rxring *rxr;
        struct vmxnet3_comp_ring *rxc;
-       int i, populate, idx, error;
+       u_int i, populate, idx;
+       int error;
 
        /* LRO and jumbo frame is not supported yet */
        populate = 1;
@@ -3377,7 +3383,7 @@
                        error = EINVAL;
                        break;
                }
-               if (ifp->if_mtu != nmtu) {
+               if (ifp->if_mtu != (uint64_t)nmtu) {
                        s = splnet();
                        error = ether_ioctl(ifp, cmd, data);
                        splx(s);
@@ -3656,3 +3662,33 @@
 
        memset(dma, 0, sizeof(*dma));
 }
+
+MODULE(MODULE_CLASS_DRIVER, if_vmx, "pci");
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+if_vmx_modcmd(modcmd_t cmd, void *opaque)
+{
+       int error = 0;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+#ifdef _MODULE
+               error = config_init_component(cfdriver_ioconf_if_vmx,
+                   cfattach_ioconf_if_vmx, cfdata_ioconf_if_vmx);
+#endif
+               return error;
+       case MODULE_CMD_FINI:
+#ifdef _MODULE
+               error = config_fini_component(cfdriver_ioconf_if_vmx,
+                   cfattach_ioconf_if_vmx, cfdata_ioconf_if_vmx);
+#endif
+               return error;
+       default:
+               return ENOTTY;
+       }
+}
+
diff -r ef389a6b61db -r fed4f123f84d sys/modules/Makefile
--- a/sys/modules/Makefile      Wed Oct 14 10:19:10 2020 +0000
+++ b/sys/modules/Makefile      Wed Oct 14 10:26:59 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.246 2020/09/26 17:49:50 jmcneill Exp $
+#      $NetBSD: Makefile,v 1.247 2020/10/14 10:26:59 ryo Exp $
 
 .include <bsd.own.mk>
 
@@ -446,6 +446,7 @@
 SUBDIR+=       cac_pci
 SUBDIR+=       if_aq
 SUBDIR+=       if_vioif
+SUBDIR+=       if_vmx
 SUBDIR+=       ld
 SUBDIR+=       ld_aac
 SUBDIR+=       ld_amr
diff -r ef389a6b61db -r fed4f123f84d sys/modules/if_vmx/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_vmx/Makefile       Wed Oct 14 10:26:59 2020 +0000
@@ -0,0 +1,12 @@
+#      $NetBSD: Makefile,v 1.1 2020/10/14 10:26:59 ryo Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/dev/pci
+
+KMOD=  if_vmx
+IOCONF=        if_vmx.ioconf
+
+SRCS=  if_vmx.c
+
+.include <bsd.kmodule.mk>
diff -r ef389a6b61db -r fed4f123f84d sys/modules/if_vmx/if_vmx.ioconf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_vmx/if_vmx.ioconf  Wed Oct 14 10:26:59 2020 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: if_vmx.ioconf,v 1.1 2020/10/14 10:26:59 ryo Exp $
+
+ioconf if_vmx
+
+include "conf/files"
+include "dev/pci/files.pci"
+
+pseudo-root pci*
+
+vmx* at pci? dev ? function ?



Home | Main Index | Thread Index | Old Index