Index: head/sys/net/if_var.h =================================================================== --- head/sys/net/if_var.h +++ head/sys/net/if_var.h @@ -183,7 +183,8 @@ struct m_snd_tag; #define IF_SND_TAG_TYPE_RATE_LIMIT 0 -#define IF_SND_TAG_TYPE_MAX 1 +#define IF_SND_TAG_TYPE_UNLIMITED 1 +#define IF_SND_TAG_TYPE_MAX 2 struct if_snd_tag_alloc_header { uint32_t type; /* send tag type, see IF_SND_TAG_XXX */ @@ -198,19 +199,26 @@ struct if_snd_tag_rate_limit_params { uint64_t max_rate; /* in bytes/s */ + uint32_t queue_level; /* 0 (empty) .. 65535 (full) */ +#define IF_SND_QUEUE_LEVEL_MIN 0 +#define IF_SND_QUEUE_LEVEL_MAX 65535 + uint32_t reserved; /* padding */ }; union if_snd_tag_alloc_params { struct if_snd_tag_alloc_header hdr; struct if_snd_tag_alloc_rate_limit rate_limit; + struct if_snd_tag_alloc_rate_limit unlimited; }; union if_snd_tag_modify_params { struct if_snd_tag_rate_limit_params rate_limit; + struct if_snd_tag_rate_limit_params unlimited; }; union if_snd_tag_query_params { struct if_snd_tag_rate_limit_params rate_limit; + struct if_snd_tag_rate_limit_params unlimited; }; typedef int (if_snd_tag_alloc_t)(struct ifnet *, union if_snd_tag_alloc_params *, Index: head/sys/netinet/in_pcb.h =================================================================== --- head/sys/netinet/in_pcb.h +++ head/sys/netinet/in_pcb.h @@ -761,6 +761,7 @@ void in_pcbdetach_txrtlmt(struct inpcb *); int in_pcbmodify_txrtlmt(struct inpcb *, uint32_t); int in_pcbquery_txrtlmt(struct inpcb *, uint32_t *); +int in_pcbquery_txrlevel(struct inpcb *, uint32_t *); void in_pcboutput_txrtlmt(struct inpcb *, struct ifnet *, struct mbuf *); void in_pcboutput_eagain(struct inpcb *); #endif Index: head/sys/netinet/in_pcb.c =================================================================== --- head/sys/netinet/in_pcb.c +++ head/sys/netinet/in_pcb.c @@ -2797,6 +2797,35 @@ } /* + * Query existing TX queue level based on the existing + * "inp->inp_snd_tag", if any. + */ +int +in_pcbquery_txrlevel(struct inpcb *inp, uint32_t *p_txqueue_level) +{ + union if_snd_tag_query_params params = { }; + struct m_snd_tag *mst; + struct ifnet *ifp; + int error; + + mst = inp->inp_snd_tag; + if (mst == NULL) + return (EINVAL); + + ifp = mst->ifp; + if (ifp == NULL) + return (EINVAL); + + if (ifp->if_snd_tag_query == NULL) + return (EOPNOTSUPP); + + error = ifp->if_snd_tag_query(mst, ¶ms); + if (error == 0 && p_txqueue_level != NULL) + *p_txqueue_level = params.rate_limit.queue_level; + return (error); +} + +/* * Allocate a new TX rate limit send tag from the network interface * given by the "ifp" argument and save it in "inp->inp_snd_tag": */ @@ -2805,7 +2834,8 @@ uint32_t flowtype, uint32_t flowid, uint32_t max_pacing_rate) { union if_snd_tag_alloc_params params = { - .rate_limit.hdr.type = IF_SND_TAG_TYPE_RATE_LIMIT, + .rate_limit.hdr.type = (max_pacing_rate == -1U) ? + IF_SND_TAG_TYPE_UNLIMITED : IF_SND_TAG_TYPE_RATE_LIMIT, .rate_limit.hdr.flowid = flowid, .rate_limit.hdr.flowtype = flowtype, .rate_limit.max_rate = max_pacing_rate,