Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cxgbe/tom: Miscellaneous updates for TOE+IPv6 support (more to follow).
- Teach find_best_mtu_idx() to deal with IPv6 endpoints.

- Install correct protosw in offloaded TCP/IPv6 sockets when DDP is
  enabled.

- Move set_tcp_ddp_ulp_mode to t4_tom.c so that t4_tom.h can be included
  without having to drag in t4_msg.h too.  This was bothering the iWARP
  driver for some reason.

MFC after:	1 week
  • Loading branch information
np-2020 committed Jan 15, 2013
1 parent 8251e18 commit 90ae50f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
44 changes: 37 additions & 7 deletions sys/dev/cxgbe/tom/t4_tom.c
Expand Up @@ -29,6 +29,7 @@
__FBSDID("$FreeBSD$");

#include "opt_inet.h"
#include "opt_inet6.h"

#include <sys/param.h>
#include <sys/types.h>
Expand All @@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/tcp_var.h>
#define TCPSTATES
#include <netinet/tcp_fsm.h>
Expand All @@ -58,6 +60,9 @@ __FBSDID("$FreeBSD$");
static struct protosw ddp_protosw;
static struct pr_usrreqs ddp_usrreqs;

static struct protosw ddp6_protosw;
static struct pr_usrreqs ddp6_usrreqs;

/* Module ops */
static int t4_tom_mod_load(void);
static int t4_tom_mod_unload(void);
Expand Down Expand Up @@ -170,8 +175,12 @@ offload_socket(struct socket *so, struct toepcb *toep)
sb = &so->so_rcv;
SOCKBUF_LOCK(sb);
sb->sb_flags |= SB_NOCOALESCE;
if (toep->ulp_mode == ULP_MODE_TCPDDP)
so->so_proto = &ddp_protosw;
if (toep->ulp_mode == ULP_MODE_TCPDDP) {
if (inp->inp_vflag & INP_IPV6)
so->so_proto = &ddp6_protosw;
else
so->so_proto = &ddp_protosw;
}
SOCKBUF_UNLOCK(sb);

/* Update TCP PCB */
Expand Down Expand Up @@ -394,7 +403,7 @@ int
find_best_mtu_idx(struct adapter *sc, struct in_conninfo *inc, int pmss)
{
unsigned short *mtus = &sc->params.mtus[0];
int i = 0, mss;
int i, mss, n;

KASSERT(inc != NULL || pmss > 0,
("%s: at least one of inc/pmss must be specified", __func__));
Expand All @@ -403,8 +412,13 @@ find_best_mtu_idx(struct adapter *sc, struct in_conninfo *inc, int pmss)
if (pmss > 0 && mss > pmss)
mss = pmss;

while (i < NMTUS - 1 && mtus[i + 1] <= mss + 40)
++i;
if (inc->inc_flags & INC_ISIPV6)
n = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
else
n = sizeof(struct ip) + sizeof(struct tcphdr);

for (i = 0; i < NMTUS - 1 && mtus[i + 1] <= mss + n; i++)
continue;

return (i);
}
Expand Down Expand Up @@ -513,6 +527,15 @@ select_ntuple(struct port_info *pi, struct l2t_entry *e, uint32_t filter_mode)
return (htobe32(ntuple));
}

void
set_tcpddp_ulp_mode(struct toepcb *toep)
{

toep->ulp_mode = ULP_MODE_TCPDDP;
toep->ddp_flags = DDP_OK;
toep->ddp_score = DDP_LOW_SCORE;
}

static int
alloc_tid_tabs(struct tid_info *t)
{
Expand Down Expand Up @@ -698,17 +721,24 @@ static int
t4_tom_mod_load(void)
{
int rc;
struct protosw *tcp_protosw;
struct protosw *tcp_protosw, *tcp6_protosw;

tcp_protosw = pffindproto(PF_INET, IPPROTO_TCP, SOCK_STREAM);
if (tcp_protosw == NULL)
return (ENOPROTOOPT);

bcopy(tcp_protosw, &ddp_protosw, sizeof(ddp_protosw));
bcopy(tcp_protosw->pr_usrreqs, &ddp_usrreqs, sizeof(ddp_usrreqs));
ddp_usrreqs.pru_soreceive = t4_soreceive_ddp;
ddp_protosw.pr_usrreqs = &ddp_usrreqs;

tcp6_protosw = pffindproto(PF_INET6, IPPROTO_TCP, SOCK_STREAM);
if (tcp6_protosw == NULL)
return (ENOPROTOOPT);
bcopy(tcp6_protosw, &ddp6_protosw, sizeof(ddp6_protosw));
bcopy(tcp6_protosw->pr_usrreqs, &ddp6_usrreqs, sizeof(ddp6_usrreqs));
ddp6_usrreqs.pru_soreceive = t4_soreceive_ddp;
ddp6_protosw.pr_usrreqs = &ddp6_usrreqs;

rc = t4_register_uld(&tom_uld_info);
if (rc != 0)
t4_tom_mod_unload();
Expand Down
10 changes: 1 addition & 9 deletions sys/dev/cxgbe/tom/t4_tom.h
Expand Up @@ -140,15 +140,6 @@ struct flowc_tx_params {
#define DDP_LOW_SCORE 1
#define DDP_HIGH_SCORE 3

static inline void
set_tcpddp_ulp_mode(struct toepcb *toep)
{

toep->ulp_mode = ULP_MODE_TCPDDP;
toep->ddp_flags = DDP_OK;
toep->ddp_score = DDP_LOW_SCORE;
}

/*
* Compressed state for embryonic connections for a listener. Barely fits in
* 64B, try not to grow it further.
Expand Down Expand Up @@ -234,6 +225,7 @@ int select_rcv_wscale(void);
uint64_t calc_opt0(struct socket *, struct port_info *, struct l2t_entry *,
int, int, int, int);
uint32_t select_ntuple(struct port_info *, struct l2t_entry *, uint32_t);
void set_tcpddp_ulp_mode(struct toepcb *);

/* t4_connect.c */
void t4_init_connect_cpl_handlers(struct adapter *);
Expand Down

0 comments on commit 90ae50f

Please sign in to comment.