Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/netvsc/hv_net_vsc.h
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <dev/hyperv/include/hyperv.h> | #include <dev/hyperv/include/hyperv.h> | ||||
#define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF) | #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF) | ||||
#define NVSP_PROTOCOL_VERSION_1 2 | #define NVSP_PROTOCOL_VERSION_1 2 | ||||
#define NVSP_PROTOCOL_VERSION_2 0x30002 | #define NVSP_PROTOCOL_VERSION_2 0x30002 | ||||
#define NVSP_PROTOCOL_VERSION_4 0x40000 | |||||
#define NVSP_PROTOCOL_VERSION_5 0x50000 | |||||
#define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1) | #define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1) | ||||
#define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2) | #define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2) | ||||
#define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2 | #define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2 | ||||
#define VERSION_4_OFFLOAD_SIZE 22 | |||||
#define NVSP_OPERATIONAL_STATUS_OK (0x00000000) | #define NVSP_OPERATIONAL_STATUS_OK (0x00000000) | ||||
#define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001) | #define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001) | ||||
#define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002) | #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002) | ||||
#define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003) | #define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003) | ||||
#define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004) | #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004) | ||||
/* | /* | ||||
* Maximun number of transfer pages (packets) the VSP will use on a receive | * Maximun number of transfer pages (packets) the VSP will use on a receive | ||||
▲ Show 20 Lines • Show All 473 Lines • ▼ Show 20 Lines | typedef struct nvsp_2_msg_indicate_chimney_event_ { | ||||
* contains the VSC's TCP context. | * contains the VSC's TCP context. | ||||
* If 0, the event indication is global. | * If 0, the event indication is global. | ||||
*/ | */ | ||||
uint64_t vsc_tcp_context; | uint64_t vsc_tcp_context; | ||||
} __packed nvsp_2_msg_indicate_chimney_event; | } __packed nvsp_2_msg_indicate_chimney_event; | ||||
#define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu | #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu | ||||
#define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffu | #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffffff | ||||
/* | /* | ||||
* NvspMessage2TypeSendChimneyPacket | * NvspMessage2TypeSendChimneyPacket | ||||
*/ | */ | ||||
typedef struct nvsp_2_msg_send_chimney_pkt_ { | typedef struct nvsp_2_msg_send_chimney_pkt_ { | ||||
/* | /* | ||||
* Identify the TCP connection for which this chimney send is | * Identify the TCP connection for which this chimney send is | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* The following arguably belongs in a separate header file | * The following arguably belongs in a separate header file | ||||
*/ | */ | ||||
/* | /* | ||||
* Defines | * Defines | ||||
*/ | */ | ||||
#define NETVSC_SEND_BUFFER_SIZE (64*1024) /* 64K */ | #define NETVSC_SEND_BUFFER_SIZE (1024*1024*15) /* 15M */ | ||||
#define NETVSC_SEND_BUFFER_ID 0xface | #define NETVSC_SEND_BUFFER_ID 0xface | ||||
#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024) /* 1MB */ | #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */ | ||||
#define NETVSC_RECEIVE_BUFFER_ID 0xcafe | #define NETVSC_RECEIVE_BUFFER_ID 0xcafe | ||||
#define NETVSC_RECEIVE_SG_COUNT 1 | #define NETVSC_RECEIVE_SG_COUNT 1 | ||||
/* Preallocated receive packets */ | /* Preallocated receive packets */ | ||||
#define NETVSC_RECEIVE_PACKETLIST_COUNT 256 | #define NETVSC_RECEIVE_PACKETLIST_COUNT 256 | ||||
/* | /* | ||||
* Maximum MTU we permit to be configured for a netvsc interface. | * Maximum MTU we permit to be configured for a netvsc interface. | ||||
* When the code was developed, a max MTU of 12232 was tested and | * When the code was developed, a max MTU of 12232 was tested and | ||||
* proven to work. 9K is a reasonable maximum for an Ethernet. | * proven to work. 9K is a reasonable maximum for an Ethernet. | ||||
*/ | */ | ||||
#define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024) | #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024) | ||||
#define NETVSC_PACKET_SIZE 4096 | |||||
royger: Is this 4096 because it's limited by PAGE_SIZE, or it is not related? | |||||
Not Done Inline ActionsThis was inherited from its Windows counterpart. I believe it is somewhat related to PAGE_SIZE. whu: This was inherited from its Windows counterpart. I believe it is somewhat related to PAGE_SIZE. | |||||
Not Done Inline ActionsIMHO, if this is related to page size I would rather use PAGE_SIZE directly. royger: IMHO, if this is related to page size I would rather use PAGE_SIZE directly. | |||||
/* | /* | ||||
* Data types | * Data types | ||||
*/ | */ | ||||
/* | /* | ||||
* Per netvsc channel-specific | * Per netvsc channel-specific | ||||
*/ | */ | ||||
typedef struct netvsc_dev_ { | typedef struct netvsc_dev_ { | ||||
struct hv_device *dev; | struct hv_device *dev; | ||||
int num_outstanding_sends; | int num_outstanding_sends; | ||||
/* List of free preallocated NETVSC_PACKET to represent RX packet */ | |||||
STAILQ_HEAD(PQ, netvsc_packet_) myrx_packet_list; | |||||
struct mtx rx_pkt_list_lock; | |||||
/* Send buffer allocated by us but manages by NetVSP */ | /* Send buffer allocated by us but manages by NetVSP */ | ||||
void *send_buf; | void *send_buf; | ||||
uint32_t send_buf_size; | uint32_t send_buf_size; | ||||
uint32_t send_buf_gpadl_handle; | uint32_t send_buf_gpadl_handle; | ||||
uint32_t send_section_size; | uint32_t send_section_size; | ||||
uint32_t send_section_count; | |||||
unsigned long bitsmap_words; | |||||
unsigned long *send_section_bitsmap; | |||||
/* Receive buffer allocated by us but managed by NetVSP */ | /* Receive buffer allocated by us but managed by NetVSP */ | ||||
void *rx_buf; | void *rx_buf; | ||||
uint32_t rx_buf_size; | uint32_t rx_buf_size; | ||||
uint32_t rx_buf_gpadl_handle; | uint32_t rx_buf_gpadl_handle; | ||||
uint32_t rx_section_count; | uint32_t rx_section_count; | ||||
nvsp_1_rx_buf_section *rx_sections; | nvsp_1_rx_buf_section *rx_sections; | ||||
/* Used for NetVSP initialization protocol */ | /* Used for NetVSP initialization protocol */ | ||||
struct sema channel_init_sema; | struct sema channel_init_sema; | ||||
nvsp_msg channel_init_packet; | nvsp_msg channel_init_packet; | ||||
nvsp_msg revoke_packet; | nvsp_msg revoke_packet; | ||||
/*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/ | /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/ | ||||
/* Holds rndis device info */ | /* Holds rndis device info */ | ||||
void *extension; | void *extension; | ||||
hv_bool_uint8_t destroy; | hv_bool_uint8_t destroy; | ||||
/* Negotiated NVSP version */ | /* Negotiated NVSP version */ | ||||
uint32_t nvsp_version; | uint32_t nvsp_version; | ||||
unsigned char callback_buf[NETVSC_PACKET_SIZE]; | |||||
Done Inline Actionsuint8_t? royger: uint8_t? | |||||
} netvsc_dev; | } netvsc_dev; | ||||
typedef void (*pfn_on_send_rx_completion)(void *); | typedef void (*pfn_on_send_rx_completion)(void *); | ||||
#define NETVSC_DEVICE_RING_BUFFER_SIZE (64 * PAGE_SIZE) | #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) | ||||
#define NETVSC_PACKET_MAXPAGE 16 | #define NETVSC_PACKET_MAXPAGE 32 | ||||
typedef struct xfer_page_packet_ { | #define NETVSC_VLAN_PRIO_MASK 0xe000 | ||||
/* | #define NETVSC_VLAN_PRIO_SHIFT 13 | ||||
* This needs to be here because the network RX code casts | #define NETVSC_VLAN_VID_MASK 0x0fff | ||||
* an instantiation of this structure to a netvsc_packet. | |||||
*/ | |||||
STAILQ_ENTRY(netvsc_packet_) mylist_entry; | |||||
uint32_t count; | #define TYPE_IPV4 2 | ||||
} xfer_page_packet; | #define TYPE_IPV6 4 | ||||
#define TYPE_TCP 2 | |||||
#define TYPE_UDP 4 | |||||
#define TRANSPORT_TYPE_NOT_IP 0 | |||||
#define TRANSPORT_TYPE_IPV4_TCP ((TYPE_IPV4 << 16) | TYPE_TCP) | |||||
#define TRANSPORT_TYPE_IPV4_UDP ((TYPE_IPV4 << 16) | TYPE_UDP) | |||||
#define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP) | |||||
#define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) | |||||
#ifdef __i386__ | |||||
#define BITS_PER_LONG 32 | |||||
#else | |||||
#define BITS_PER_LONG 64 | |||||
#endif | |||||
Done Inline ActionsIMHO I think you should be able to use LONG_BIT from sys/limits.h instead of rolling your own. Or in any case this should be: #ifdef __LP64__ #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif Although I would recommend to simply set: #define BITS_PER_LONG LONG_BIT royger: IMHO I think you should be able to use LONG_BIT from sys/limits.h instead of rolling your own. | |||||
typedef struct netvsc_packet_ { | typedef struct netvsc_packet_ { | ||||
/* | |||||
* List used when enqueued on &net_dev->rx_packet_list, | |||||
* and when enqueued within the netvsc code | |||||
*/ | |||||
STAILQ_ENTRY(netvsc_packet_) mylist_entry; | |||||
struct hv_device *device; | struct hv_device *device; | ||||
hv_bool_uint8_t is_data_pkt; /* One byte */ | hv_bool_uint8_t is_data_pkt; /* One byte */ | ||||
uint16_t vlan_tci; | uint16_t vlan_tci; | ||||
xfer_page_packet *xfer_page_pkt; | uint32_t status; | ||||
/* Completion */ | /* Completion */ | ||||
union { | union { | ||||
struct { | struct { | ||||
uint64_t rx_completion_tid; | uint64_t rx_completion_tid; | ||||
void *rx_completion_context; | void *rx_completion_context; | ||||
/* This is no longer used */ | /* This is no longer used */ | ||||
pfn_on_send_rx_completion on_rx_completion; | pfn_on_send_rx_completion on_rx_completion; | ||||
} rx; | } rx; | ||||
struct { | struct { | ||||
uint64_t send_completion_tid; | uint64_t send_completion_tid; | ||||
void *send_completion_context; | void *send_completion_context; | ||||
/* Still used in netvsc and filter code */ | /* Still used in netvsc and filter code */ | ||||
pfn_on_send_rx_completion on_send_completion; | pfn_on_send_rx_completion on_send_completion; | ||||
} send; | } send; | ||||
} compl; | } compl; | ||||
uint32_t send_buf_section_idx; | |||||
uint32_t send_buf_section_size; | |||||
void *extension; | void *rndis_mesg; | ||||
uint32_t tot_data_buf_len; | uint32_t tot_data_buf_len; | ||||
void *data; | |||||
uint32_t page_buf_count; | uint32_t page_buf_count; | ||||
hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE]; | hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE]; | ||||
} netvsc_packet; | } netvsc_packet; | ||||
typedef struct { | typedef struct { | ||||
uint8_t mac_addr[6]; /* Assumption unsigned long */ | uint8_t mac_addr[6]; /* Assumption unsigned long */ | ||||
hv_bool_uint8_t link_state; | hv_bool_uint8_t link_state; | ||||
} netvsc_device_info; | } netvsc_device_info; | ||||
Show All 17 Lines | |||||
/* | /* | ||||
* Externs | * Externs | ||||
*/ | */ | ||||
extern int hv_promisc_mode; | extern int hv_promisc_mode; | ||||
extern void netvsc_linkstatus_callback(struct hv_device *device_obj, | extern void netvsc_linkstatus_callback(struct hv_device *device_obj, | ||||
uint32_t status); | uint32_t status); | ||||
Done Inline ActionsPlease indent using 4 spaces (here and below). royger: Please indent using 4 spaces (here and below). | |||||
extern int netvsc_recv(struct hv_device *device_obj, netvsc_packet *packet); | |||||
extern void netvsc_xmit_completion(void *context); | extern void netvsc_xmit_completion(void *context); | ||||
extern void | |||||
extern void hv_nv_on_receive_completion(void *context); | hv_nv_on_receive_completion(struct hv_device *device, | ||||
uint64_t tid, | |||||
uint32_t status); | |||||
Done Inline ActionsFollowing the style used in this file I don't think there should be a line break here. royger: Following the style used in this file I don't think there should be a line break here. | |||||
extern netvsc_dev *hv_nv_on_device_add(struct hv_device *device, void *additional_info); | extern netvsc_dev *hv_nv_on_device_add(struct hv_device *device, void *additional_info); | ||||
Done Inline Actionsthere's no reason to add a line break between tid and status. Also, could you remove the "extern" from function prototypes? IMHO unless I'm wrong it simply makes no sense, function declarations are always extern in C. royger: there's no reason to add a line break between tid and status. Also, could you remove the… | |||||
extern int hv_nv_on_device_remove(struct hv_device *device, | extern int hv_nv_on_device_remove(struct hv_device *device, | ||||
boolean_t destroy_channel); | boolean_t destroy_channel); | ||||
extern int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt); | extern int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt); | ||||
extern int hv_nv_get_next_send_section(netvsc_dev *net_dev); | |||||
#endif /* __HV_NET_VSC_H__ */ | #endif /* __HV_NET_VSC_H__ */ | ||||
Is this 4096 because it's limited by PAGE_SIZE, or it is not related?