svn commit: r296333 - in head/sys/dev/cxgbe: . common
Navdeep Parhar
np at FreeBSD.org
Thu Mar 3 01:41:55 UTC 2016
Author: np
Date: Thu Mar 3 01:41:53 2016
New Revision: 296333
URL: https://svnweb.freebsd.org/changeset/base/296333
Log:
cxgbe(4): First of many changes to reduce diffs with internal shared
code:
- Rename some CamelCase variables.
- s/t4_link_start/t4_link_l1cfg/g
- Pull in t4_get_port_type_description.
- Move t4_wait_op_done to t4_hw.c.
- Flip the order of the RDMA stats.
- Remove unsused function t4_iq_start_stop.
- Move t4_wait_op_done and t4_wait_op_done_val to t4_hw.c
Obtained from: Chelsio Communications
Modified:
head/sys/dev/cxgbe/common/common.h
head/sys/dev/cxgbe/common/t4_hw.c
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/common/common.h
==============================================================================
--- head/sys/dev/cxgbe/common/common.h Thu Mar 3 01:30:28 2016 (r296332)
+++ head/sys/dev/cxgbe/common/common.h Thu Mar 3 01:41:53 2016 (r296333)
@@ -169,10 +169,10 @@ struct lb_port_stats {
};
struct tp_tcp_stats {
- u32 tcpOutRsts;
- u64 tcpInSegs;
- u64 tcpOutSegs;
- u64 tcpRetransSegs;
+ u32 tcp_out_rsts;
+ u64 tcp_in_segs;
+ u64 tcp_out_segs;
+ u64 tcp_retrans_segs;
};
struct tp_usm_stats {
@@ -182,22 +182,22 @@ struct tp_usm_stats {
};
struct tp_fcoe_stats {
- u32 framesDDP;
- u32 framesDrop;
- u64 octetsDDP;
+ u32 frames_ddp;
+ u32 frames_drop;
+ u64 octets_ddp;
};
struct tp_err_stats {
- u32 macInErrs[4];
- u32 hdrInErrs[4];
- u32 tcpInErrs[4];
- u32 tnlCongDrops[4];
- u32 ofldChanDrops[4];
- u32 tnlTxDrops[4];
- u32 ofldVlanDrops[4];
- u32 tcp6InErrs[4];
- u32 ofldNoNeigh;
- u32 ofldCongDefer;
+ u32 mac_in_errs[4];
+ u32 hdr_in_errs[4];
+ u32 tcp_in_errs[4];
+ u32 tnl_cong_drops[4];
+ u32 ofld_chan_drops[4];
+ u32 tnl_tx_drops[4];
+ u32 ofld_vlan_drops[4];
+ u32 tcp6_in_errs[4];
+ u32 ofld_no_neigh;
+ u32 ofld_cong_defer;
};
struct tp_proxy_stats {
@@ -210,8 +210,8 @@ struct tp_cpl_stats {
};
struct tp_rdma_stats {
- u32 rqe_dfr_mod;
u32 rqe_dfr_pkt;
+ u32 rqe_dfr_mod;
};
struct tp_params {
@@ -389,15 +389,6 @@ static inline unsigned int dack_ticks_to
}
void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, u32 val);
-int t4_wait_op_done_val(struct adapter *adapter, int reg, u32 mask, int polarity,
- int attempts, int delay, u32 *valp);
-
-static inline int t4_wait_op_done(struct adapter *adapter, int reg, u32 mask,
- int polarity, int attempts, int delay)
-{
- return t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
- delay, NULL);
-}
int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
void *rpl, bool sleep_ok);
@@ -431,7 +422,7 @@ void t4_intr_clear(struct adapter *adapt
int t4_slow_intr_handler(struct adapter *adapter);
int t4_hash_mac_addr(const u8 *addr);
-int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
+int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
struct link_config *lc);
int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
int t4_seeprom_read(struct adapter *adapter, u32 addr, u32 *data);
@@ -500,6 +491,7 @@ int t4_edc_read(struct adapter *adap, in
int t4_mem_read(struct adapter *adap, int mtype, u32 addr, u32 size,
__be32 *data);
+const char *t4_get_port_type_description(enum fw_port_type port_type);
void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
void t4_get_port_stats_offset(struct adapter *adap, int idx,
struct port_stats *stats,
@@ -597,9 +589,6 @@ int t4_i2c_wr(struct adapter *adap, unsi
int port, unsigned int devid,
unsigned int offset, unsigned int len,
u8 *buf);
-int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
- unsigned int pf, unsigned int vf, unsigned int iqid,
- unsigned int fl0id, unsigned int fl1id);
int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
unsigned int vf, unsigned int iqtype, unsigned int iqid,
unsigned int fl0id, unsigned int fl1id);
Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c Thu Mar 3 01:30:28 2016 (r296332)
+++ head/sys/dev/cxgbe/common/t4_hw.c Thu Mar 3 01:41:53 2016 (r296333)
@@ -60,8 +60,8 @@ __FBSDID("$FreeBSD$");
* at the time it indicated completion is stored there. Returns 0 if the
* operation completes and -EAGAIN otherwise.
*/
-int t4_wait_op_done_val(struct adapter *adapter, int reg, u32 mask,
- int polarity, int attempts, int delay, u32 *valp)
+static int t4_wait_op_done_val(struct adapter *adapter, int reg, u32 mask,
+ int polarity, int attempts, int delay, u32 *valp)
{
while (1) {
u32 val = t4_read_reg(adapter, reg);
@@ -78,6 +78,13 @@ int t4_wait_op_done_val(struct adapter *
}
}
+static inline int t4_wait_op_done(struct adapter *adapter, int reg, u32 mask,
+ int polarity, int attempts, int delay)
+{
+ return t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
+ delay, NULL);
+}
+
/**
* t4_set_reg_field - set a register field to a value
* @adapter: the adapter to program
@@ -1870,7 +1877,7 @@ void t4_ulprx_read_la(struct adapter *ad
FW_PORT_CAP_SPEED_100G | FW_PORT_CAP_ANEG)
/**
- * t4_link_start - apply link configuration to MAC/PHY
+ * t4_link_l1cfg - apply link configuration to MAC/PHY
* @phy: the PHY to setup
* @mac: the MAC to setup
* @lc: the requested link configuration
@@ -1882,7 +1889,7 @@ void t4_ulprx_read_la(struct adapter *ad
* - If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
* otherwise do it later based on the outcome of auto-negotiation.
*/
-int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
+int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
struct link_config *lc)
{
struct fw_port_cmd c;
@@ -2909,7 +2916,7 @@ static int rd_rss_row(struct adapter *ad
return t4_wait_op_done_val(adap, A_TP_RSS_LKP_TABLE, F_LKPTBLROWVLD, 1,
5, 0, val);
}
-
+
/**
* t4_read_rss - read the contents of the RSS mapping table
* @adapter: the adapter
@@ -3189,18 +3196,18 @@ void t4_tp_get_tcp_stats(struct adapter
if (v4) {
t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, val,
ARRAY_SIZE(val), A_TP_MIB_TCP_OUT_RST);
- v4->tcpOutRsts = STAT(OUT_RST);
- v4->tcpInSegs = STAT64(IN_SEG);
- v4->tcpOutSegs = STAT64(OUT_SEG);
- v4->tcpRetransSegs = STAT64(RXT_SEG);
+ v4->tcp_out_rsts = STAT(OUT_RST);
+ v4->tcp_in_segs = STAT64(IN_SEG);
+ v4->tcp_out_segs = STAT64(OUT_SEG);
+ v4->tcp_retrans_segs = STAT64(RXT_SEG);
}
if (v6) {
t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, val,
ARRAY_SIZE(val), A_TP_MIB_TCP_V6OUT_RST);
- v6->tcpOutRsts = STAT(OUT_RST);
- v6->tcpInSegs = STAT64(IN_SEG);
- v6->tcpOutSegs = STAT64(OUT_SEG);
- v6->tcpRetransSegs = STAT64(RXT_SEG);
+ v6->tcp_out_rsts = STAT(OUT_RST);
+ v6->tcp_in_segs = STAT64(IN_SEG);
+ v6->tcp_out_segs = STAT64(OUT_SEG);
+ v6->tcp_retrans_segs = STAT64(RXT_SEG);
}
#undef STAT64
#undef STAT
@@ -3216,18 +3223,27 @@ void t4_tp_get_tcp_stats(struct adapter
*/
void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st)
{
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, st->macInErrs,
- 12, A_TP_MIB_MAC_IN_ERR_0);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, st->tnlCongDrops,
- 8, A_TP_MIB_TNL_CNG_DROP_0);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, st->tnlTxDrops,
- 4, A_TP_MIB_TNL_DROP_0);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, st->ofldVlanDrops,
- 4, A_TP_MIB_OFD_VLN_DROP_0);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, st->tcp6InErrs,
- 4, A_TP_MIB_TCP_V6IN_ERR_0);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->ofldNoNeigh,
- 2, A_TP_MIB_OFD_ARP_DROP);
+ int nchan = NCHAN;
+
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->mac_in_errs, nchan, A_TP_MIB_MAC_IN_ERR_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->hdr_in_errs, nchan, A_TP_MIB_HDR_IN_ERR_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->tcp_in_errs, nchan, A_TP_MIB_TCP_IN_ERR_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->tnl_cong_drops, nchan, A_TP_MIB_TNL_CNG_DROP_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->ofld_chan_drops, nchan, A_TP_MIB_OFD_CHN_DROP_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->tnl_tx_drops, nchan, A_TP_MIB_TNL_DROP_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->ofld_vlan_drops, nchan, A_TP_MIB_OFD_VLN_DROP_0);
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ st->tcp6_in_errs, nchan, A_TP_MIB_TCP_V6IN_ERR_0);
+
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+ &st->ofld_no_neigh, 2, A_TP_MIB_OFD_ARP_DROP);
}
/**
@@ -3266,7 +3282,7 @@ void t4_tp_get_cpl_stats(struct adapter
void t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st)
{
t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->rqe_dfr_mod,
- 2, A_TP_MIB_RQE_DFR_MOD);
+ 2, A_TP_MIB_RQE_DFR_PKT);
}
/**
@@ -3282,13 +3298,13 @@ void t4_get_fcoe_stats(struct adapter *a
{
u32 val[2];
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->framesDDP,
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->frames_ddp,
1, A_TP_MIB_FCOE_DDP_0 + idx);
- t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->framesDrop,
+ t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &st->frames_drop,
1, A_TP_MIB_FCOE_DROP_0 + idx);
t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, val,
2, A_TP_MIB_FCOE_BYTE_0_HI + 2 * idx);
- st->octetsDDP = ((u64)val[0] << 32) | val[1];
+ st->octets_ddp = ((u64)val[0] << 32) | val[1];
}
/**
@@ -3868,6 +3884,36 @@ static unsigned int get_mps_bg_map(struc
}
/**
+ * t4_get_port_type_description - return Port Type string description
+ * @port_type: firmware Port Type enumeration
+ */
+const char *t4_get_port_type_description(enum fw_port_type port_type)
+{
+ static const char *port_type_description[] = {
+ "Fiber_XFI",
+ "Fiber_XAUI",
+ "BT_SGMII",
+ "BT_XFI",
+ "BT_XAUI",
+ "KX4",
+ "CX4",
+ "KX",
+ "KR",
+ "SFP",
+ "BP_AP",
+ "BP4_AP",
+ "QSFP_10G",
+ "",
+ "QSFP",
+ "BP40_BA",
+ };
+
+ if (port_type < ARRAY_SIZE(port_type_description))
+ return port_type_description[port_type];
+ return "UNKNOWN";
+}
+
+/**
* t4_get_port_stats_offset - collect port stats relative to a previous
* snapshot
* @adap: The adapter
@@ -5276,37 +5322,6 @@ int t4_identify_port(struct adapter *ada
}
/**
- * t4_iq_start_stop - enable/disable an ingress queue and its FLs
- * @adap: the adapter
- * @mbox: mailbox to use for the FW command
- * @start: %true to enable the queues, %false to disable them
- * @pf: the PF owning the queues
- * @vf: the VF owning the queues
- * @iqid: ingress queue id
- * @fl0id: FL0 queue id or 0xffff if no attached FL0
- * @fl1id: FL1 queue id or 0xffff if no attached FL1
- *
- * Starts or stops an ingress queue and its associated FLs, if any.
- */
-int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
- unsigned int pf, unsigned int vf, unsigned int iqid,
- unsigned int fl0id, unsigned int fl1id)
-{
- struct fw_iq_cmd c;
-
- memset(&c, 0, sizeof(c));
- c.op_to_vfn = htonl(V_FW_CMD_OP(FW_IQ_CMD) | F_FW_CMD_REQUEST |
- F_FW_CMD_EXEC | V_FW_IQ_CMD_PFN(pf) |
- V_FW_IQ_CMD_VFN(vf));
- c.alloc_to_len16 = htonl(V_FW_IQ_CMD_IQSTART(start) |
- V_FW_IQ_CMD_IQSTOP(!start) | FW_LEN16(c));
- c.iqid = htons(iqid);
- c.fl0id = htons(fl0id);
- c.fl1id = htons(fl1id);
- return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
-}
-
-/**
* t4_iq_free - free an ingress queue and its FLs
* @adap: the adapter
* @mbox: mailbox to use for the FW command
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Thu Mar 3 01:30:28 2016 (r296332)
+++ head/sys/dev/cxgbe/t4_main.c Thu Mar 3 01:41:53 2016 (r296333)
@@ -828,7 +828,7 @@ t4_attach(device_t dev)
pi->link_cfg.fc &= ~(PAUSE_TX | PAUSE_RX);
pi->link_cfg.fc |= t4_pause_settings;
- rc = -t4_link_start(sc, sc->mbox, pi->tx_chan, &pi->link_cfg);
+ rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, &pi->link_cfg);
if (rc != 0) {
device_printf(dev, "port %d l1cfg failed: %d\n", i, rc);
free(pi->vi, M_CXGBE);
@@ -5935,7 +5935,7 @@ sysctl_pause_settings(SYSCTL_HANDLER_ARG
lc->requested_fc &= ~(PAUSE_TX | PAUSE_RX);
lc->requested_fc |= n;
- rc = -t4_link_start(sc, sc->mbox, pi->tx_chan, lc);
+ rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
lc->link_ok = link_ok; /* restore */
}
end_synchronized_op(sc, 0);
@@ -6494,13 +6494,14 @@ sysctl_fcoe_stats(SYSCTL_HANDLER_ARGS)
sbuf_printf(sb, " channel 0 channel 1 "
"channel 2 channel 3\n");
sbuf_printf(sb, "octetsDDP: %16ju %16ju %16ju %16ju\n",
- stats[0].octetsDDP, stats[1].octetsDDP, stats[2].octetsDDP,
- stats[3].octetsDDP);
- sbuf_printf(sb, "framesDDP: %16u %16u %16u %16u\n", stats[0].framesDDP,
- stats[1].framesDDP, stats[2].framesDDP, stats[3].framesDDP);
+ stats[0].octets_ddp, stats[1].octets_ddp, stats[2].octets_ddp,
+ stats[3].octets_ddp);
+ sbuf_printf(sb, "framesDDP: %16u %16u %16u %16u\n",
+ stats[0].frames_ddp, stats[1].frames_ddp, stats[2].frames_ddp,
+ stats[3].frames_ddp);
sbuf_printf(sb, "framesDrop: %16u %16u %16u %16u",
- stats[0].framesDrop, stats[1].framesDrop, stats[2].framesDrop,
- stats[3].framesDrop);
+ stats[0].frames_drop, stats[1].frames_drop, stats[2].frames_drop,
+ stats[3].frames_drop);
rc = sbuf_finish(sb);
sbuf_delete(sb);
@@ -7099,13 +7100,13 @@ sysctl_tcp_stats(SYSCTL_HANDLER_ARGS)
sbuf_printf(sb,
" IP IPv6\n");
sbuf_printf(sb, "OutRsts: %20u %20u\n",
- v4.tcpOutRsts, v6.tcpOutRsts);
+ v4.tcp_out_rsts, v6.tcp_out_rsts);
sbuf_printf(sb, "InSegs: %20ju %20ju\n",
- v4.tcpInSegs, v6.tcpInSegs);
+ v4.tcp_in_segs, v6.tcp_in_segs);
sbuf_printf(sb, "OutSegs: %20ju %20ju\n",
- v4.tcpOutSegs, v6.tcpOutSegs);
+ v4.tcp_out_segs, v6.tcp_out_segs);
sbuf_printf(sb, "RetransSegs: %20ju %20ju",
- v4.tcpRetransSegs, v6.tcpRetransSegs);
+ v4.tcp_retrans_segs, v6.tcp_retrans_segs);
rc = sbuf_finish(sb);
sbuf_delete(sb);
@@ -7199,31 +7200,31 @@ sysctl_tp_err_stats(SYSCTL_HANDLER_ARGS)
sbuf_printf(sb, " channel 0 channel 1 channel 2 "
"channel 3\n");
sbuf_printf(sb, "macInErrs: %10u %10u %10u %10u\n",
- stats.macInErrs[0], stats.macInErrs[1], stats.macInErrs[2],
- stats.macInErrs[3]);
+ stats.mac_in_errs[0], stats.mac_in_errs[1], stats.mac_in_errs[2],
+ stats.mac_in_errs[3]);
sbuf_printf(sb, "hdrInErrs: %10u %10u %10u %10u\n",
- stats.hdrInErrs[0], stats.hdrInErrs[1], stats.hdrInErrs[2],
- stats.hdrInErrs[3]);
+ stats.hdr_in_errs[0], stats.hdr_in_errs[1], stats.hdr_in_errs[2],
+ stats.hdr_in_errs[3]);
sbuf_printf(sb, "tcpInErrs: %10u %10u %10u %10u\n",
- stats.tcpInErrs[0], stats.tcpInErrs[1], stats.tcpInErrs[2],
- stats.tcpInErrs[3]);
+ stats.tcp_in_errs[0], stats.tcp_in_errs[1], stats.tcp_in_errs[2],
+ stats.tcp_in_errs[3]);
sbuf_printf(sb, "tcp6InErrs: %10u %10u %10u %10u\n",
- stats.tcp6InErrs[0], stats.tcp6InErrs[1], stats.tcp6InErrs[2],
- stats.tcp6InErrs[3]);
+ stats.tcp6_in_errs[0], stats.tcp6_in_errs[1], stats.tcp6_in_errs[2],
+ stats.tcp6_in_errs[3]);
sbuf_printf(sb, "tnlCongDrops: %10u %10u %10u %10u\n",
- stats.tnlCongDrops[0], stats.tnlCongDrops[1], stats.tnlCongDrops[2],
- stats.tnlCongDrops[3]);
+ stats.tnl_cong_drops[0], stats.tnl_cong_drops[1],
+ stats.tnl_cong_drops[2], stats.tnl_cong_drops[3]);
sbuf_printf(sb, "tnlTxDrops: %10u %10u %10u %10u\n",
- stats.tnlTxDrops[0], stats.tnlTxDrops[1], stats.tnlTxDrops[2],
- stats.tnlTxDrops[3]);
+ stats.tnl_tx_drops[0], stats.tnl_tx_drops[1], stats.tnl_tx_drops[2],
+ stats.tnl_tx_drops[3]);
sbuf_printf(sb, "ofldVlanDrops: %10u %10u %10u %10u\n",
- stats.ofldVlanDrops[0], stats.ofldVlanDrops[1],
- stats.ofldVlanDrops[2], stats.ofldVlanDrops[3]);
+ stats.ofld_vlan_drops[0], stats.ofld_vlan_drops[1],
+ stats.ofld_vlan_drops[2], stats.ofld_vlan_drops[3]);
sbuf_printf(sb, "ofldChanDrops: %10u %10u %10u %10u\n\n",
- stats.ofldChanDrops[0], stats.ofldChanDrops[1],
- stats.ofldChanDrops[2], stats.ofldChanDrops[3]);
+ stats.ofld_chan_drops[0], stats.ofld_chan_drops[1],
+ stats.ofld_chan_drops[2], stats.ofld_chan_drops[3]);
sbuf_printf(sb, "ofldNoNeigh: %u\nofldCongDefer: %u",
- stats.ofldNoNeigh, stats.ofldCongDefer);
+ stats.ofld_no_neigh, stats.ofld_cong_defer);
rc = sbuf_finish(sb);
sbuf_delete(sb);
More information about the svn-src-all
mailing list