hfi.h (d295dbeb2a0c93364444e76b3bb30f587a823e0e) hfi.h (72c07e2b671eda1cf3e8ebabc664f542f673b997)
1#ifndef _HFI1_KERNEL_H
2#define _HFI1_KERNEL_H
3/*
4 * Copyright(c) 2015-2017 Intel Corporation.
5 *
6 * This file is provided under a dual BSD/GPLv2 license. When using or
7 * redistributing this file, you may do so under either license.
8 *

--- 52 unchanged lines hidden (view full) ---

61#include <linux/kref.h>
62#include <linux/sched.h>
63#include <linux/cdev.h>
64#include <linux/delay.h>
65#include <linux/kthread.h>
66#include <linux/i2c.h>
67#include <linux/i2c-algo-bit.h>
68#include <rdma/ib_hdrs.h>
1#ifndef _HFI1_KERNEL_H
2#define _HFI1_KERNEL_H
3/*
4 * Copyright(c) 2015-2017 Intel Corporation.
5 *
6 * This file is provided under a dual BSD/GPLv2 license. When using or
7 * redistributing this file, you may do so under either license.
8 *

--- 52 unchanged lines hidden (view full) ---

61#include <linux/kref.h>
62#include <linux/sched.h>
63#include <linux/cdev.h>
64#include <linux/delay.h>
65#include <linux/kthread.h>
66#include <linux/i2c.h>
67#include <linux/i2c-algo-bit.h>
68#include <rdma/ib_hdrs.h>
69#include <rdma/opa_addr.h>
69#include <linux/rhashtable.h>
70#include <linux/netdevice.h>
71#include <rdma/rdma_vt.h>
72
73#include "chip_registers.h"
74#include "common.h"
75#include "verbs.h"
76#include "pio.h"

--- 243 unchanged lines hidden (view full) ---

320 * here so we do not have to keep doing them over and over. The rule of thumb is
321 * if something is used one time to derive some value, store that something in
322 * here. If it is used multiple times, then store the result of that derivation
323 * in here.
324 */
325struct hfi1_packet {
326 void *ebuf;
327 void *hdr;
70#include <linux/rhashtable.h>
71#include <linux/netdevice.h>
72#include <rdma/rdma_vt.h>
73
74#include "chip_registers.h"
75#include "common.h"
76#include "verbs.h"
77#include "pio.h"

--- 243 unchanged lines hidden (view full) ---

321 * here so we do not have to keep doing them over and over. The rule of thumb is
322 * if something is used one time to derive some value, store that something in
323 * here. If it is used multiple times, then store the result of that derivation
324 * in here.
325 */
326struct hfi1_packet {
327 void *ebuf;
328 void *hdr;
329 void *payload;
328 struct hfi1_ctxtdata *rcd;
329 __le32 *rhf_addr;
330 struct rvt_qp *qp;
331 struct ib_other_headers *ohdr;
332 struct ib_grh *grh;
333 u64 rhf;
334 u32 maxcnt;
335 u32 rhqoff;

--- 10 unchanged lines hidden (view full) ---

346 u8 pad;
347 u8 sc;
348 u8 sl;
349 u8 opcode;
350 bool becn;
351 bool fecn;
352};
353
330 struct hfi1_ctxtdata *rcd;
331 __le32 *rhf_addr;
332 struct rvt_qp *qp;
333 struct ib_other_headers *ohdr;
334 struct ib_grh *grh;
335 u64 rhf;
336 u32 maxcnt;
337 u32 rhqoff;

--- 10 unchanged lines hidden (view full) ---

348 u8 pad;
349 u8 sc;
350 u8 sl;
351 u8 opcode;
352 bool becn;
353 bool fecn;
354};
355
356/*
357 * OPA 16B Header
358 */
359#define OPA_16B_L4_MASK 0xFFull
360#define OPA_16B_SC_MASK 0x1F00000ull
361#define OPA_16B_SC_SHIFT 20
362#define OPA_16B_LID_MASK 0xFFFFFull
363#define OPA_16B_DLID_MASK 0xF000ull
364#define OPA_16B_DLID_SHIFT 20
365#define OPA_16B_DLID_HIGH_SHIFT 12
366#define OPA_16B_SLID_MASK 0xF00ull
367#define OPA_16B_SLID_SHIFT 20
368#define OPA_16B_SLID_HIGH_SHIFT 8
369#define OPA_16B_BECN_MASK 0x80000000ull
370#define OPA_16B_BECN_SHIFT 31
371#define OPA_16B_FECN_MASK 0x10000000ull
372#define OPA_16B_FECN_SHIFT 28
373#define OPA_16B_L2_MASK 0x60000000ull
374#define OPA_16B_L2_SHIFT 29
375
376/*
377 * OPA 16B L2/L4 Encodings
378 */
379#define OPA_16B_L2_TYPE 0x02
380#define OPA_16B_L4_IB_LOCAL 0x09
381#define OPA_16B_L4_IB_GLOBAL 0x0A
382#define OPA_16B_L4_ETHR OPA_VNIC_L4_ETHR
383
384static inline u8 hfi1_16B_get_l4(struct hfi1_16b_header *hdr)
385{
386 return (u8)(hdr->lrh[2] & OPA_16B_L4_MASK);
387}
388
389static inline u8 hfi1_16B_get_sc(struct hfi1_16b_header *hdr)
390{
391 return (u8)((hdr->lrh[1] & OPA_16B_SC_MASK) >> OPA_16B_SC_SHIFT);
392}
393
394static inline u32 hfi1_16B_get_dlid(struct hfi1_16b_header *hdr)
395{
396 return (u32)((hdr->lrh[1] & OPA_16B_LID_MASK) |
397 (((hdr->lrh[2] & OPA_16B_DLID_MASK) >>
398 OPA_16B_DLID_HIGH_SHIFT) << OPA_16B_DLID_SHIFT));
399}
400
401static inline u32 hfi1_16B_get_slid(struct hfi1_16b_header *hdr)
402{
403 return (u32)((hdr->lrh[0] & OPA_16B_LID_MASK) |
404 (((hdr->lrh[2] & OPA_16B_SLID_MASK) >>
405 OPA_16B_SLID_HIGH_SHIFT) << OPA_16B_SLID_SHIFT));
406}
407
408static inline u8 hfi1_16B_get_becn(struct hfi1_16b_header *hdr)
409{
410 return (u8)((hdr->lrh[0] & OPA_16B_BECN_MASK) >> OPA_16B_BECN_SHIFT);
411}
412
413static inline u8 hfi1_16B_get_fecn(struct hfi1_16b_header *hdr)
414{
415 return (u8)((hdr->lrh[1] & OPA_16B_FECN_MASK) >> OPA_16B_FECN_SHIFT);
416}
417
418static inline u8 hfi1_16B_get_l2(struct hfi1_16b_header *hdr)
419{
420 return (u8)((hdr->lrh[1] & OPA_16B_L2_MASK) >> OPA_16B_L2_SHIFT);
421}
422
423/*
424 * BTH
425 */
426#define OPA_16B_BTH_PAD_MASK 7
427static inline u8 hfi1_16B_bth_get_pad(struct ib_other_headers *ohdr)
428{
429 return (u8)((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_PAD_SHIFT) &
430 OPA_16B_BTH_PAD_MASK);
431}
432
354struct rvt_sge_state;
355
356/*
357 * Get/Set IB link-level config parameters for f_get/set_ib_cfg()
358 * Mostly for MADs that set or query link parameters, also ipath
359 * config interfaces
360 */
361#define HFI1_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */

