Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LINUX/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ remoteobjs-$(CONFIG_NETMAP_VALE) += netmap_vale.o netmap_offloadings.o
remoteobjs-$(CONFIG_NETMAP_PIPE) += netmap_pipe.o
remoteobjs-$(CONFIG_NETMAP_MONITOR) += netmap_monitor.o
remoteobjs-$(CONFIG_NETMAP_GENERIC) += netmap_generic.o
remoteobjs-$(CONFIG_NETMAP_PASTE) += netmap_paste.o
remoteobjs-$(CONFIG_NETMAP_NULL) += netmap_null.o

define remote_template
Expand Down
89 changes: 89 additions & 0 deletions LINUX/bsd_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
#include <linux/page_ref.h>
#endif /* NETMAP_LINUX_HAVE_PAGE_REF */

#ifndef NETMAP_LINUX_HAVE_PAGE_TO_VIRT
#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
#endif /* NETMAP_LINUX_HAVE_PAGE_TO_VIRT */

#ifndef NETMAP_LINUX_HAVE_HRTIMER_MODE_REL
#define HRTIMER_MODE_REL HRTIMER_REL
#endif
Expand Down Expand Up @@ -555,4 +559,89 @@ void netmap_bns_unregister(void);
#define BIT_ULL(nr) (1ULL << (nr))
#endif /* !BIT_ULL */

/*
* for PASTE
*/
#define curcpu smp_processor_id()
#define so_lock(_s) lock_sock(_s)
#define so_unlock(_s) release_sock(_s)
#define SOCKBUF_LOCK(sb)
#define SOCKBUF_UNLOCK(sb)
#define pause(_s, _v) usleep_range((_v) * 1000, (_v) * 1000 + 5000)
#define nm_os_sock_set_nocoalesce(_sb)

static inline u_int
intr_disable(void)
{
local_bh_disable();
return 0;
}

static inline void
intr_restore(u_int intr)
{
local_bh_enable();
}

#define MBUF_L3_OFST(m) skb_network_offset(m)
#define MBUF_L4_OFST(m) skb_transport_offset(m)
#define MBUF_L3_HEADER(m) skb_network_header(m)
#define MBUF_L4_HEADER(m) skb_transport_header(m)
#define MBUF_HASNEXT(m) skb_is_nonlinear(m)
#define MBUF_FLATTEN(m) skb_linearize(m)
#define MBUF_DATA(m) (m)->data
#define MBUF_CSUM_DONE(m) ((m)->ip_summed = CHECKSUM_COMPLETE)

#define NM_SOCK_T struct sock
#define SAVE_SOUPCALL(sk, soa) \
(soa)->save_soupcall = (sk)->sk_data_ready
#define RESTORE_SOUPCALL(sk, soa) \
(sk)->sk_data_ready = (void *)(soa)->save_soupcall
#define SAVE_SODTOR(sk, soa) \
(soa)->save_sodtor = (sk)->sk_destruct
#define RESTORE_SODTOR(sk, soa) \
(sk)->sk_destruct = (void *)(soa)->save_sodtor
#define SET_SOUPCALL(sk, f) (sk)->sk_data_ready = (void *)f
#define SET_SODTOR(sk, f) (sk)->sk_destruct = (void *)f
#define so_dtor sk_destruct
#define MBUF_HDRLEN(m) skb_headlen(m)

/* NMCB() is only valid for mbuf populated by nm_os_build_mbuf() */
#define NMCB(_m) ((struct nmcb *)(_m)->head)
#define NMCB_EXT(_m, _i, _bs) \
NMCB_BUF(page_address(skb_frag_page(&skb_shinfo(_m)->frags[_i])) + \
_bs * (skb_frag_off(&skb_shinfo(_m)->frags[_i]) / _bs))
#define NMCB_BUF(_buf) ((struct nmcb *)(_buf))
#define m_length(_m, _x) (_m)->len

struct nm_ubuf_info {
struct ubuf_info ubuf;
};

#define nmcb_kring(nmcb) ((struct netmap_kring *)(nmcb)->ui.ubuf.ctx)
#define nmcb_slot(nmcb) ((struct netmap_slot *)(uintptr_t)(nmcb)->ui.ubuf.desc)
#define nmcbw(cb, kring, slot) do {\
(cb)->ui.ubuf.ctx = (kring);\
(cb)->ui.ubuf.desc = (uintptr_t)(slot);\
} while (0)

