Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2013 22:14:58 +0000 (UTC)
From:      Luigi Rizzo <luigi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r245579 - head/sys/dev/netmap
Message-ID:  <201301172214.r0HMEwN5019545@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luigi
Date: Thu Jan 17 22:14:58 2013
New Revision: 245579
URL: http://svnweb.freebsd.org/changeset/base/245579

Log:
  add some definition and driver changes in preparation for
  two upcoming features:
  
  semi-transparent mode:
      when a device is opened in this mode, the
      user program will be able to mark slots that must be forwarded
      to the "other" side (i.e. from NIC to host stack, or viceversa),
      and the forwarding will occur automatically at the next netmap syscall.
      This saves the need to open another file descriptor and do
      the forwarding manually.
  
  direct-forwarding mode:
      when operating with a VALE port, the user can specify in the slot
      the actual destination port, overriding the forwarding decision
      made by a lookup of the destination MAC. This can be useful to
      implement packet dispatchers.
  
  No API changes will be introduced.
  No new functionality in this patch yet.

Modified:
  head/sys/dev/netmap/if_em_netmap.h
  head/sys/dev/netmap/if_igb_netmap.h
  head/sys/dev/netmap/if_lem_netmap.h
  head/sys/dev/netmap/if_re_netmap.h
  head/sys/dev/netmap/ixgbe_netmap.h
  head/sys/dev/netmap/netmap_kern.h

