mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 19:08:58 +00:00
Allow cxgb to be unified across versions by making newer features conditional
Submitted by: Chelsio Inc MFC after: 3 days
This commit is contained in:
parent
f1dea04adb
commit
e97121da99
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183289
@ -46,7 +46,6 @@ $FreeBSD$
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <netinet/tcp_lro.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
@ -68,6 +67,10 @@ $FreeBSD$
|
||||
#include <dev/cxgb/ulp/toecore/cxgb_toedev.h>
|
||||
#endif
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
#include <netinet/tcp_lro.h>
|
||||
#endif
|
||||
|
||||
#define USE_SX
|
||||
|
||||
struct adapter;
|
||||
@ -163,10 +166,12 @@ enum { TXQ_ETH = 0,
|
||||
#define WR_LEN (WR_FLITS * 8)
|
||||
#define PIO_LEN (WR_LEN - sizeof(struct cpl_tx_pkt_lso))
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
struct lro_state {
|
||||
unsigned short enabled;
|
||||
struct lro_ctrl ctrl;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define RX_BUNDLE_SIZE 8
|
||||
|
||||
@ -295,7 +300,9 @@ enum {
|
||||
struct sge_qset {
|
||||
struct sge_rspq rspq;
|
||||
struct sge_fl fl[SGE_RXQ_PER_SET];
|
||||
#ifdef LRO_SUPPORTED
|
||||
struct lro_state lro;
|
||||
#endif
|
||||
struct sge_txq txq[SGE_TXQ_PER_SET];
|
||||
uint32_t txq_stopped; /* which Tx queues are stopped */
|
||||
uint64_t port_stats[SGE_PSTAT_MAX];
|
||||
|
@ -876,6 +876,12 @@ cxgb_makedev(struct port_info *pi)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef LRO_SUPPORTED
|
||||
#ifdef IFCAP_LRO
|
||||
#undef IFCAP_LRO
|
||||
#endif
|
||||
#define IFCAP_LRO 0x0
|
||||
#endif
|
||||
|
||||
#ifdef TSO_SUPPORTED
|
||||
#define CXGB_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO)
|
||||
@ -1899,6 +1905,7 @@ cxgb_set_mtu(struct port_info *p, int mtu)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
/*
|
||||
* Mark lro enabled or disabled in all qsets for this port
|
||||
*/
|
||||
@ -1916,6 +1923,7 @@ cxgb_set_lro(struct port_info *p, int enabled)
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
cxgb_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
|
||||
@ -2002,12 +2010,14 @@ cxgb_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
|
||||
error = EINVAL;
|
||||
}
|
||||
}
|
||||
#ifdef LRO_SUPPORTED
|
||||
if (mask & IFCAP_LRO) {
|
||||
ifp->if_capenable ^= IFCAP_LRO;
|
||||
|
||||
/* Safe to do this even if cxgb_up not called yet */
|
||||
cxgb_set_lro(p, ifp->if_capenable & IFCAP_LRO);
|
||||
}
|
||||
#endif
|
||||
if (mask & IFCAP_VLAN_HWTAGGING) {
|
||||
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
||||
reinit = ifp->if_drv_flags & IFF_DRV_RUNNING;
|
||||
|
@ -635,7 +635,11 @@ cxgb_pcpu_start_proc(void *arg)
|
||||
t3_free_qset(qs->port->adapter, qs);
|
||||
|
||||
qs->qs_flags &= ~QS_RUNNING;
|
||||
#if __FreeBSD_version >= 800002
|
||||
kproc_exit(0);
|
||||
#else
|
||||
kthread_exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef IFNET_MULTIQUEUE
|
||||
@ -680,8 +684,13 @@ cxgb_pcpu_startup_threads(struct adapter *sc)
|
||||
device_printf(sc->dev, "starting thread for %d\n",
|
||||
qs->qs_cpuid);
|
||||
|
||||
#if __FreeBSD_version >= 800002
|
||||
kproc_create(cxgb_pcpu_start_proc, qs, &p,
|
||||
RFNOWAIT, 0, "cxgbsp");
|
||||
#else
|
||||
kthread_create(cxgb_pcpu_start_proc, qs, &p,
|
||||
RFNOWAIT, 0, "cxgbsp");
|
||||
#endif
|
||||
DELAY(200);
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,11 @@ struct t3_mbuf_hdr {
|
||||
#define M_SANITY(m, n)
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version >= 701000
|
||||
#define LRO_SUPPORTED
|
||||
#define TOE_SUPPORTED
|
||||
#endif
|
||||
|
||||
#define __read_mostly __attribute__((__section__(".data.read_mostly")))
|
||||
|
||||
/*
|
||||
|
@ -1775,7 +1775,9 @@ t3_free_qset(adapter_t *sc, struct sge_qset *q)
|
||||
MTX_DESTROY(&q->rspq.lock);
|
||||
}
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
tcp_lro_free(&q->lro.ctrl);
|
||||
#endif
|
||||
|
||||
bzero(q, sizeof(*q));
|
||||
}
|
||||
@ -2387,10 +2389,8 @@ t3_sge_alloc_qset(adapter_t *sc, u_int id, int nports, int irq_vec_idx,
|
||||
q->fl[1].type = EXT_JUMBOP;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We allocate and setup the lro_ctrl structure irrespective of whether
|
||||
* lro is available and/or enabled.
|
||||
*/
|
||||
#ifdef LRO_SUPPORTED
|
||||
/* Allocate and setup the lro_ctrl structure */
|
||||
q->lro.enabled = !!(pi->ifp->if_capenable & IFCAP_LRO);
|
||||
ret = tcp_lro_init(&q->lro.ctrl);
|
||||
if (ret) {
|
||||
@ -2398,6 +2398,7 @@ t3_sge_alloc_qset(adapter_t *sc, u_int id, int nports, int irq_vec_idx,
|
||||
goto err;
|
||||
}
|
||||
q->lro.ctrl.ifp = pi->ifp;
|
||||
#endif
|
||||
|
||||
mtx_lock_spin(&sc->sge.reg_lock);
|
||||
ret = -t3_sge_init_rspcntxt(sc, q->rspq.cntxt_id, irq_vec_idx,
|
||||
@ -2555,8 +2556,12 @@ init_cluster_mbuf(caddr_t cl, int flags, int type, uma_zone_t zone)
|
||||
m->m_ext.ref_cnt = (uint32_t *)(cl + header_size - sizeof(uint32_t));
|
||||
m->m_ext.ext_size = m_getsizefromtype(type);
|
||||
m->m_ext.ext_free = ext_free_handler;
|
||||
#if __FreeBSD_version >= 800016
|
||||
m->m_ext.ext_arg1 = cl;
|
||||
m->m_ext.ext_arg2 = (void *)(uintptr_t)type;
|
||||
#else
|
||||
m->m_ext.ext_args = (void *)(uintptr_t)type;
|
||||
#endif
|
||||
m->m_ext.ext_type = EXT_EXTREF;
|
||||
*(m->m_ext.ref_cnt) = 1;
|
||||
DPRINTF("data=%p ref_cnt=%p\n", m->m_data, m->m_ext.ref_cnt);
|
||||
@ -2803,8 +2808,10 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget)
|
||||
struct rsp_desc *r = &rspq->desc[rspq->cidx];
|
||||
int budget_left = budget;
|
||||
unsigned int sleeping = 0;
|
||||
#ifdef LRO_SUPPORTED
|
||||
int lro_enabled = qs->lro.enabled;
|
||||
struct lro_ctrl *lro_ctrl = &qs->lro.ctrl;
|
||||
#endif
|
||||
struct mbuf *offload_mbufs[RX_BUNDLE_SIZE];
|
||||
int ngathered = 0;
|
||||
#ifdef DEBUG
|
||||
@ -2922,10 +2929,13 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget)
|
||||
prefetch(mtod(m, uint8_t *) + L1_CACHE_BYTES);
|
||||
|
||||
t3_rx_eth(adap, rspq, m, ethpad);
|
||||
#ifdef LRO_SUPPORTED
|
||||
if (lro_enabled && lro_ctrl->lro_cnt &&
|
||||
(tcp_lro_rx(lro_ctrl, m, 0) == 0)) {
|
||||
/* successfully queue'd for LRO */
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* LRO not enabled, packet unsuitable for LRO,
|
||||
* or unable to queue. Pass it up right now in
|
||||
@ -2945,12 +2955,14 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget)
|
||||
|
||||
deliver_partial_bundle(&adap->tdev, rspq, offload_mbufs, ngathered);
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
/* Flush LRO */
|
||||
while (!SLIST_EMPTY(&lro_ctrl->lro_active)) {
|
||||
struct lro_entry *queued = SLIST_FIRST(&lro_ctrl->lro_active);
|
||||
SLIST_REMOVE_HEAD(&lro_ctrl->lro_active, next);
|
||||
tcp_lro_flush(lro_ctrl, queued);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sleeping)
|
||||
check_ring_db(adap, qs, sleeping);
|
||||
@ -3547,6 +3559,7 @@ t3_add_configured_sysctls(adapter_t *sc)
|
||||
CTLTYPE_STRING | CTLFLAG_RD, &qs->txq[TXQ_CTRL],
|
||||
0, t3_dump_txq_ctrl, "A", "dump of the transmit queue");
|
||||
|
||||
#ifdef LRO_SUPPORTED
|
||||
SYSCTL_ADD_INT(ctx, lropoidlist, OID_AUTO, "lro_queued",
|
||||
CTLFLAG_RD, &qs->lro.ctrl.lro_queued, 0, NULL);
|
||||
SYSCTL_ADD_INT(ctx, lropoidlist, OID_AUTO, "lro_flushed",
|
||||
@ -3555,6 +3568,7 @@ t3_add_configured_sysctls(adapter_t *sc)
|
||||
CTLFLAG_RD, &qs->lro.ctrl.lro_bad_csum, 0, NULL);
|
||||
SYSCTL_ADD_INT(ctx, lropoidlist, OID_AUTO, "lro_cnt",
|
||||
CTLFLAG_RD, &qs->lro.ctrl.lro_cnt, 0, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Now add a node for mac stats. */
|
||||
|
@ -53,7 +53,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/eventhandler.h>
|
||||
|
||||
#if __FreeBSD_version >= 800044
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#define V_ifnet ifnet
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
|
@ -47,7 +47,17 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/priv.h>
|
||||
|
||||
#if __FreeBSD_version >= 800044
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#define V_tcp_do_autosndbuf tcp_do_autosndbuf
|
||||
#define V_tcp_autosndbuf_max tcp_autosndbuf_max
|
||||
#define V_tcp_do_rfc1323 tcp_do_rfc1323
|
||||
#define V_tcp_do_autorcvbuf tcp_do_autorcvbuf
|
||||
#define V_tcp_autorcvbuf_max tcp_autorcvbuf_max
|
||||
#define V_tcpstat tcpstat
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
|
@ -368,8 +368,12 @@ cxgb_vm_page_to_miov(struct toepcb *toep, struct uio *uio, struct mbuf **m)
|
||||
m0->m_flags = (M_EXT|M_NOFREE);
|
||||
m0->m_ext.ext_type = EXT_EXTREF;
|
||||
m0->m_ext.ext_free = cxgb_zero_copy_free;
|
||||
#if __FreeBSD_version >= 800016
|
||||
m0->m_ext.ext_arg1 = NULL; /* XXX: probably wrong /phk */
|
||||
m0->m_ext.ext_arg2 = NULL;
|
||||
#else
|
||||
m0->m_ext.ext_args = NULL;
|
||||
#endif
|
||||
|
||||
mv = mtomv(m0);
|
||||
mv->mv_count = seg_count;
|
||||
|
Loading…
Reference in New Issue
Block a user