iwx: Fix 32-bit compilation

- Avoid shifts wider than integer types, by wrapping the corresponding
  checks into '#if __SIZEOF_SIZE_T__ > 32' blocks.  'bus_addr_t'
  currently has the same width as 'size_t' on all architectures (and
  this is not going to change for 32-bit architectures).
- Use appropriate printf(3) format for 'wk_keytsc'.

Reviewed by:    adrian
MFC after:      1 minute
MFC to:         stable/15
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D55667
This commit is contained in:
Olivier Certner
2026-03-05 13:31:51 +01:00
parent 9cea0f0be7
commit 35da55c28d
+17 -6
View File
@@ -155,6 +155,7 @@
#include <sys/epoch.h>
#include <sys/kdb.h>
#include <machine/_inttypes.h>
#include <machine/bus.h>
#include <machine/endian.h>
#include <machine/resource.h>
@@ -5818,15 +5819,21 @@ iwx_tx(struct iwx_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
desc->tbs[0].tb_len = htole16(IWX_FIRST_TB_SIZE);
paddr = htole64(data->cmd_paddr);
memcpy(&desc->tbs[0].addr, &paddr, sizeof(paddr));
if (data->cmd_paddr >> 32 != (data->cmd_paddr + le32toh(desc->tbs[0].tb_len)) >> 32)
#if __SIZEOF_SIZE_T__ > 32
if (data->cmd_paddr >> 32 != (data->cmd_paddr +
le32toh(desc->tbs[0].tb_len)) >> 32)
DPRINTF(("%s: TB0 crosses 32bit boundary\n", __func__));
#endif
desc->tbs[1].tb_len = htole16(sizeof(struct iwx_cmd_header) +
txcmd_size + hdrlen + pad - IWX_FIRST_TB_SIZE);
paddr = htole64(data->cmd_paddr + IWX_FIRST_TB_SIZE);
memcpy(&desc->tbs[1].addr, &paddr, sizeof(paddr));
if (data->cmd_paddr >> 32 != (data->cmd_paddr + le32toh(desc->tbs[1].tb_len)) >> 32)
#if __SIZEOF_SIZE_T__ > 32
if (data->cmd_paddr >> 32 != (data->cmd_paddr +
le32toh(desc->tbs[1].tb_len)) >> 32)
DPRINTF(("%s: TB1 crosses 32bit boundary\n", __func__));
#endif
/* Other DMA segments are for data payload. */
for (i = 0; i < nsegs; i++) {
@@ -5834,8 +5841,12 @@ iwx_tx(struct iwx_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
desc->tbs[i + 2].tb_len = htole16(seg->ds_len);
paddr = htole64(seg->ds_addr);
memcpy(&desc->tbs[i + 2].addr, &paddr, sizeof(paddr));
if (data->cmd_paddr >> 32 != (data->cmd_paddr + le32toh(desc->tbs[i + 2].tb_len)) >> 32)
DPRINTF(("%s: TB%d crosses 32bit boundary\n", __func__, i + 2));
#if __SIZEOF_SIZE_T__ > 32
if (data->cmd_paddr >> 32 != (data->cmd_paddr +
le32toh(desc->tbs[i + 2].tb_len)) >> 32)
DPRINTF(("%s: TB%d crosses 32bit boundary\n", __func__,
i + 2));
#endif
}
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
@@ -11079,8 +11090,8 @@ iwx_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
cmd.common.sta_id = IWX_STATION_ID;
cmd.transmit_seq_cnt = htole64(k->wk_keytsc);
IWX_DPRINTF(sc, IWX_DEBUG_KEYMGMT, "%s: k->wk_keytsc=%lu\n", __func__,
k->wk_keytsc);
IWX_DPRINTF(sc, IWX_DEBUG_KEYMGMT, "%s: k->wk_keytsc=%" PRIu64 "\n",
__func__, k->wk_keytsc);
status = IWX_ADD_STA_SUCCESS;
err = iwx_send_cmd_pdu_status(sc, IWX_ADD_STA_KEY, sizeof(cmd), &cmd,