Skip to content

Commit

Permalink
sync up e1000 and igc nic code (nov 26, 2024 freebsd 13 stable)
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Dec 1, 2024
1 parent 7b4f818 commit 93a48c6
Show file tree
Hide file tree
Showing 8 changed files with 1,006 additions and 706 deletions.
4 changes: 2 additions & 2 deletions sys/dev/e1000/e1000_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_PCH_ADL_I219_V16:
case E1000_DEV_ID_PCH_ADL_I219_LM17:
case E1000_DEV_ID_PCH_ADL_I219_V17:
case E1000_DEV_ID_PCH_ADL_I219_LM19:
case E1000_DEV_ID_PCH_ADL_I219_V19:
mac->type = e1000_pch_adp;
break;
case E1000_DEV_ID_PCH_MTP_I219_LM18:
case E1000_DEV_ID_PCH_MTP_I219_V18:
case E1000_DEV_ID_PCH_MTP_I219_LM19:
case E1000_DEV_ID_PCH_MTP_I219_V19:
mac->type = e1000_pch_mtp;
break;
case E1000_DEV_ID_PCH_ARL_I219_LM24:
Expand Down
4 changes: 2 additions & 2 deletions sys/dev/e1000/e1000_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ struct e1000_hw;
#define E1000_DEV_ID_PCH_ADL_I219_V17 0x1A1D
#define E1000_DEV_ID_PCH_MTP_I219_LM18 0x550A
#define E1000_DEV_ID_PCH_MTP_I219_V18 0x550B
#define E1000_DEV_ID_PCH_MTP_I219_LM19 0x550C
#define E1000_DEV_ID_PCH_MTP_I219_V19 0x550D
#define E1000_DEV_ID_PCH_ADL_I219_LM19 0x550C
#define E1000_DEV_ID_PCH_ADL_I219_V19 0x550D
#define E1000_DEV_ID_PCH_LNL_I219_LM20 0x550E
#define E1000_DEV_ID_PCH_LNL_I219_V20 0x550F
#define E1000_DEV_ID_PCH_LNL_I219_LM21 0x5510
Expand Down
5 changes: 3 additions & 2 deletions sys/dev/e1000/e1000_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,10 @@ s32 e1000_setup_copper_link_generic(struct e1000_hw *hw)
* autonegotiation.
*/
ret_val = e1000_copper_link_autoneg(hw);
if (ret_val)
if (ret_val && !hw->mac.forced_speed_duplex)
return ret_val;
} else {
}
if (!hw->mac.autoneg || (ret_val && hw->mac.forced_speed_duplex)) {
/* PHY will be set to 10H, 10F, 100H or 100F
* depending on user settings.
*/
Expand Down
55 changes: 34 additions & 21 deletions sys/dev/e1000/em_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ em_dump_rs(struct e1000_softc *sc)
cur = txr->tx_rsq[rs_cidx];
status = txr->tx_base[cur].upper.fields.status;
if (!(status & E1000_TXD_STAT_DD))
printf("qid[%d]->tx_rsq[%d]: %d clear ", qid, rs_cidx, cur);
printf("qid[%d]->tx_rsq[%d]: %d clear ",
qid, rs_cidx, cur);
} else {
rs_cidx = (rs_cidx-1)&(ntxd-1);
cur = txr->tx_rsq[rs_cidx];
printf("qid[%d]->tx_rsq[rs_cidx-1=%d]: %d ", qid, rs_cidx, cur);
printf("qid[%d]->tx_rsq[rs_cidx-1=%d]: %d ",
qid, rs_cidx, cur);
}
printf("cidx_prev=%d rs_pidx=%d ",txr->tx_cidx_processed,
txr->tx_rs_pidx);
for (i = 0; i < ntxd; i++) {
if (txr->tx_base[i].upper.fields.status & E1000_TXD_STAT_DD)
if (txr->tx_base[i].upper.fields.status &
E1000_TXD_STAT_DD)
printf("%d set ", i);
}
printf("\n");
Expand All @@ -143,8 +146,8 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,

