svn commit: r303603 - in head/sys/dev/hyperv: include netvsc storvsc vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Mon Aug 1 04:26:26 UTC 2016
Author: sephe
Date: Mon Aug 1 04:26:24 2016
New Revision: 303603
URL: https://svnweb.freebsd.org/changeset/base/303603
Log:
hyperv/vmbus: Remove the artificial entry limit of SG and PRP list.
Just make sure that the total channel packet size does not exceed 1/2
data size of the TX bufring.
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7359
Modified:
head/sys/dev/hyperv/include/vmbus.h
head/sys/dev/hyperv/netvsc/hv_net_vsc.h
head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
head/sys/dev/hyperv/vmbus/vmbus_brvar.h
head/sys/dev/hyperv/vmbus/vmbus_chan.c
Modified: head/sys/dev/hyperv/include/vmbus.h
==============================================================================
--- head/sys/dev/hyperv/include/vmbus.h Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/include/vmbus.h Mon Aug 1 04:26:24 2016 (r303603)
@@ -102,9 +102,6 @@ struct vmbus_chanpkt_rxbuf {
struct vmbus_rxbuf_desc cp_rxbuf[];
} __packed;
-#define VMBUS_CHAN_SGLIST_MAX 32
-#define VMBUS_CHAN_PRPLIST_MAX 32
-
struct vmbus_channel;
struct hyperv_guid;
Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Aug 1 04:26:24 2016 (r303603)
@@ -1088,6 +1088,7 @@ struct vmbus_channel;
typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *);
#define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE)
+#define NETVSC_PACKET_MAXPAGE 32
#define NETVSC_VLAN_PRIO_MASK 0xe000
#define NETVSC_VLAN_PRIO_SHIFT 13
@@ -1137,7 +1138,7 @@ typedef struct netvsc_packet_ {
uint32_t tot_data_buf_len;
void *data;
uint32_t gpa_cnt;
- struct vmbus_gpa gpa[VMBUS_CHAN_SGLIST_MAX];
+ struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE];
} netvsc_packet;
typedef struct {
Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Aug 1 04:26:24 2016 (r303603)
@@ -152,7 +152,7 @@ __FBSDID("$FreeBSD$");
#define HN_TX_DATA_MAXSIZE IP_MAXPACKET
#define HN_TX_DATA_SEGSIZE PAGE_SIZE
#define HN_TX_DATA_SEGCNT_MAX \
- (VMBUS_CHAN_SGLIST_MAX - HV_RF_NUM_TX_RESERVED_PAGE_BUFS)
+ (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS)
#define HN_DIRECT_TX_SIZE_DEF 128
Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 1 04:26:24 2016 (r303603)
@@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$");
#define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta)
-#define STORVSC_DATA_SEGCNT_MAX VMBUS_CHAN_PRPLIST_MAX
+#define STORVSC_DATA_SEGCNT_MAX 32
#define STORVSC_DATA_SEGSZ_MAX PAGE_SIZE
#define STORVSC_DATA_SIZE_MAX \
(STORVSC_DATA_SEGCNT_MAX * STORVSC_DATA_SEGSZ_MAX)
Modified: head/sys/dev/hyperv/vmbus/vmbus_brvar.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/vmbus/vmbus_brvar.h Mon Aug 1 04:26:24 2016 (r303603)
@@ -71,6 +71,13 @@ struct vmbus_txbr {
struct sysctl_ctx_list;
struct sysctl_oid;
+static __inline int
+vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr)
+{
+ /* 1/2 data size */
+ return (tbr->txbr_dsize / 2);
+}
+
void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx,
struct sysctl_oid *br_tree, struct vmbus_br *br,
const char *name);
Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Aug 1 00:36:29 2016 (r303602)
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Mon Aug 1 04:26:24 2016 (r303603)
@@ -610,6 +610,8 @@ vmbus_chan_send(struct vmbus_channel *ch
hlen = sizeof(pkt);
pktlen = hlen + dlen;
pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
+ KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr),
+ ("invalid packet size %d", pad_pktlen));
pkt.cp_hdr.cph_type = type;
pkt.cp_hdr.cph_flags = flags;
@@ -640,12 +642,11 @@ vmbus_chan_send_sglist(struct vmbus_chan
boolean_t send_evt;
uint64_t pad = 0;
- KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX,
- ("invalid sglist len %d", sglen));
-
hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]);
pktlen = hlen + dlen;
pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
+ KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr),
+ ("invalid packet size %d", pad_pktlen));
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
@@ -681,13 +682,12 @@ vmbus_chan_send_prplist(struct vmbus_cha
boolean_t send_evt;
uint64_t pad = 0;
- KASSERT(prp_cnt < VMBUS_CHAN_PRPLIST_MAX,
- ("invalid prplist entry count %d", prp_cnt));
-
hlen = __offsetof(struct vmbus_chanpkt_prplist,
cp_range[0].gpa_page[prp_cnt]);
pktlen = hlen + dlen;
pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen);
+ KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr),
+ ("invalid packet size %d", pad_pktlen));
pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA;
pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC;
More information about the svn-src-head
mailing list