--- 1717 unchanged lines hidden (view full) ---

2079
2080int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
2081
2082#define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev))
2083#define DD_DEV_ASSIGN(dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev))
2084
2085/*
2086 * hfi1_check_mcast- Check if the given lid is
433struct rvt_sge_state;
434
435/*
436 * Get/Set IB link-level config parameters for f_get/set_ib_cfg()
437 * Mostly for MADs that set or query link parameters, also ipath
438 * config interfaces
439 */
440#define HFI1_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */

--- 1717 unchanged lines hidden (view full) ---

2158
2159int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
2160
2161#define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev))
2162#define DD_DEV_ASSIGN(dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev))
2163
2164/*
2165 * hfi1_check_mcast- Check if the given lid is
2087 * in the IB multicast range.
2166 * in the OPA multicast range.
2167 *
2168 * The LID might either reside in ah.dlid or might be
2169 * in the GRH of the address handle as DGID if extended
2170 * addresses are in use.
2088 */
2171 */
2089static inline bool hfi1_check_mcast(u16 lid)
2172static inline bool hfi1_check_mcast(u32 lid)
2090{
2173{
2091 return ((lid >= be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
2092 (lid != be16_to_cpu(IB_LID_PERMISSIVE)));
2174 return ((lid >= opa_get_mcast_base(OPA_MCAST_NR)) &&
2175 (lid != be32_to_cpu(OPA_LID_PERMISSIVE)));
2093}
2176}
2177
2178#define opa_get_lid(lid, format) \
2179 __opa_get_lid(lid, OPA_PORT_PACKET_FORMAT_##format)
2180
2181/* Convert a lid to a specific lid space */
2182static inline u32 __opa_get_lid(u32 lid, u8 format)
2183{
2184 bool is_mcast = hfi1_check_mcast(lid);
2185
2186 switch (format) {
2187 case OPA_PORT_PACKET_FORMAT_8B:
2188 case OPA_PORT_PACKET_FORMAT_10B:
2189 if (is_mcast)
2190 return (lid - opa_get_mcast_base(OPA_MCAST_NR) +
2191 0xF0000);
2192 return lid & 0xFFFFF;
2193 case OPA_PORT_PACKET_FORMAT_16B:
2194 if (is_mcast)
2195 return (lid - opa_get_mcast_base(OPA_MCAST_NR) +
2196 0xF00000);
2197 return lid & 0xFFFFFF;
2198 case OPA_PORT_PACKET_FORMAT_9B:
2199 if (is_mcast)
2200 return (lid -
2201 opa_get_mcast_base(OPA_MCAST_NR) +
2202 be16_to_cpu(IB_MULTICAST_LID_BASE));
2203 else
2204 return lid & 0xFFFF;
2205 default:
2206 return lid;
2207 }
2208}
2209
2210/* Return true if the given lid is the OPA 16B multicast range */
2211static inline bool hfi1_is_16B_mcast(u32 lid)
2212{
2213 return ((lid >=
2214 opa_get_lid(opa_get_mcast_base(OPA_MCAST_NR), 16B)) &&
2215 (lid != opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE), 16B)));
2216}
2094#endif /* _HFI1_KERNEL_H */
2217#endif /* _HFI1_KERNEL_H */