hdr_len = pi->ipi_ehdrlen + pi->ipi_ip_hlen + pi->ipi_tcp_hlen;
*txd_lower = (E1000_TXD_CMD_DEXT | /* Extended descr type */
E1000_TXD_DTYP_D | /* Data descr type */
E1000_TXD_CMD_TSE); /* Do TSE on this packet */
E1000_TXD_DTYP_D | /* Data descr type */
E1000_TXD_CMD_TSE); /* Do TSE on this packet */

cur = pi->ipi_pidx;
TXD = (struct e1000_context_desc *)&txr->tx_base[cur];
Expand All @@ -157,7 +160,8 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,
switch(pi->ipi_etype) {
case ETHERTYPE_IP:
/* IP and/or TCP header checksum calculation and insertion. */
*txd_upper = (E1000_TXD_POPTS_IXSM | E1000_TXD_POPTS_TXSM) << 8;
*txd_upper =
(E1000_TXD_POPTS_IXSM | E1000_TXD_POPTS_TXSM) << 8;

TXD->lower_setup.ip_fields.ipcse =
htole16(pi->ipi_ehdrlen + pi->ipi_ip_hlen - 1);
Expand All @@ -183,7 +187,8 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,
TXD->upper_setup.tcp_fields.tucss = pi->ipi_ehdrlen + pi->ipi_ip_hlen;
TXD->upper_setup.tcp_fields.tucse = 0;
TXD->upper_setup.tcp_fields.tucso =
pi->ipi_ehdrlen + pi->ipi_ip_hlen + offsetof(struct tcphdr, th_sum);
pi->ipi_ehdrlen + pi->ipi_ip_hlen +
offsetof(struct tcphdr, th_sum);

/*
* Payload size per packet w/o any headers.
Expand Down Expand Up @@ -211,8 +216,8 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,
if (++cur == scctx->isc_ntxd[0]) {
cur = 0;
}
DPRINTF(iflib_get_dev(sc->ctx), "%s: pidx: %d cur: %d\n", __FUNCTION__,
pi->ipi_pidx, cur);
DPRINTF(iflib_get_dev(sc->ctx), "%s: pidx: %d cur: %d\n",
__FUNCTION__, pi->ipi_pidx, cur);
return (cur);
}

Expand Down Expand Up @@ -277,8 +282,8 @@ em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi,
* ipcse - End offset for header checksum calculation.
* ipcso - Offset of place to put the checksum.
*
* We set ipcsX values regardless of IP version to work around HW issues
* and ipcse must be 0 for IPv6 per "PCIe GbE SDM 2.5" page 61.
* We set ipcsX values regardless of IP version to work around HW
* issues and ipcse must be 0 for IPv6 per "PCIe GbE SDM 2.5" page 61.
* IXSM controls whether it's inserted.
*/
TXD->lower_setup.ip_fields.ipcss = pi->ipi_ehdrlen;
Expand All @@ -296,7 +301,8 @@ em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi,
* tucse - End offset for payload checksum calculation.
* tucso - Offset of place to put the checksum.
*/
if (csum_flags & (CSUM_TCP | CSUM_UDP | CSUM_IP6_TCP | CSUM_IP6_UDP)) {
if (csum_flags & (CSUM_TCP | CSUM_UDP | CSUM_IP6_TCP |
CSUM_IP6_UDP)) {
uint8_t tucso;

*txd_upper |= E1000_TXD_POPTS_TXSM << 8;
Expand Down Expand Up @@ -326,7 +332,8 @@ em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi,
cur = 0;
}
DPRINTF(iflib_get_dev(sc->ctx),
"checksum_setup csum_flags=%x txd_upper=%x txd_lower=%x hdr_len=%d cmd=%x\n",
"checksum_setup csum_flags=%x txd_upper=%x txd_lower=%x"
" hdr_len=%d cmd=%x\n",
csum_flags, *txd_upper, *txd_lower, hdr_len, cmd);
return (cur);
}
Expand Down Expand Up @@ -372,7 +379,8 @@ em_isc_txd_encap(void *arg, if_pkt_info_t pi)
i = em_tso_setup(sc, pi, &txd_upper, &txd_lower);
tso_desc = true;
} else if (csum_flags & EM_CSUM_OFFLOAD) {
i = em_transmit_checksum_setup(sc, pi, &txd_upper, &txd_lower);
i = em_transmit_checksum_setup(sc, pi, &txd_upper,
&txd_lower);
}