static inline struct pst_so_adapter *
pst_so(NM_SOCK_T *sk)
{
return (struct pst_so_adapter *)sk->sk_user_data;
}

/* We overwrite sk->sk_cookie as it appear not to be used */
static inline void
pst_wso(struct pst_so_adapter *soa, NM_SOCK_T *sk)
{
sk->sk_user_data = soa;
}

#ifndef NETMAP_LINUX_HAVE_NETIF_RECEIVE_SKB_CORE
#define netif_receive_skb_core netif_receive_skb
#endif /* NETMAP_LINUX_HAVE_NETIF_RECEIVE_SKB_CORE */
#ifndef NETMAP_LINUX_HAVE_SKB_FRAG_OFF
#define skb_frag_off(_f) (_f)->page_offset
#endif /* NETMAP_LINUX_HAVE_NETIF_RECEIVE_SKB_CORE */
#endif /* NETMAP_BSD_GLUE_H */
67 changes: 66 additions & 1 deletion LINUX/configure
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ setop()

# available subsystems
subsystem_avail="vale pipe monitor generic ptnetmap sink \
extmem null"
extmem paste null"
#enabled subsystems (bitfield)
subsystem=0

Expand Down Expand Up @@ -323,6 +323,8 @@ Available options:
--mod-name= netmap module name [$MODNAME]
--enable-vale enable the VALE switch
--disable-vale disable the VALE switch
--enable-paste enable netmap API for kernel TCP/IP
--disable-paste disable netmap API for kernel TCP/IP
--enable-pipe enable the netmap pipes
--disable-pipe disable the netmap pipes
--enable-monitor enable the nemtap monitors
Expand Down Expand Up @@ -1575,6 +1577,15 @@ EOF
EOF
done

# page_to_virt
add_test 'have PAGE_TO_VIRT' <<EOF
#include <linux/mm.h>
void *
dummy(struct page *page) {
return page_to_virt(page);
}
EOF

# check for third argument in qdisc enqueue callbacks
add_test 'have QDISC_ENQUEUE_TOFREE' <<EOF
#include <net/sch_generic.h>
Expand Down Expand Up @@ -1605,6 +1616,48 @@ EOF
}
EOF

# check for kernel_sendpage_locked
add_test 'have KERNEL_SENDPAGE_LOCKED' <<EOF
#include <linux/net.h>

int
dummy(struct sock *sk) {
return kernel_sendpage_locked(sk, NULL, 0, 0, 0);
}
EOF

# check for netif_receive_skb_core
add_test 'have NETIF_RECEIVE_SKB_CORE' <<EOF
#include <linux/netdevice.h>

int
dummy(struct sk_buff *skb) {
return netif_receive_skb_core(skb);
}
EOF

# arguments of skb_zcopy_set (either 2 or 3)
add_test 'define SKB_ZCOPY_SET_3ARGS' <<EOF
#include <linux/skbuff.h>

void
dummy(struct sk_buff *skb, struct ubuf_info *ui)
{
skb_zcopy_set(skb, ui, NULL);
}
EOF

# arguments of skb_zcopy_set (either 2 or 3)
add_test 'have SKB_FRAG_OFF' <<EOF
#include <linux/skbuff.h>

unsigned int
dummy(struct sk_buff *skb)
{
return skb_frag_off(&skb_shinfo(skb)->frags[0]);
}
EOF

# check for fault arguments
add_test 'have FAULT_VMA_ARG' <<EOF
#include <linux/mm.h>
Expand Down Expand Up @@ -1743,11 +1796,23 @@ EOF

# check for extack in Qdisc_ops init callback
add_test 'have QDISC_EXTACK' <<EOF
#include <linux/netlink.h>
#include <net/sch_generic.h>

int
dummy(struct Qdisc_ops *ops, struct netlink_ext_ack *extack) {
return ops->init(NULL, NULL, extack);

Comment thread
micchie marked this conversation as resolved.
Outdated
EOF

# check for SO_TIMESTAMPING in sock
add_test 'have SO_TIMESTAMPING' <<EOF
#include <net/sock.h>
#include <net/ip.h>

void
dummy(struct sock *sk, struct ipcm_cookie *ipc) {
sock_tx_timestamp(sk, ipc->sockc.tsflags, &ipc->tx_flags);
}
EOF

Expand Down
Loading