aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2021-09-14 18:43:41 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2021-09-14 18:43:41 +0000
commitc782ea8bb50bf49f5da20da66417952b0e77472e (patch)
tree0809f93cc5baa7734feb60a00dd9b8e1876a760c /sys/netinet
parentcf4670fe0b1049863ed3150a6ffb0b80dad151b2 (diff)
downloadsrc-c782ea8bb50bf49f5da20da66417952b0e77472e.tar.gz
src-c782ea8bb50bf49f5da20da66417952b0e77472e.zip
Add a switch structure for send tags.
Move the type and function pointers for operations on existing send tags (modify, query, next, free) out of 'struct ifnet' and into a new 'struct if_snd_tag_sw'. A pointer to this structure is added to the generic part of send tags and is initialized by m_snd_tag_init() (which now accepts a switch structure as a new argument in place of the type). Previously, device driver ifnet methods switched on the type to call type-specific functions. Now, those type-specific functions are saved in the switch structure and invoked directly. In addition, this more gracefully permits multiple implementations of the same tag within a driver. In particular, NIC TLS for future Chelsio adapters will use a different implementation than the existing NIC TLS support for T6 adapters. Reviewed by: gallatin, hselasky, kib (older version) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D31572
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_pcb.c31
-rw-r--r--sys/netinet/tcp_ratelimit.c8
2 files changed, 12 insertions, 27 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 4c21bdbf1347..04d34b022772 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -3293,21 +3293,16 @@ in_pcbmodify_txrtlmt(struct inpcb *inp, uint32_t max_pacing_rate)
.rate_limit.flags = M_NOWAIT,
};
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_modify == NULL) {
+ if (mst->sw->snd_tag_modify == NULL) {
error = EOPNOTSUPP;
} else {
- error = ifp->if_snd_tag_modify(mst, &params);
+ error = mst->sw->snd_tag_modify(mst, &params);
}
return (error);
}
@@ -3321,22 +3316,17 @@ in_pcbquery_txrtlmt(struct inpcb *inp, uint32_t *p_max_pacing_rate)
{
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) {
+ if (mst->sw->snd_tag_query == NULL) {
error = EOPNOTSUPP;
} else {
- error = ifp->if_snd_tag_query(mst, &params);
- if (error == 0 && p_max_pacing_rate != NULL)
+ error = mst->sw->snd_tag_query(mst, &params);
+ if (error == 0 && p_max_pacing_rate != NULL)
*p_max_pacing_rate = params.rate_limit.max_rate;
}
return (error);
@@ -3351,22 +3341,17 @@ 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)
+ if (mst->sw->snd_tag_query == NULL)
return (EOPNOTSUPP);
- error = ifp->if_snd_tag_query(mst, &params);
- if (error == 0 && p_txqueue_level != NULL)
+ error = mst->sw->snd_tag_query(mst, &params);
+ if (error == 0 && p_txqueue_level != NULL)
*p_txqueue_level = params.rate_limit.queue_level;
return (error);
}
diff --git a/sys/netinet/tcp_ratelimit.c b/sys/netinet/tcp_ratelimit.c
index c33b2872e91f..528dc062fd97 100644
--- a/sys/netinet/tcp_ratelimit.c
+++ b/sys/netinet/tcp_ratelimit.c
@@ -1065,8 +1065,8 @@ rt_find_real_interface(struct ifnet *ifp, struct inpcb *inp, int *error)
return (NULL);
}
ntag = tag;
- while(ntag->ifp->if_next_snd_tag != NULL) {
- ntag = ntag->ifp->if_next_snd_tag(ntag);
+ while (ntag->sw->next_snd_tag != NULL) {
+ ntag = ntag->sw->next_snd_tag(ntag);
}
tifp = ntag->ifp;
m_snd_tag_rele(tag);
@@ -1360,7 +1360,7 @@ tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp,
* send tag. This will convert the existing
* tag to a TLS ratelimit tag.
*/
- MPASS(tls->snd_tag->type == IF_SND_TAG_TYPE_TLS);
+ MPASS(tls->snd_tag->sw->type == IF_SND_TAG_TYPE_TLS);
ktls_output_eagain(tp->t_inpcb, tls);
}
#endif
@@ -1405,7 +1405,7 @@ tcp_chg_pacing_rate(const struct tcp_hwrate_limit_table *crte,
tls = tp->t_inpcb->inp_socket->so_snd.sb_tls_info;
MPASS(tls->mode == TCP_TLS_MODE_IFNET);
if (tls->snd_tag != NULL &&
- tls->snd_tag->type != IF_SND_TAG_TYPE_TLS_RATE_LIMIT) {
+ tls->snd_tag->sw->type != IF_SND_TAG_TYPE_TLS_RATE_LIMIT) {
/*
* NIC probably doesn't support ratelimit TLS
* tags if it didn't allocate one when an