if (pi->ipi_mflags & M_VLANTAG) {
Expand Down Expand Up @@ -414,7 +422,8 @@ em_isc_txd_encap(void *arg, if_pkt_info_t pi)
/* Now make the sentinel */
ctxd = &txr->tx_base[i];
ctxd->buffer_addr = htole64(seg_addr + seg_len);
ctxd->lower.data = htole32(cmd | txd_lower | TSO_WORKAROUND);
ctxd->lower.data =
htole32(cmd | txd_lower | TSO_WORKAROUND);
ctxd->upper.data = htole32(txd_upper);
pidx_last = i;
if (++i == scctx->isc_ntxd[0])
Expand All @@ -429,7 +438,8 @@ em_isc_txd_encap(void *arg, if_pkt_info_t pi)
pidx_last = i;
if (++i == scctx->isc_ntxd[0])
i = 0;
DPRINTF(iflib_get_dev(sc->ctx), "pidx_last=%d i=%d ntxd[0]=%d\n",
DPRINTF(iflib_get_dev(sc->ctx),
"pidx_last=%d i=%d ntxd[0]=%d\n",
pidx_last, i, scctx->isc_ntxd[0]);
}
}
Expand All @@ -449,7 +459,8 @@ em_isc_txd_encap(void *arg, if_pkt_info_t pi)
}
ctxd->lower.data |= htole32(E1000_TXD_CMD_EOP | txd_flags);
DPRINTF(iflib_get_dev(sc->ctx),
"tx_buffers[%d]->eop = %d ipi_new_pidx=%d\n", first, pidx_last, i);
"tx_buffers[%d]->eop = %d ipi_new_pidx=%d\n",
first, pidx_last, i);
pi->ipi_new_pidx = i;

/* Sent data accounting for AIM */
Expand Down Expand Up @@ -508,8 +519,8 @@ em_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear)
delta += ntxd;
MPASS(delta > 0);
DPRINTF(iflib_get_dev(sc->ctx),
"%s: cidx_processed=%u cur=%u clear=%d delta=%d\n",
__FUNCTION__, prev, cur, clear, delta);
"%s: cidx_processed=%u cur=%u clear=%d delta=%d\n",
__FUNCTION__, prev, cur, clear, delta);

processed += delta;
prev = cur;
Expand Down Expand Up @@ -699,7 +710,8 @@ lem_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)

if (scctx->isc_capenable & IFCAP_VLAN_HWTAGGING &&
status & E1000_RXD_STAT_VP) {
ri->iri_vtag = le16toh(rxd->special & E1000_RXD_SPC_VLAN_MASK);
ri->iri_vtag =
le16toh(rxd->special & E1000_RXD_SPC_VLAN_MASK);
ri->iri_flags |= M_VLANTAG;
}

Expand Down Expand Up @@ -789,7 +801,8 @@ em_receive_checksum(uint16_t status, uint8_t errors, if_rxd_info_t ri)
return;

/* If there is a layer 3 or 4 error we are done */
if (__predict_false(errors & (E1000_RXD_ERR_IPE | E1000_RXD_ERR_TCPE)))
if (__predict_false(errors & (E1000_RXD_ERR_IPE |
E1000_RXD_ERR_TCPE)))
return;

/* IP Checksum Good */
Expand Down
Loading

0 comments on commit 93a48c6

Please sign in to comment.