Commit 81daf10c authored by Karen Xie's avatar Karen Xie Committed by James Bottomley

cxgbi: use per-connection link-speed dependent send/recv windows

For adapters supporting both 10G and 40G use per-connection send/recv window
and calculate the size based on the link speed.
Signed-off-by: default avatarKaren Xie <kxie@chelsio.com>
Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
parent dee0586e
...@@ -156,7 +156,7 @@ static int push_tx_frames(struct cxgbi_sock *csk, int req_completion); ...@@ -156,7 +156,7 @@ static int push_tx_frames(struct cxgbi_sock *csk, int req_completion);
static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb, static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
const struct l2t_entry *e) const struct l2t_entry *e)
{ {
unsigned int wscale = cxgbi_sock_compute_wscale(cxgb3i_rcv_win); unsigned int wscale = cxgbi_sock_compute_wscale(csk->rcv_win);
struct cpl_act_open_req *req = (struct cpl_act_open_req *)skb->head; struct cpl_act_open_req *req = (struct cpl_act_open_req *)skb->head;
skb->priority = CPL_PRIORITY_SETUP; skb->priority = CPL_PRIORITY_SETUP;
...@@ -172,7 +172,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb, ...@@ -172,7 +172,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
V_WND_SCALE(wscale) | V_MSS_IDX(csk->mss_idx) | V_WND_SCALE(wscale) | V_MSS_IDX(csk->mss_idx) |
V_L2T_IDX(e->idx) | V_TX_CHANNEL(e->smt_idx)); V_L2T_IDX(e->idx) | V_TX_CHANNEL(e->smt_idx));
req->opt0l = htonl(V_ULP_MODE(ULP2_MODE_ISCSI) | req->opt0l = htonl(V_ULP_MODE(ULP2_MODE_ISCSI) |
V_RCV_BUFSIZ(cxgb3i_rcv_win>>10)); V_RCV_BUFSIZ(csk->rcv_win >> 10));
log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK, log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
"csk 0x%p,%u,0x%lx,%u, %pI4:%u-%pI4:%u, %u,%u,%u.\n", "csk 0x%p,%u,0x%lx,%u, %pI4:%u-%pI4:%u, %u,%u,%u.\n",
...@@ -369,7 +369,7 @@ static inline void make_tx_data_wr(struct cxgbi_sock *csk, struct sk_buff *skb, ...@@ -369,7 +369,7 @@ static inline void make_tx_data_wr(struct cxgbi_sock *csk, struct sk_buff *skb,
req->flags |= htonl(V_TX_ACK_PAGES(2) | F_TX_INIT | req->flags |= htonl(V_TX_ACK_PAGES(2) | F_TX_INIT |
V_TX_CPU_IDX(csk->rss_qid)); V_TX_CPU_IDX(csk->rss_qid));
/* sendbuffer is in units of 32KB. */ /* sendbuffer is in units of 32KB. */
req->param |= htonl(V_TX_SNDBUF(cxgb3i_snd_win >> 15)); req->param |= htonl(V_TX_SNDBUF(csk->snd_win >> 15));
cxgbi_sock_set_flag(csk, CTPF_TX_DATA_SENT); cxgbi_sock_set_flag(csk, CTPF_TX_DATA_SENT);
} }
} }
...@@ -503,8 +503,8 @@ static int do_act_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) ...@@ -503,8 +503,8 @@ static int do_act_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
csk, csk->state, csk->flags, csk->tid); csk, csk->state, csk->flags, csk->tid);
csk->copied_seq = csk->rcv_wup = csk->rcv_nxt = rcv_isn; csk->copied_seq = csk->rcv_wup = csk->rcv_nxt = rcv_isn;
if (cxgb3i_rcv_win > (M_RCV_BUFSIZ << 10)) if (csk->rcv_win > (M_RCV_BUFSIZ << 10))
csk->rcv_wup -= cxgb3i_rcv_win - (M_RCV_BUFSIZ << 10); csk->rcv_wup -= csk->rcv_win - (M_RCV_BUFSIZ << 10);
cxgbi_sock_established(csk, ntohl(req->snd_isn), ntohs(req->tcp_opt)); cxgbi_sock_established(csk, ntohl(req->snd_isn), ntohs(req->tcp_opt));
...@@ -988,6 +988,8 @@ static int init_act_open(struct cxgbi_sock *csk) ...@@ -988,6 +988,8 @@ static int init_act_open(struct cxgbi_sock *csk)
goto rel_resource; goto rel_resource;
skb->sk = (struct sock *)csk; skb->sk = (struct sock *)csk;
set_arp_failure_handler(skb, act_open_arp_failure); set_arp_failure_handler(skb, act_open_arp_failure);
csk->snd_win = cxgb3i_snd_win;
csk->rcv_win = cxgb3i_rcv_win;
csk->wr_max_cred = csk->wr_cred = T3C_DATA(t3dev)->max_wrs - 1; csk->wr_max_cred = csk->wr_cred = T3C_DATA(t3dev)->max_wrs - 1;
csk->wr_una_cred = 0; csk->wr_una_cred = 0;
...@@ -1320,8 +1322,6 @@ static void cxgb3i_dev_open(struct t3cdev *t3dev) ...@@ -1320,8 +1322,6 @@ static void cxgb3i_dev_open(struct t3cdev *t3dev)
cdev->nports = adapter->params.nports; cdev->nports = adapter->params.nports;
cdev->mtus = adapter->params.mtus; cdev->mtus = adapter->params.mtus;
cdev->nmtus = NMTUS; cdev->nmtus = NMTUS;
cdev->snd_win = cxgb3i_snd_win;
cdev->rcv_win = cxgb3i_rcv_win;
cdev->rx_credit_thres = cxgb3i_rx_credit_thres; cdev->rx_credit_thres = cxgb3i_rx_credit_thres;
cdev->skb_tx_rsvd = CXGB3I_TX_HEADER_LEN; cdev->skb_tx_rsvd = CXGB3I_TX_HEADER_LEN;
cdev->skb_rx_extra = sizeof(struct cpl_iscsi_hdr_norss); cdev->skb_rx_extra = sizeof(struct cpl_iscsi_hdr_norss);
......
...@@ -50,11 +50,13 @@ MODULE_LICENSE("GPL"); ...@@ -50,11 +50,13 @@ MODULE_LICENSE("GPL");
module_param(dbg_level, uint, 0644); module_param(dbg_level, uint, 0644);
MODULE_PARM_DESC(dbg_level, "Debug flag (default=0)"); MODULE_PARM_DESC(dbg_level, "Debug flag (default=0)");
static int cxgb4i_rcv_win = 256 * 1024; #define CXGB4I_DEFAULT_10G_RCV_WIN (256 * 1024)
static int cxgb4i_rcv_win = -1;
module_param(cxgb4i_rcv_win, int, 0644); module_param(cxgb4i_rcv_win, int, 0644);
MODULE_PARM_DESC(cxgb4i_rcv_win, "TCP reveive window in bytes"); MODULE_PARM_DESC(cxgb4i_rcv_win, "TCP reveive window in bytes");
static int cxgb4i_snd_win = 128 * 1024; #define CXGB4I_DEFAULT_10G_SND_WIN (128 * 1024)
static int cxgb4i_snd_win = -1;
module_param(cxgb4i_snd_win, int, 0644); module_param(cxgb4i_snd_win, int, 0644);
MODULE_PARM_DESC(cxgb4i_snd_win, "TCP send window in bytes"); MODULE_PARM_DESC(cxgb4i_snd_win, "TCP send window in bytes");
...@@ -196,7 +198,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb, ...@@ -196,7 +198,7 @@ static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
TX_CHAN_V(csk->tx_chan) | TX_CHAN_V(csk->tx_chan) |
SMAC_SEL_V(csk->smac_idx) | SMAC_SEL_V(csk->smac_idx) |
ULP_MODE_V(ULP_MODE_ISCSI) | ULP_MODE_V(ULP_MODE_ISCSI) |
RCV_BUFSIZ_V(cxgb4i_rcv_win >> 10); RCV_BUFSIZ_V(csk->rcv_win >> 10);
opt2 = RX_CHANNEL_V(0) | opt2 = RX_CHANNEL_V(0) |
RSS_QUEUE_VALID_F | RSS_QUEUE_VALID_F |
(RX_FC_DISABLE_F) | (RX_FC_DISABLE_F) |
...@@ -279,7 +281,7 @@ static void send_act_open_req6(struct cxgbi_sock *csk, struct sk_buff *skb, ...@@ -279,7 +281,7 @@ static void send_act_open_req6(struct cxgbi_sock *csk, struct sk_buff *skb,
TX_CHAN_V(csk->tx_chan) | TX_CHAN_V(csk->tx_chan) |
SMAC_SEL_V(csk->smac_idx) | SMAC_SEL_V(csk->smac_idx) |
ULP_MODE_V(ULP_MODE_ISCSI) | ULP_MODE_V(ULP_MODE_ISCSI) |
RCV_BUFSIZ_V(cxgb4i_rcv_win >> 10); RCV_BUFSIZ_V(csk->rcv_win >> 10);
opt2 = RX_CHANNEL_V(0) | opt2 = RX_CHANNEL_V(0) |
RSS_QUEUE_VALID_F | RSS_QUEUE_VALID_F |
...@@ -544,7 +546,7 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *csk) ...@@ -544,7 +546,7 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *csk)
flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_RCVNXT; flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_RCVNXT;
flowc->mnemval[5].val = htonl(csk->rcv_nxt); flowc->mnemval[5].val = htonl(csk->rcv_nxt);
flowc->mnemval[6].mnemonic = FW_FLOWC_MNEM_SNDBUF; flowc->mnemval[6].mnemonic = FW_FLOWC_MNEM_SNDBUF;
flowc->mnemval[6].val = htonl(cxgb4i_snd_win); flowc->mnemval[6].val = htonl(csk->snd_win);
flowc->mnemval[7].mnemonic = FW_FLOWC_MNEM_MSS; flowc->mnemval[7].mnemonic = FW_FLOWC_MNEM_MSS;
flowc->mnemval[7].val = htonl(csk->advmss); flowc->mnemval[7].val = htonl(csk->advmss);
flowc->mnemval[8].mnemonic = 0; flowc->mnemval[8].mnemonic = 0;
...@@ -557,7 +559,7 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *csk) ...@@ -557,7 +559,7 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *csk)
log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK, log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
"csk 0x%p, tid 0x%x, %u,%u,%u,%u,%u,%u,%u.\n", "csk 0x%p, tid 0x%x, %u,%u,%u,%u,%u,%u,%u.\n",
csk, csk->tid, 0, csk->tx_chan, csk->rss_qid, csk, csk->tid, 0, csk->tx_chan, csk->rss_qid,
csk->snd_nxt, csk->rcv_nxt, cxgb4i_snd_win, csk->snd_nxt, csk->rcv_nxt, csk->snd_win,
csk->advmss); csk->advmss);
cxgb4_ofld_send(csk->cdev->ports[csk->port_id], skb); cxgb4_ofld_send(csk->cdev->ports[csk->port_id], skb);
...@@ -750,8 +752,8 @@ static void do_act_establish(struct cxgbi_device *cdev, struct sk_buff *skb) ...@@ -750,8 +752,8 @@ static void do_act_establish(struct cxgbi_device *cdev, struct sk_buff *skb)
* Causes the first RX_DATA_ACK to supply any Rx credits we couldn't * Causes the first RX_DATA_ACK to supply any Rx credits we couldn't
* pass through opt0. * pass through opt0.
*/ */
if (cxgb4i_rcv_win > (RCV_BUFSIZ_MASK << 10)) if (csk->rcv_win > (RCV_BUFSIZ_MASK << 10))
csk->rcv_wup -= cxgb4i_rcv_win - (RCV_BUFSIZ_MASK << 10); csk->rcv_wup -= csk->rcv_win - (RCV_BUFSIZ_MASK << 10);
csk->advmss = lldi->mtus[TCPOPT_MSS_G(tcp_opt)] - 40; csk->advmss = lldi->mtus[TCPOPT_MSS_G(tcp_opt)] - 40;
if (TCPOPT_TSTAMP_G(tcp_opt)) if (TCPOPT_TSTAMP_G(tcp_opt))
...@@ -1367,6 +1369,8 @@ static int init_act_open(struct cxgbi_sock *csk) ...@@ -1367,6 +1369,8 @@ static int init_act_open(struct cxgbi_sock *csk)
unsigned int step; unsigned int step;
unsigned int size, size6; unsigned int size, size6;
int t4 = is_t4(lldi->adapter_type); int t4 = is_t4(lldi->adapter_type);
unsigned int linkspeed;
unsigned int rcv_winf, snd_winf;
log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK, log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
"csk 0x%p,%u,0x%lx,%u.\n", "csk 0x%p,%u,0x%lx,%u.\n",
...@@ -1440,6 +1444,21 @@ static int init_act_open(struct cxgbi_sock *csk) ...@@ -1440,6 +1444,21 @@ static int init_act_open(struct cxgbi_sock *csk)
csk->txq_idx = cxgb4_port_idx(ndev) * step; csk->txq_idx = cxgb4_port_idx(ndev) * step;
step = lldi->nrxq / lldi->nchan; step = lldi->nrxq / lldi->nchan;
csk->rss_qid = lldi->rxq_ids[cxgb4_port_idx(ndev) * step]; csk->rss_qid = lldi->rxq_ids[cxgb4_port_idx(ndev) * step];
linkspeed = ((struct port_info *)netdev_priv(ndev))->link_cfg.speed;
csk->snd_win = cxgb4i_snd_win;
csk->rcv_win = cxgb4i_rcv_win;
if (cxgb4i_rcv_win <= 0) {
csk->rcv_win = CXGB4I_DEFAULT_10G_RCV_WIN;
rcv_winf = linkspeed / SPEED_10000;
if (rcv_winf)
csk->rcv_win *= rcv_winf;
}
if (cxgb4i_snd_win <= 0) {
csk->snd_win = CXGB4I_DEFAULT_10G_SND_WIN;
snd_winf = linkspeed / SPEED_10000;
if (snd_winf)
csk->snd_win *= snd_winf;
}
csk->wr_cred = lldi->wr_cred - csk->wr_cred = lldi->wr_cred -
DIV_ROUND_UP(sizeof(struct cpl_abort_req), 16); DIV_ROUND_UP(sizeof(struct cpl_abort_req), 16);
csk->wr_max_cred = csk->wr_cred; csk->wr_max_cred = csk->wr_cred;
...@@ -1758,8 +1777,6 @@ static void *t4_uld_add(const struct cxgb4_lld_info *lldi) ...@@ -1758,8 +1777,6 @@ static void *t4_uld_add(const struct cxgb4_lld_info *lldi)
cdev->nports = lldi->nports; cdev->nports = lldi->nports;
cdev->mtus = lldi->mtus; cdev->mtus = lldi->mtus;
cdev->nmtus = NMTUS; cdev->nmtus = NMTUS;
cdev->snd_win = cxgb4i_snd_win;
cdev->rcv_win = cxgb4i_rcv_win;
cdev->rx_credit_thres = cxgb4i_rx_credit_thres; cdev->rx_credit_thres = cxgb4i_rx_credit_thres;
cdev->skb_tx_rsvd = CXGB4I_TX_HEADER_LEN; cdev->skb_tx_rsvd = CXGB4I_TX_HEADER_LEN;
cdev->skb_rx_extra = sizeof(struct cpl_iscsi_hdr); cdev->skb_rx_extra = sizeof(struct cpl_iscsi_hdr);
......
...@@ -1126,11 +1126,11 @@ static int cxgbi_sock_send_pdus(struct cxgbi_sock *csk, struct sk_buff *skb) ...@@ -1126,11 +1126,11 @@ static int cxgbi_sock_send_pdus(struct cxgbi_sock *csk, struct sk_buff *skb)
goto out_err; goto out_err;
} }
if (csk->write_seq - csk->snd_una >= cdev->snd_win) { if (csk->write_seq - csk->snd_una >= csk->snd_win) {
log_debug(1 << CXGBI_DBG_PDU_TX, log_debug(1 << CXGBI_DBG_PDU_TX,
"csk 0x%p,%u,0x%lx,%u, FULL %u-%u >= %u.\n", "csk 0x%p,%u,0x%lx,%u, FULL %u-%u >= %u.\n",
csk, csk->state, csk->flags, csk->tid, csk->write_seq, csk, csk->state, csk->flags, csk->tid, csk->write_seq,
csk->snd_una, cdev->snd_win); csk->snd_una, csk->snd_win);
err = -ENOBUFS; err = -ENOBUFS;
goto out_err; goto out_err;
} }
...@@ -1885,7 +1885,7 @@ static void csk_return_rx_credits(struct cxgbi_sock *csk, int copied) ...@@ -1885,7 +1885,7 @@ static void csk_return_rx_credits(struct cxgbi_sock *csk, int copied)
"csk 0x%p,%u,0x%lx,%u, seq %u, wup %u, thre %u, %u.\n", "csk 0x%p,%u,0x%lx,%u, seq %u, wup %u, thre %u, %u.\n",
csk, csk->state, csk->flags, csk->tid, csk->copied_seq, csk, csk->state, csk->flags, csk->tid, csk->copied_seq,
csk->rcv_wup, cdev->rx_credit_thres, csk->rcv_wup, cdev->rx_credit_thres,
cdev->rcv_win); csk->rcv_win);
if (csk->state != CTP_ESTABLISHED) if (csk->state != CTP_ESTABLISHED)
return; return;
...@@ -1896,7 +1896,7 @@ static void csk_return_rx_credits(struct cxgbi_sock *csk, int copied) ...@@ -1896,7 +1896,7 @@ static void csk_return_rx_credits(struct cxgbi_sock *csk, int copied)
if (unlikely(cdev->rx_credit_thres == 0)) if (unlikely(cdev->rx_credit_thres == 0))
return; return;
must_send = credits + 16384 >= cdev->rcv_win; must_send = credits + 16384 >= csk->rcv_win;
if (must_send || credits >= cdev->rx_credit_thres) if (must_send || credits >= cdev->rx_credit_thres)
csk->rcv_wup += cdev->csk_send_rx_credits(csk, credits); csk->rcv_wup += cdev->csk_send_rx_credits(csk, credits);
} }
......
...@@ -234,6 +234,8 @@ struct cxgbi_sock { ...@@ -234,6 +234,8 @@ struct cxgbi_sock {
u32 snd_nxt; u32 snd_nxt;
u32 snd_una; u32 snd_una;
u32 write_seq; u32 write_seq;
u32 snd_win;
u32 rcv_win;
}; };
/* /*
...@@ -540,8 +542,6 @@ struct cxgbi_device { ...@@ -540,8 +542,6 @@ struct cxgbi_device {
struct iscsi_transport *itp; struct iscsi_transport *itp;
unsigned int pfvf; unsigned int pfvf;
unsigned int snd_win;
unsigned int rcv_win;
unsigned int rx_credit_thres; unsigned int rx_credit_thres;
unsigned int skb_tx_rsvd; unsigned int skb_tx_rsvd;
unsigned int skb_rx_extra; /* for msg coalesced mode */ unsigned int skb_rx_extra; /* for msg coalesced mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment