diff mbox

ODP packet headroom example diff

Message ID 201408191722.s7JHMHED014422@cpp-rtpbld-55.cisco.com
State New
Headers show

Commit Message

Robbie King Aug. 19, 2014, 5:22 p.m. UTC
Here is the diff I mentioned that I'm using to make progress on 
Cisco DP.
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_pktio_socket.h b/platform/linux-generic/include/api/odp_pktio_socket.h
index deeeeed..99f5904 100644
--- a/platform/linux-generic/include/api/odp_pktio_socket.h
+++ b/platform/linux-generic/include/api/odp_pktio_socket.h
@@ -16,6 +16,7 @@  extern "C" {
 typedef struct {
 	odp_pktio_type_t type;
 	int fanout;
+	int headroom;
 } socket_params_t;
 
 #ifdef __cplusplus
diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h
index f991806..cc965a3 100644
--- a/platform/linux-generic/include/odp_packet_socket.h
+++ b/platform/linux-generic/include/odp_packet_socket.h
@@ -80,7 +80,7 @@  int setup_pkt_sock(pkt_sock_t * const pkt_sock, const char *netdev,
 		   odp_buffer_pool_t pool);
 
 int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev,
-			odp_buffer_pool_t pool, int fanout);
+			odp_buffer_pool_t pool, socket_params_t *sock_params);
 
 /**
  * Close a packet socket
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 33ade10..3682c78 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -220,7 +220,7 @@  odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool,
 		break;
 	case ODP_PKTIO_TYPE_SOCKET_MMAP:
 		res = setup_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, dev,
-				pool, params->sock_params.fanout);
+				pool, &params->sock_params);
 		if (res == -1) {
 			close_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap);
 			free_pktio_entry(id);
diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c
index d44c333..49652a0 100644
--- a/platform/linux-generic/odp_packet_socket.c
+++ b/platform/linux-generic/odp_packet_socket.c
@@ -34,8 +34,8 @@ 
 #include <errno.h>
 #include <sys/syscall.h>
 
-#include <odp_packet_socket.h>
 #include <odp_packet_internal.h>
+#include <odp_packet_socket.h>
 #include <odp_hints.h>
 
 #include <helper/odp_eth.h>
@@ -760,7 +760,7 @@  static int mmap_store_hw_addr(pkt_sock_mmap_t * const pkt_sock,
  * ODP_PACKET_SOCKET_MMAP:
  */
 int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev,
-		   odp_buffer_pool_t pool, int fanout)
+		   odp_buffer_pool_t pool,  socket_params_t *sock_params)
 {
 	odp_packet_t pkt;
 	uint8_t *pkt_buf;
@@ -781,6 +781,7 @@  int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev,
 	l2_hdr = ETHBUF_ALIGN(pkt_buf);
 	/* Store eth buffer offset for pkt buffers from this pool */
 	pkt_sock->frame_offset = (uintptr_t)l2_hdr - (uintptr_t)pkt_buf;
+	pkt_sock->frame_offset +=  sock_params->headroom;
 
 	odp_packet_free(pkt);
 
@@ -815,7 +816,7 @@  int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev,
 		return -1;
 	}
 
-	if (fanout) {
+	if (sock_params->fanout) {
 		ret = set_pkt_sock_fanout_mmap(pkt_sock, if_idx);
 		if (ret != 0)
 			return -1;