/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* * Copyright(c) 2015-2017 Intel Corporation. */ #ifndef _PIO_H #define _PIO_H /* send context types */ #define SC_KERNEL … #define SC_VL15 … #define SC_ACK … #define SC_USER … #define SC_MAX … /* invalid send context index */ #define INVALID_SCI … /* PIO buffer release callback function */ pio_release_cb; /* PIO release codes - in bits, as there could more than one that apply */ #define PRC_OK … #define PRC_STATUS_ERR … #define PRC_PBC … #define PRC_THRESHOLD … #define PRC_FILL_ERR … #define PRC_FORCE … #define PRC_SC_DISABLE … /* byte helper */ mix; /* an allocated PIO buffer */ struct pio_buf { … }; /* cache line aligned pio buffer array */ pio_shadow_ring ____cacheline_aligned; /* per-NUMA send context */ struct send_context { … }; /* send context flags */ #define SCF_ENABLED … #define SCF_IN_FREE … #define SCF_HALTED … #define SCF_FROZEN … #define SCF_LINK_DOWN … struct send_context_info { … }; /* DMA credit return, index is always (context & 0x7) */ struct credit_return { … }; /* NUMA indexed credit return array */ struct credit_return_base { … }; /* send context configuration sizes (one per type) */ struct sc_config_sizes { … }; /* * The diagram below details the relationship of the mapping structures * * Since the mapping now allows for non-uniform send contexts per vl, the * number of send contexts for a vl is either the vl_scontexts[vl] or * a computation based on num_kernel_send_contexts/num_vls: * * For example: * nactual = vl_scontexts ? vl_scontexts[vl] : num_kernel_send_contexts/num_vls * * n = roundup to next highest power of 2 using nactual * * In the case where there are num_kernel_send_contexts/num_vls doesn't divide * evenly, the extras are added from the last vl downward. * * For the case where n > nactual, the send contexts are assigned * in a round robin fashion wrapping back to the first send context * for a particular vl. * * dd->pio_map * | pio_map_elem[0] * | +--------------------+ * v | mask | * pio_vl_map |--------------------| * +--------------------------+ | ksc[0] -> sc 1 | * | list (RCU) | |--------------------| * |--------------------------| ->| ksc[1] -> sc 2 | * | mask | --/ |--------------------| * |--------------------------| -/ | * | * | actual_vls (max 8) | -/ |--------------------| * |--------------------------| --/ | ksc[n-1] -> sc n | * | vls (max 8) | -/ +--------------------+ * |--------------------------| --/ * | map[0] |-/ * |--------------------------| +--------------------+ * | map[1] |--- | mask | * |--------------------------| \---- |--------------------| * | * | \-- | ksc[0] -> sc 1+n | * | * | \---- |--------------------| * | * | \->| ksc[1] -> sc 2+n | * |--------------------------| |--------------------| * | map[vls - 1] |- | * | * +--------------------------+ \- |--------------------| * \- | ksc[m-1] -> sc m+n | * \ +--------------------+ * \- * \ * \- +----------------------+ * \- | mask | * \ |----------------------| * \- | ksc[0] -> sc 1+m+n | * \- |----------------------| * >| ksc[1] -> sc 2+m+n | * |----------------------| * | * | * |----------------------| * | ksc[o-1] -> sc o+m+n | * +----------------------+ * */ /* Initial number of send contexts per VL */ #define INIT_SC_PER_VL … /* * struct pio_map_elem - mapping for a vl * @mask - selector mask * @ksc - array of kernel send contexts for this vl * * The mask is used to "mod" the selector to * produce index into the trailing array of * kscs */ struct pio_map_elem { … }; /* * struct pio_vl_map - mapping for a vl * @list - rcu head for free callback * @mask - vl mask to "mod" the vl to produce an index to map array * @actual_vls - number of vls * @vls - numbers of vls rounded to next power of 2 * @map - array of pio_map_elem entries * * This is the parent mapping structure. The trailing members of the * struct point to pio_map_elem entries, which in turn point to an * array of kscs for that vl. */ struct pio_vl_map { … }; int pio_map_init(struct hfi1_devdata *dd, u8 port, u8 num_vls, u8 *vl_scontexts); void free_pio_map(struct hfi1_devdata *dd); struct send_context *pio_select_send_context_vl(struct hfi1_devdata *dd, u32 selector, u8 vl); struct send_context *pio_select_send_context_sc(struct hfi1_devdata *dd, u32 selector, u8 sc5); /* send context functions */ int init_credit_return(struct hfi1_devdata *dd); void free_credit_return(struct hfi1_devdata *dd); int init_sc_pools_and_sizes(struct hfi1_devdata *dd); int init_send_contexts(struct hfi1_devdata *dd); int init_pervl_scs(struct hfi1_devdata *dd); struct send_context *sc_alloc(struct hfi1_devdata *dd, int type, uint hdrqentsize, int numa); void sc_free(struct send_context *sc); int sc_enable(struct send_context *sc); void sc_disable(struct send_context *sc); int sc_restart(struct send_context *sc); void sc_return_credits(struct send_context *sc); void sc_flush(struct send_context *sc); void sc_drop(struct send_context *sc); void sc_stop(struct send_context *sc, int bit); struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len, pio_release_cb cb, void *arg); void sc_release_update(struct send_context *sc); void sc_group_release_update(struct hfi1_devdata *dd, u32 hw_context); void sc_add_credit_return_intr(struct send_context *sc); void sc_del_credit_return_intr(struct send_context *sc); void sc_set_cr_threshold(struct send_context *sc, u32 new_threshold); u32 sc_percent_to_threshold(struct send_context *sc, u32 percent); u32 sc_mtu_to_threshold(struct send_context *sc, u32 mtu, u32 hdrqentsize); void hfi1_sc_wantpiobuf_intr(struct send_context *sc, u32 needint); void sc_wait(struct hfi1_devdata *dd); void set_pio_integrity(struct send_context *sc); /* support functions */ void pio_reset_all(struct hfi1_devdata *dd); void pio_freeze(struct hfi1_devdata *dd); void pio_kernel_unfreeze(struct hfi1_devdata *dd); void pio_kernel_linkup(struct hfi1_devdata *dd); /* global PIO send control operations */ #define PSC_GLOBAL_ENABLE … #define PSC_GLOBAL_DISABLE … #define PSC_GLOBAL_VLARB_ENABLE … #define PSC_GLOBAL_VLARB_DISABLE … #define PSC_CM_RESET … #define PSC_DATA_VL_ENABLE … #define PSC_DATA_VL_DISABLE … void __cm_reset(struct hfi1_devdata *dd, u64 sendctrl); void pio_send_control(struct hfi1_devdata *dd, int op); /* PIO copy routines */ void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc, const void *from, size_t count); void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc, const void *from, size_t nbytes); void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes); void seg_pio_copy_end(struct pio_buf *pbuf); void seqfile_dump_sci(struct seq_file *s, u32 i, struct send_context_info *sci); #endif /* _PIO_H */