Modified: head/sys/dev/netmap/if_em_netmap.h
==============================================================================
--- head/sys/dev/netmap/if_em_netmap.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/if_em_netmap.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -292,6 +292,8 @@ em_netmap_rxsync(struct ifnet *ifp, u_in
 	l = rxr->next_to_check;
 	j = netmap_idx_n2k(kring, l);
 	if (netmap_no_pendintr || force_update) {
+		uint16_t slot_flags = kring->nkr_slot_flags;
+
 		for (n = 0; ; n++) {
 			struct e1000_rx_desc *curr = &rxr->rx_base[l];
 			uint32_t staterr = le32toh(curr->status);
@@ -299,6 +301,7 @@ em_netmap_rxsync(struct ifnet *ifp, u_in
 			if ((staterr & E1000_RXD_STAT_DD) == 0)
 				break;
 			ring->slot[j].len = le16toh(curr->length);
+			ring->slot[j].flags = slot_flags;
 			bus_dmamap_sync(rxr->rxtag, rxr->rx_buffers[l].map,
 				BUS_DMASYNC_POSTREAD);
 			j = (j == lim) ? 0 : j + 1;

Modified: head/sys/dev/netmap/if_igb_netmap.h
==============================================================================
--- head/sys/dev/netmap/if_igb_netmap.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/if_igb_netmap.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -263,6 +263,8 @@ igb_netmap_rxsync(struct ifnet *ifp, u_i
 	l = rxr->next_to_check;
 	j = netmap_idx_n2k(kring, l);
 	if (netmap_no_pendintr || force_update) {
+		uint16_t slot_flags = kring->nkr_slot_flags;
+
 		for (n = 0; ; n++) {
 			union e1000_adv_rx_desc *curr = &rxr->rx_base[l];
 			uint32_t staterr = le32toh(curr->wb.upper.status_error);
@@ -270,6 +272,7 @@ igb_netmap_rxsync(struct ifnet *ifp, u_i
 			if ((staterr & E1000_RXD_STAT_DD) == 0)
 				break;
 			ring->slot[j].len = le16toh(curr->wb.upper.length);
+			ring->slot[j].flags = slot_flags;
 			bus_dmamap_sync(rxr->ptag,
 				rxr->rx_buffers[l].pmap, BUS_DMASYNC_POSTREAD);
 			j = (j == lim) ? 0 : j + 1;

Modified: head/sys/dev/netmap/if_lem_netmap.h
==============================================================================
--- head/sys/dev/netmap/if_lem_netmap.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/if_lem_netmap.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -253,6 +253,8 @@ lem_netmap_rxsync(struct ifnet *ifp, u_i
 	l = adapter->next_rx_desc_to_check;
 	j = netmap_idx_n2k(kring, l);
 	if (netmap_no_pendintr || force_update) {
+		uint16_t slot_flags = kring->nkr_slot_flags;
+
 		for (n = 0; ; n++) {
 			struct e1000_rx_desc *curr = &adapter->rx_desc_base[l];
 			uint32_t staterr = le32toh(curr->status);
@@ -266,6 +268,7 @@ lem_netmap_rxsync(struct ifnet *ifp, u_i
 				len = 0;
 			}
 			ring->slot[j].len = len;
+			ring->slot[j].flags = slot_flags;
 			bus_dmamap_sync(adapter->rxtag,
 				adapter->rx_buffer_area[l].map,
 				    BUS_DMASYNC_POSTREAD);

Modified: head/sys/dev/netmap/if_re_netmap.h
==============================================================================
--- head/sys/dev/netmap/if_re_netmap.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/if_re_netmap.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -245,6 +245,8 @@ re_netmap_rxsync(struct ifnet *ifp, u_in
 	l = sc->rl_ldata.rl_rx_prodidx; /* next pkt to check */
 	j = netmap_idx_n2k(kring, l); /* the kring index */
 	if (netmap_no_pendintr || force_update) {
+		uint16_t slot_flags = kring->nkr_slot_flags;
+
 		for (n = kring->nr_hwavail; n < lim ; n++) {
 			struct rl_desc *cur_rx = &sc->rl_ldata.rl_rx_list[l];
 			uint32_t rxstat = le32toh(cur_rx->rl_cmdstat);
@@ -256,6 +258,7 @@ re_netmap_rxsync(struct ifnet *ifp, u_in
 			/* XXX subtract crc */
 			total_len = (total_len < 4) ? 0 : total_len - 4;
 			kring->ring->slot[j].len = total_len;
+			kring->ring->slot[j].flags = slot_flags;
 			/*  sync was in re_newbuf() */
 			bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag,
 			    rxd[l].rx_dmamap, BUS_DMASYNC_POSTREAD);

Modified: head/sys/dev/netmap/ixgbe_netmap.h
==============================================================================
--- head/sys/dev/netmap/ixgbe_netmap.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/ixgbe_netmap.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -483,6 +483,7 @@ ixgbe_netmap_rxsync(struct ifnet *ifp, u
 	 */
 	if (netmap_no_pendintr || force_update) {
 		int crclen = ix_crcstrip ? 0 : 4;
+		uint16_t slot_flags = kring->nkr_slot_flags;
 
 		l = rxr->next_to_check;
 		j = netmap_idx_n2k(kring, l);
@@ -494,6 +495,7 @@ ixgbe_netmap_rxsync(struct ifnet *ifp, u
 			if ((staterr & IXGBE_RXD_STAT_DD) == 0)
 				break;
 			ring->slot[j].len = le16toh(curr->wb.upper.length) - crclen;
+			ring->slot[j].flags = slot_flags;
 			bus_dmamap_sync(rxr->ptag,
 			    rxr->rx_buffers[l].pmap, BUS_DMASYNC_POSTREAD);
 			j = (j == lim) ? 0 : j + 1;

Modified: head/sys/dev/netmap/netmap_kern.h
==============================================================================
--- head/sys/dev/netmap/netmap_kern.h	Thu Jan 17 21:32:53 2013	(r245578)
+++ head/sys/dev/netmap/netmap_kern.h	Thu Jan 17 22:14:58 2013	(r245579)
@@ -119,6 +119,10 @@ struct netmap_adapter;
  * RX rings: the next empty buffer (hwcur + hwavail + hwofs) coincides with
  * 	the next empty buffer as known by the hardware (next_to_check or so).
  * TX rings: hwcur + hwofs coincides with next_to_send
+ *
+ * For received packets, slot->flags is set to nkr_slot_flags
+ * so we can provide a proper initial value (e.g. set NS_FORWARD
+ * when operating in 'transparent' mode).
  */
 struct netmap_kring {
 	struct netmap_ring *ring;
@@ -128,6 +132,7 @@ struct netmap_kring {
 #define NKR_PENDINTR	0x1	// Pending interrupt.
 	u_int nkr_num_slots;
 
+	uint16_t	nkr_slot_flags;	/* initial value for flags */
 	int	nkr_hwofs;	/* offset between NIC and netmap ring */
 	struct netmap_adapter *na;
 	NM_SELINFO_T si;	/* poll/select wait queue */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301172214.r0HMEwN5019545>