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
This commit is contained in:
Sepherosa Ziehau 2016-08-01 04:26:24 +00:00
parent 52fe68b878
commit 9d6016a773
6 changed files with 17 additions and 12 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -610,6 +610,8 @@ vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, uint16_t flags,
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_channel *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_channel *chan,
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;