i40e: add ethertype filter
[dpdk.git] / lib / librte_vhost / vhost-net-cdev.h
index 575daa9..03a5c57 100644 (file)
 
 #ifndef _VHOST_NET_CDEV_H_
 #define _VHOST_NET_CDEV_H_
-
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <linux/vhost.h>
 
-struct vhost_memory;
-struct vhost_vring_state;
-struct vhost_vring_addr;
-struct vhost_vring_file;
+#include <rte_log.h>
+
+/* Macros for printing using RTE_LOG */
+#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
+#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
+
+#ifdef RTE_LIBRTE_VHOST_DEBUG
+#define VHOST_MAX_PRINT_BUFF 6072
+#define LOG_LEVEL RTE_LOG_DEBUG
+#define LOG_DEBUG(log_type, fmt, args...) RTE_LOG(DEBUG, log_type, fmt, ##args)
+#define PRINT_PACKET(device, addr, size, header) do { \
+       char *pkt_addr = (char *)(addr); \
+       unsigned int index; \
+       char packet[VHOST_MAX_PRINT_BUFF]; \
+       \
+       if ((header)) \
+               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Header size %d: ", (device->device_fh), (size)); \
+       else \
+               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Packet size %d: ", (device->device_fh), (size)); \
+       for (index = 0; index < (size); index++) { \
+               snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \
+                       "%02hhx ", pkt_addr[index]); \
+       } \
+       snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), "\n"); \
+       \
+       LOG_DEBUG(VHOST_DATA, "%s", packet); \
+} while (0)
+#else
+#define LOG_LEVEL RTE_LOG_INFO
+#define LOG_DEBUG(log_type, fmt, args...) do {} while (0)
+#define PRINT_PACKET(device, addr, size, header) do {} while (0)
+#endif
+
 
 /*
  * Structure used to identify device context.
  */
-struct vhost_device_ctx
-{
+struct vhost_device_ctx {
        pid_t           pid;    /* PID of process calling the IOCTL. */
-       uint64_t        fh;             /* Populated with fi->fh to track the device index. */
+       uint64_t        fh;     /* Populated with fi->fh to track the device index. */
 };
 
 /*
@@ -55,29 +86,28 @@ struct vhost_device_ctx
  * functions are called in CUSE context and are used to configure devices.
  */
 struct vhost_net_device_ops {
-       int (* new_device)              (struct vhost_device_ctx);
-       void (* destroy_device) (struct vhost_device_ctx);
+       int (*new_device)(struct vhost_device_ctx);
+       void (*destroy_device)(struct vhost_device_ctx);
 
-       int (* get_features)    (struct vhost_device_ctx, uint64_t *);
-       int (* set_features)    (struct vhost_device_ctx, uint64_t *);
+       int (*get_features)(struct vhost_device_ctx, uint64_t *);
+       int (*set_features)(struct vhost_device_ctx, uint64_t *);
 
-       int (* set_mem_table)   (struct vhost_device_ctx, const void *, uint32_t);
+       int (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);
 
-       int (* set_vring_num)   (struct vhost_device_ctx, struct vhost_vring_state *);
-       int (* set_vring_addr)  (struct vhost_device_ctx, struct vhost_vring_addr *);
-       int (* set_vring_base)  (struct vhost_device_ctx, struct vhost_vring_state *);
-       int (* get_vring_base)  (struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);
+       int (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state *);
+       int (*set_vring_addr)(struct vhost_device_ctx, struct vhost_vring_addr *);
+       int (*set_vring_base)(struct vhost_device_ctx, struct vhost_vring_state *);
+       int (*get_vring_base)(struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);
 
-       int (* set_vring_kick)  (struct vhost_device_ctx, struct vhost_vring_file *);
-       int (* set_vring_call)  (struct vhost_device_ctx, struct vhost_vring_file *);
+       int (*set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file *);
+       int (*set_vring_call)(struct vhost_device_ctx, struct vhost_vring_file *);
 
-       int (* set_backend)     (struct vhost_device_ctx, struct vhost_vring_file *);
+       int (*set_backend)(struct vhost_device_ctx, struct vhost_vring_file *);
 
-       int (* set_owner)               (struct vhost_device_ctx);
-       int (* reset_owner)     (struct vhost_device_ctx);
+       int (*set_owner)(struct vhost_device_ctx);
+       int (*reset_owner)(struct vhost_device_ctx);
 };
 
-int register_cuse_device(const char *base_name, int index, struct vhost_net_device_ops const * const);
-int start_cuse_session_loop(void);
 
+struct vhost_net_device_ops const *get_virtio_net_callbacks(void);
 #endif /* _VHOST_NET_CDEV_H_ */