L2 BVI/FIB: Update L2 FIB table when BVI's MAC changes
[vpp.git] / src / vnet / devices / af_packet / device.c
index a48ae5c..b8c7501 100644 (file)
@@ -23,8 +23,6 @@
 #include <net/if.h>
 #include <net/if_arp.h>
 
-#include <linux/virtio_net.h>
-
 #include <vlib/vlib.h>
 #include <vlib/unix/unix.h>
 #include <vnet/ip/ip.h>
@@ -52,7 +50,8 @@ static char *af_packet_tx_func_error_strings[] = {
 #undef _
 };
 
-static u8 *
+
+u8 *
 format_af_packet_device_name (u8 * s, va_list * args)
 {
   u32 i = va_arg (*args, u32);
@@ -77,23 +76,6 @@ format_af_packet_tx_trace (u8 * s, va_list * args)
   return s;
 }
 
-
-static_always_inline void
-af_packet_buffer_tx_offload (vlib_buffer_t * b, struct virtio_net_hdr *vhdr)
-{
-  /* For now - just mark the data as valid,
-   * DPDK csums on input, tap presently operates in legacy
-   * compatibility mode where the kernel checksums CSUM_PARTIAL
-   * for it and we have fixed the af_packet input
-   *
-   * In the future, locally originated frames, etc can be made
-   * to fit this convention so that they are not checksummed
-   * unless needed.
-   **/
-  vhdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
-}
-
-
 static uword
 af_packet_interface_tx (vlib_main_t * vm,
                        vlib_node_runtime_t * node, vlib_frame_t * frame)
@@ -105,6 +87,7 @@ af_packet_interface_tx (vlib_main_t * vm,
   vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
   af_packet_if_t *apif =
     pool_elt_at_index (apm->interfaces, rd->dev_instance);
+  clib_spinlock_lock_if_init (&apif->lockp);
   int block = 0;
   u32 block_size = apif->tx_req->tp_block_size;
   u32 frame_size = apif->tx_req->tp_frame_size;
@@ -114,16 +97,10 @@ af_packet_interface_tx (vlib_main_t * vm,
   struct tpacket2_hdr *tph;
   u32 frame_not_ready = 0;
 
-  clib_spinlock_lock_if_init (&apif->lockp);
-
   while (n_left > 0)
     {
       u32 len;
       u32 offset = 0;
-      if (PREDICT_TRUE ((apm->flags & AF_PACKET_USES_VNET_HEADERS) != 0))
-       {
-         offset = sizeof (struct virtio_net_hdr);
-       }
       vlib_buffer_t *b0;
       n_left--;
       u32 bi = buffers[0];
@@ -141,12 +118,6 @@ af_packet_interface_tx (vlib_main_t * vm,
       do
        {
          b0 = vlib_get_buffer (vm, bi);
-         if (PREDICT_TRUE ((apm->flags & AF_PACKET_USES_VNET_HEADERS) != 0))
-           {
-             u8 *vh =
-               (u8 *) tph + TPACKET_ALIGN (sizeof (struct tpacket2_hdr));
-             af_packet_buffer_tx_offload (b0, (struct virtio_net_hdr *) vh);
-           }
          len = b0->current_length;
          clib_memcpy ((u8 *) tph +
                       TPACKET_ALIGN (sizeof (struct tpacket2_hdr)) + offset,
@@ -160,11 +131,11 @@ af_packet_interface_tx (vlib_main_t * vm,
       tph->tp_status = TP_STATUS_SEND_REQUEST;
       n_sent++;
     next:
+      tx_frame = (tx_frame + 1) % frame_num;
+
       /* check if we've exhausted the ring */
       if (PREDICT_FALSE (frame_not_ready + n_sent == frame_num))
        break;
-
-      tx_frame = (tx_frame + 1) % frame_num;
     }
 
   CLIB_MEMORY_BARRIER ();
@@ -242,8 +213,8 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
 
   if (0 > fd)
     {
-      clib_unix_warning ("af_packet_%s could not open socket",
-                        apif->host_if_name);
+      vlib_log_warn (apm->log_class, "af_packet_%s could not open socket",
+                    apif->host_if_name);
       return 0;
     }
 
@@ -255,8 +226,9 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
   ifr.ifr_ifindex = apif->host_if_index;
   if ((rv = ioctl (fd, SIOCGIFNAME, &ifr)) < 0)
     {
-      clib_unix_warning ("af_packet_%s ioctl could not retrieve eth name",
-                        apif->host_if_name);
+      vlib_log_warn (apm->log_class,
+                    "af_packet_%s ioctl could not retrieve eth name",
+                    apif->host_if_name);
       goto error;
     }
 
@@ -264,8 +236,8 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
 
   if ((rv = ioctl (fd, SIOCGIFFLAGS, &ifr)) < 0)
     {
-      clib_unix_warning ("af_packet_%s error: %d",
-                        apif->is_admin_up ? "up" : "down", rv);
+      vlib_log_warn (apm->log_class, "af_packet_%s error: %d",
+                    apif->is_admin_up ? "up" : "down", rv);
       goto error;
     }
 
@@ -282,8 +254,8 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
 
   if ((rv = ioctl (fd, SIOCSIFFLAGS, &ifr)) < 0)
     {
-      clib_unix_warning ("af_packet_%s error: %d",
-                        apif->is_admin_up ? "up" : "down", rv);
+      vlib_log_warn (apm->log_class, "af_packet_%s error: %d",
+                    apif->is_admin_up ? "up" : "down", rv);
       goto error;
     }
 
@@ -306,7 +278,7 @@ af_packet_subif_add_del_function (vnet_main_t * vnm,
 }
 
 static clib_error_t *af_packet_set_mac_address_function
-  (struct vnet_hw_interface_t *hi, char *address)
+  (struct vnet_hw_interface_t *hi, const u8 * old_address, const u8 * address)
 {
   af_packet_main_t *apm = &af_packet_main;
   af_packet_if_t *apif =
@@ -316,8 +288,8 @@ static clib_error_t *af_packet_set_mac_address_function
 
   if (0 > fd)
     {
-      clib_unix_warning ("af_packet_%s could not open socket",
-                        apif->host_if_name);
+      vlib_log_warn (apm->log_class, "af_packet_%s could not open socket",
+                    apif->host_if_name);
       return 0;
     }
 
@@ -329,8 +301,9 @@ static clib_error_t *af_packet_set_mac_address_function
   ifr.ifr_ifindex = apif->host_if_index;
   if ((rv = ioctl (fd, SIOCGIFNAME, &ifr)) < 0)
     {
-      clib_unix_warning
-       ("af_packet_%s ioctl could not retrieve eth name, error: %d",
+      vlib_log_warn
+       (apm->log_class,
+        "af_packet_%s ioctl could not retrieve eth name, error: %d",
         apif->host_if_name, rv);
       goto error;
     }
@@ -340,8 +313,9 @@ static clib_error_t *af_packet_set_mac_address_function
 
   if ((rv = ioctl (fd, SIOCSIFHWADDR, &ifr)) < 0)
     {
-      clib_unix_warning ("af_packet_%s ioctl could not set mac, error: %d",
-                        apif->host_if_name, rv);
+      vlib_log_warn (apm->log_class,
+                    "af_packet_%s ioctl could not set mac, error: %d",
+                    apif->host_if_name, rv);
       goto error;
     }