aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/dmm_image/README.md13
-rw-r--r--docker/dmm_image/centos/Dockerfile17
-rw-r--r--stacks/lwip_stack/src/io_adpt/dpdk.c100
3 files changed, 125 insertions, 5 deletions
diff --git a/docker/dmm_image/README.md b/docker/dmm_image/README.md
new file mode 100644
index 0000000..0b674b2
--- /dev/null
+++ b/docker/dmm_image/README.md
@@ -0,0 +1,13 @@
+# How to build the image of dmm
+Note: Make sure your computer can connect to the network
+```sh
+ #cd dmm/docker/dmm_image/centos
+ #docker build -t "dmm:tag" .
+```
+
+# How to use the image of dmm
+```sh
+ #docker run -i -t --network=host -v /sys/bus/pci/devices:/sys/bus/pci/devices -v /sys/devices/system/node:/sys/devices/system/node -v /mnt/nstackhuge:/mnt/nstackhuge -v /dev:/dev --privileged dmm:tag /bin/bash
+```
+
+Then we will enter a container and we can build dmm and run the app.
diff --git a/docker/dmm_image/centos/Dockerfile b/docker/dmm_image/centos/Dockerfile
new file mode 100644
index 0000000..de772fe
--- /dev/null
+++ b/docker/dmm_image/centos/Dockerfile
@@ -0,0 +1,17 @@
+FROM docker.io/centos:latest
+
+RUN yum install -y git vim sudo ethtool
+
+RUN yum install -y kernel-devel-`uname -r`
+RUN yum install -y kernel-`uname -r`
+
+RUN git config --global http.sslVerify false
+RUN git config --global user.email "you@example.com"
+RUN git config --global user.name "Your Name"
+
+RUN git clone https://gerrit.fd.io/r/dmm
+
+RUN mkdir -p /var/run/ip_module/
+RUN mkdir -p /var/log/nStack/ip_module/
+
+RUN cd /dmm/scripts/ && bash -x build.sh && cd /dmm/ && git clean -dfx ./ && git checkout ./
diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c
index da2cfb6..d199513 100644
--- a/stacks/lwip_stack/src/io_adpt/dpdk.c
+++ b/stacks/lwip_stack/src/io_adpt/dpdk.c
@@ -191,6 +191,82 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
};
/*****************************************************************************
+* Prototype : dpdk_mbuf_to_file
+* Description : write the packet data into a file
+* Input : uint16_t pkt_number
+* struct rte_mbuf **pkts
+* Output : None
+* Return Value :
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+NSTACK_STATIC void
+dpdk_mbuf_to_file (uint16_t pkt_number, struct rte_mbuf **pkts)
+{
+ char line[100] = { 0 };
+ FILE *f = NULL;
+ struct rte_mbuf *p = NULL;
+ uint16_t len = 0, offset, i;
+ uint16_t pktlen = 0;
+ uint16_t start = 0;
+ uint16_t number = 0;
+ unsigned char *data = NULL;
+
+ f = fopen ("/var/log/nStack/packet.txt", "a+");
+ if (f == NULL)
+ {
+ NSHAL_LOGERR ("can not open the file:%s", "packet.txt");
+ return;
+ }
+
+ for (i = 0; i < pkt_number; i++)
+ {
+ pktlen = 0;
+ p = pkts[i];
+ while (p)
+ {
+ len = 0;
+ data = rte_pktmbuf_mtod (p, unsigned char *);
+ while (len < p->data_len)
+ {
+ start = pktlen % 16; /* start of the line */
+ if (start == 0)
+ {
+ number = SNPRINTF_S (line, sizeof (line), sizeof (line) - 1,
+ "%08X", len);
+ }
+
+ for (offset = 0;
+ ((offset + start) < 16) && ((len + offset) < p->data_len);
+ offset++)
+ {
+ number +=
+ SNPRINTF_S (line + number, sizeof (line),
+ sizeof (line) - 1, " %02X",
+ data[len + offset]);
+ }
+
+ fprintf (f, "%s", line);
+ if ((offset + start) == 16)
+ fprintf (f, "\n");
+
+ len += offset;
+ pktlen += offset;
+ (void) MEMSET_S (line, sizeof (line), 0, sizeof (line));
+ }
+
+ p = p->next;
+
+ }
+ fprintf (f, "\n");
+ }
+
+ fclose (f);
+ return;
+}
+
+/*****************************************************************************
* Prototype : hal_rte_eth_rx_burst
* Description : a copy of rte_eth_rx_burst, because this function invokes
a global(rte_eth_devices), which cannt be access by dlsym
@@ -207,13 +283,13 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
*****************************************************************************/
NSTACK_STATIC inline uint16_t
hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id,
- struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
+ struct rte_mbuf ** rx_pkts, const uint16_t nb_pkts)
{
#ifdef RTE_ETHDEV_RXTX_CALLBACKS
struct rte_eth_rxtx_callback *cb;
#endif
int16_t nb_rx;
-
+ char *pst_capture_packet = NULL;
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
if (NULL == dev->rx_pkt_burst)
@@ -250,6 +326,11 @@ hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id,
}
#endif
+ //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
+ if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
+ {
+ dpdk_mbuf_to_file (nb_rx, rx_pkts);
+ }
return (uint16_t) nb_rx;
}
@@ -274,7 +355,8 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id,
#ifdef RTE_ETHDEV_RXTX_CALLBACKS
struct rte_eth_rxtx_callback *cb;
#endif
-
+ int16_t nb_tx = 0;
+ char *pst_capture_packet = NULL;
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
if (NULL == dev->tx_pkt_burst)
@@ -309,8 +391,16 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id,
}
#endif
- return (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts,
- nb_pkts);
+ nb_tx = (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts,
+ nb_pkts);
+
+ //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
+ if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
+ {
+ dpdk_mbuf_to_file (nb_tx, tx_pkts);
+ }
+
+ return nb_tx;
}
/*****************************************************************************