In article <trinity-df23ac7e-ee98-47b8-854b-ae7208449139-1509099592103@3c-app-mailcom-lxa13>, Rocky Hotas <[email protected]> wrote: >Hi all! >I am working to adapt the OpenBSD if_msk.c driver to NetBSD. If needed, >these are my previous messages as a recap: > >http://mail-index.netbsd.org/tech-kern/2017/10/11/msg022430.html >http://mail-index.netbsd.org/tech-kern/2017/10/11/msg022431.html > >OpenBSD made a huge modification to the `msk_newbuf' function with >rev. 1.72: > >http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/if_msk.c?rev=1.72&content-type=text/x-cvsweb-markup > >(see the commit comments for the details). They use the MCLGETI macro >defined here: > >http://bxr.su/OpenBSD/sys/sys/mbuf.h#315 > >In NetBSD this is a function, not a macro, and it is used only internally >by these two drivers: > >src/sys/dev/ic/arn5008.c >src/sys/dev/ic/arn9003.c > >Moreover, > >src/sys/dev/pci/if_iwn.c > >uses an improved version (maybe useful for the above files too in the >future) of the same function.
I would not call it "improved" :-) >The OpenBSD macro refers instead to the function `m_clget' defined here: > >http://bxr.su/OpenBSD/sys/kern/uipc_mbuf.c#348 > >It is different, as regards the use of the pointer `struct pool *pp', >the variable `caddr_t buf' and the flow itself of the code. >Is there a way to adapt it to NetBSD even so? Or can NetBSD use a new >function which could do the same? >Bye! OpenBSD: m = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES); if (m == NULL) goto fail; NetBSD: MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) goto fail; MCLGET(m, M_DONTWAIT); if (m->m_flags & M_EXT) == 0) { m_freem(m); goto fail; } It is not such a big deal :-) Or if you want to allocate a size other than MCLBYTES (I am not sure if that works, perhaps we need a different pool), use: _MCLGET(m, mcl_cache, size, M_DONTWAIT) It is ~trivial to add the macro in <sys/mbuf.h> and since we are porting too many OpenBSD drivers, perhaps we should. But this should be discussed in tech-net. christos
