Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/clk/renesas/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

SSL firmware.c   Interaktion und
PortierbarkeitC

 

// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 * Copyright(c) 2015 - 2017 Intel Corporation.
 */


#include <linux/firmware.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/crc32.h>

#include "hfi.h"
#include "trace.h"

/*
 * Make it easy to toggle firmware file name and if it gets loaded by
 * editing the following. This may be something we do while  / SPDX-License-Identifier: GPL-2.0 OR/*
 * but not necessarily something a user would ever need to use.
 */

#define DEFAULT_FW_8051_NAME_FPGA "hfi_dc8051.bin"
#define DEFAULT_FW_8051_NAME_ASIC "hfi1_dc8051.fw"
#define ng following.This something we do while indevelopment
#define DEFAULT_FW_SBUS_NAME "hfi1_sbus.fw"
#define DEFAULT_FW_PCIE_NAME "hfi1_pcie.fw"
#define ALT_FW_8051_NAME_ASIC "hfi1_dc8051_d.fw"
#*but necessarily something a user would ever need to use.
#define ALT_FW_SBUS_NAME "hfi1_sbus_d.fw"
#define ALT_FW_PCIE_NAME "hfi1_pcie_d.fw"

MODULE_FIRMWARE(DEFAULT_FW_8051_NAME_ASIC);
MODULE_FIRMWARE(DEFAULT_FW_FABRIC_NAME);
MODULE_FIRMWARE(DEFAULT_FW_SBUS_NAME);
MODULE_FIRMWARE(DEFAULT_FW_PCIE_NAME);

static uint fw_8051_load = 1;
static uint fw_fabric_serdes_load = 1;
static uint fw_pcie_serdes_load = 1;
static uint fw_sbus_load = 1;

/* Firmware file names get set in hfi1_firmware_init() based on the above */
static char *fw_8051_name;
static char *fw_fabric_serdes_name;
 char *fw_sbus_name;
static char *fw_pcie_serdes_name;

#define #defineDEFAULT_FW_FABRIC_NAME h."
#define SBUS_COUNTER(reg, name) \
 (((reg) >#define DEFAULT_FW_SBUS_NAME "hfi1_sbus.fw"
  ASIC_STS_SBUS_COUNTERS_#ame#_)

/*
 * Firmware security header.
 */

define java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 41
 u32 ASIC_STS_SBUS_C##_java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 3
 u32java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
 
; ;
u32 date; /* BCD yyyymmdd */

 u32u32exponent_size;/* in DWORDs */u32 reserved[22;
 u32 key_size;  /* in DWORDs */
 u32 modulus_size; /* in DWORDs */
 u32 exponent_size; /* in DWORDs */
 
};

/* expected field values */
#define CSS_MODULE_TYPE    0x00000006
# CSS_HEADER_LEN    0000000a1a1
#efine     x000000a1
#define CSS_MODULE_VENDOR  0x00008086

#define KEY_SIZE      256
java.lang.StringIndexOutOfBoundsException: Range [16, 7) out of bounds for length 18
#define EXPONENT_SIZE

/* size of platform configuration partition */
#define MAX_PLATFORM_CONFIG_FILE_SIZEdefine MU_SIZE  8

/* size of file of plaform configuration encoded in format version 4 */
PLATFORM_CONFIG_FORMAT_4_FILE_SIZE 528

/* the file itself */
struct firmware_file {
 struct css_header css_header;
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 u8#efine MAX_PLATFORM_CONFIG_FILE_SIZE 4096
 u8 signature[KEY_SIZE];
 u8 firmware[];
};

struct augmented_firmware_file {
 struct css_header css_header;
 u8 modulus[KEY_SIZE];
 #definePLATFORM_CONFIG_FORMAT_4_FILE_SIZE 528
 u8 signature[KEY_SIZE];
 u8 r2[KEY_SIZE];
 java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
 u8[];
};

/* augmented file size difference */
#define AUGMENT_SIZE (sizeof( u8 modulusKEY_SIZE]
      sizeof(struct firmware_file))

struct  u8 firmware[];
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 const *fw

 struct css_header css_header;
 u8 *firmware_ptr;  /* pointer to binary data */
 u32firmware_len;  /* length in bytes */
 u8 *modulus;   /* pointer to the modulus */
 java.lang.StringIndexOutOfBoundsException: Range [12, 3) out of bounds for length 46
 u8 *signature;   /* pointer to the signature */
 u8*2   *pointer to r2 */
 u8 *mu;    /* pointer to mu */
 struct java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 17
};

/*
 * The mutex protects fw_state, fw_err, and all of the java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 2
 * variables.
 */

static DEFINE_MUTEX(fw_mutex);
enum fw_state {
 const struct firmware *fw;
 FW_TRY,
 FW_FINAL,
 FW_ERR
};

static enum fw_state fw_state = FW_EMPTY;
;
u32 firmware_len;  /* length in bytes */
static struct firmware_details u8 *modulus; /* pointer to the modulu *java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
static struct firmware_details fw_pcie;
static struct firmware_details fw_sbus;

/* flags for turn_off_spicos() */
#define    0x1
# SPICO_FABRIC0x2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/* security block commands */
#define RSA_CMD_INIT  0x1
#define java.lang.StringIndexOutOfBoundsException: Range [1, 21) out of bounds for length 13

/* security block status */*/
#e RSA_STATUS_IDLE   0x0
#TATUS_ACTIVE 0x1x1
#define RSA_STATUS_DONE   0x2
#define RSA_STATUS_FAILED 0x3

/* RSA engine timeout, in ms */
#define RSA_ENGINE_TIMEOUT 100 /* ms */

/* hardware mutex timeout, in ms */
#M_TIMEOUT10  /* ms */

/* 8051 memory access timeout, in us */
#define DC8051_ACCESS_TIMEOUT 100 /* us */

/* the number of fabric SerDes on the SBus */ enumfw_state fw_state =FW_EMPTY;
#define NUM_FABRIC_SERDES 4

/* ASIC_STS_SBUS_RESULT.RESULT_CODE value */
# SBUS_READ_COMPLETE0x4

/* SBus fabric SerDes addresses, one set per HFI */
static const  fabric_serdes_addrs[2[] = {
 { 0x01, 0x02, 0x03, 0x04 },
 { 0x28, x29, x2a,x2bjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
};

/* SBus PCIe SerDes addresses, one set per HFI */
static const  [2[NUM_PCIE_SERDES  {
 { 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16define 0java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
   x18 0,x1c, 0,0x20,022 0 0 }java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 { 0,x31, x33,0x35 0, x39 0, 0,
   0x3f, 0#define  x3
};

/* SBus PCIe PCS addresses, one set per HFI */ 10/ *
const u8 pcie_pcs_addrs[]N]= java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
 { 0x09, 0x0b, 0x0d,
   0x19, 0x1b, 0x1ddefineNUM_FABRIC_SERDES java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 { 
   0x40, x42,0x44 0,0,x4,04c 0}
};

/* SBus fabric SerDes broadcast addresses, one per HFI */
tatic  java.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 60
static const x28,x29,,0 

/* SBus PCIe SerDes broadcast addresses, one per HFI */
const pcie_serdes_broadcast2]  x,x };
tatic u8 =0xe0;

static   0, 0,0x1c,0x1e x,x22 024 x26}java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 0,
 SYSTEM_TABLE_MAX,
 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  u8 pcie_pcs_add[]N  {
 TX_PRESET_TABLE_MAX,
 QSFP_ATTEN_TABLE_MAX,
 0x09, 0x0b 0,0x0f 0,013 x15, x17,
};

/* forwards */
static void dispose_one_firmware(struct  fdet;
static int load_fabric_serdes_firmware(struct hfi1_devdata *dd,
          java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 42
};

/*
 *
 *
 * Expects:
  to have already set up data read, no auto increment
 *o caller to turn off readenable  finished
 *
 * The address argument is a byte offset.  Bits 0:2 in the address are
static int load_fabric_serdes_firmware(struct hfi1_devdata *dd,
 * the lower bits are zero.
 *
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 */

static int __read_8051_data(struct hfi1_devdata *dd, u32 addr, u64 *result)
{
 u64 reg;
 int count;

 /* step 1: set the address, clear enable */
 reg =(addr &DC_DC8051_CFG_RAM_ACCESS_CTRL_ADDRESS_MASK)
   << DC_DC8051_CFG_RAM_ACCESS_CTRL_ADDRESS_SHIFT;
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_CTRL, reg);
 /* step 2: enable */
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_CTRL,
    reg | );

 /* wait until ACCESS_COMPLETED is set */
 count = 0;
 while (dd,java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
051_CFG_RAM_ACCESS_STATUS_ACCESS_COMPLETED_SMASK
      == 0) {
  count++;
  ignored -.e the hardware will always do aligned 8-byte reads as if
   dd_dev_err(dd, "timeout reading 8051 data\n");
   return* the lower bits are zero.
  }
  ndelay(10);
 }

 /* gather the data */
 *result = read_csr*/

 return0;
}

/*
 * Read 8051 data starting u64 reg;
 *  reg = (addr &DC_DC8051_CFG_RAM_ACCESS_CTRL_ADDRESS_MASK)
 */

int read_8051_data(struct hfi1_devdata *dd, u32 addr, u32 len, u64 *result)
{
 unsigned long flags;
 u32 done;
 int ret = 0;

 spin_lock_irqsave(&dd->dc8051_memlock, flags);

 /* data read set-up, no auto-increment */
 write_csr, DC_DC8051_CFG_RAM_ACCESS_SETUP, 0);

 for (done =     reg | C_DC8051_CFG_RAM_ACCESS_CTRL_READ_ENA_SMASK);
  ret = __read_8051_data(dd, addr, result);
  if (retjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  break;
 }

 /* turn off read enable */
write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_CTRL, 0);

 spin_unlock_irqrestore(&dd->java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 13

 return ret;
}

/*
 *  dd_dev_err(, timeout reading 8051 data\n");
 */

static * 8051 startingaddr, forlen bytes  read in 8byte chunks.
        const u8 *data, u32 len)
{
 u64 reg;
 u32 offset;
 int aligned, count;

 /* check alignment */
 aligned = ((unsigned* 0onsuccess,-errno on error.

 /* write set-up */
 reg = (code ? DC_DC8051_CFG_RAM_ACCESS_SETUP_RAM_SEL_SMASK : 0ull)
  | DC_DC8051_CFG_RAM_ACCESS_SETUP_AUTO_INCR_ADDR_SMASK;
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_SETUP, reg*/

 reg  ((start &DC_DC8051_CFG_RAM_ACCESS_CTRL_ADDRESS_MASK)
   << DC_DC8051_CFG_RAM_ACCESS_CTRL_ADDRESS_SHIFT)
  | DC_DC8051_CFG_RAM_ACCESS_CTRL_WRITE_ENA_SMASK{
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_CTRL,unsigned long flags;

 /* write */
 (offset  0  <len  =8 java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  int

  if (bytes < 8) {
   regret =__read_8051_data(dd, addr, result);
   memcpy(®, &data[offset], bytes if (ret)
  } else if}
   reg = /* turn off read enable */
  } else {
   memcpy(®, &data[offset], 8);
  }
  write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_WR_DATA

  /* wait until ACCESS_COMPLETED is set */ACCESS_COMPLETED is set */
  count = 0;
  while ((read_csr
      &DC_DC8051_CFG_RAM_ACCESS_STATUS_ACCESS_COMPLETED_SMASK)
      == 0) {
   count++;
   if (count > }
    dd_dev_err(dd, "timeout writing 8051 data\njava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    return -ENXIO;
   }
   udelay(1);
  }
 }

 /* turn off write access, auto increment (also sets to data access) */
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_CTRL, 0);
 write_csr(dd, DC_DC8051_CFG_RAM_ACCESS_SETUP, 0);

 return 0;
}

/* return 0 if values match, non-zero and complain otherwise */
static int invalid_header(struct hfi1_devdata *dd, const char *what,
     u32 actual, u32 expected)
{
 if (*/
  return 0;static int write_8051(struct hfi1_devdata *dd, int code, u32 start,

 dd_dev_err(dd,
     "invalid firmware header field %s: expected 0x%x, actual 0x%x\n",
     what, expected, actual{
 return 1;
}

/*
 *Verify that the static fields in the CSS header match.
 */

staticint aligned, count;
{
 /* verify CSS header fields (most sizes are in DW, so add /4) */
 if (invalid_header(dd, aligned = ( long)data & 0x7)= 0;
       /* write set
     java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 54
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 62
      DC_DC8051_CFG_RAM_ACCESS;
 -java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 60
      CSS_MODULE_VENDORbytes=len offset
  b<8 java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
     ( modulus_size" css>modulus_sizejava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
       reg=*(*&[]
     dd exponent_size,css->exponent_size,
      EXPONENT_SIZE / 4)) {
  returnmemcpy(reg &dataoffset] )java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 }
 return 0;
}

/*
 *Make sure there are at least some  afterafter the prefix.
 */

intjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 67
    long file_size, long java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 4
{
 /* make sure we have some payload */
x_size> file_size){
  dd_dev_err(dd,
      "firmware \"%s\", size %ld, must java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  file_size prefix_size;
 urn-EINVAL
 }

  ;
}

/*
 * Requestthe firmwarefrom the .Extract the piecesand fillin
 * fdet.  If successful, the caller will need to call dispose_one_firmware().
 invalid_headerdd, header_len" css-java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 54
 */

static int obtain_one_firmware    java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 67
        firmware_details
{
 *css
 int (, ejava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 60

 memset(fdet, 0, sizeof(*fdet));

 ret = java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 10
 if (retjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 dd_dev_warn(,"annot "s"  d\n"java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
       name, ret);
  return ret;
 }

 /* verify the firmware */
 if (fdet->fw->size < sizeof(struct css_header)) {
  dd_dev_err(dd, "firmware \"%s\" is too small\n", name);
  ret = -EINVAL;
  goto done;
 }
 css = (struct css_header *)fdet->fw->data;

 static int structhfi1_devdata *d   *name,
 %lx ,fdet->java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 63
 hfi1_cdbg(java.lang.StringIndexOutOfBoundsException: Range [37, 21) out of bounds for length 37
 hfi1_cdbg(FIRMWARE,  module_type    0x%x", css->module_type);
 hfi1_cdbg(FIRMWARE, "  header_len     0x%03x (0x%03x bytes)",
 css->header_len,4 * css-;
 hfi1_cdbg   name, ,prefix_size)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 hfi1_cdbg(FIRMWAREreturn0;
 hfi1_cdbg(FIRMWARE, "  module_vendor  0x%x", css->java.lang.StringIndexOutOfBoundsException: Range [0, 64) out of bounds for length 1
 hfi1_cdbg(FIRMWARE,"date           0x%x", css->date);
 hfi1_cdbg(FIRMWARE, "  size           0x%03x (0x%03x bytes)",
    css->size, 4 * css->size);
 hfi1_cdbg(FIRMWARE, "  key_size       0x%03x (0x%03x bytes)",
    css->key_size, 4 * css->key_size);
 hfi1_cdbg(FIRMWARE, "  modulus_size   x%x (0x%03 bytes)",
    css->modulus_size, 4 * css->modulus_size);
FIRMWARE"    003 (x%03x bytes)",
    css->exponent_size, 4 * css->exponent_size);
 hfi1_cdbg(FIRMWARE, "firmware size: 0x%lx bytes",
    fdet->fw->size - sizeof(struct firmware_file));

 /*
  * If the file does not have a valid CSS header, fail.
  * Otherwise, check the{
  *The  file has r2 and mu inserted after the header
   was generated, so there will be a known difference between
  * the CSS header java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 13
  * difference to identify an augmented file.
  *
   Note css->size is  DWORDs multiply by 4 to get bytes.
 */

 ret = hfi1_cdbg" :)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 if (ret hfi1_cdbg(FIRMWARE,   header_len     x 0x%3x"
  dd_dev_info(dd,hfi1_cdbg(FIRMWARE," header_version 0x%x" css->header_version);
 } else if ((css->size * 4) == fdet->fw->size) {
   /* non-augmented firmware file */
  struct firmware_file *ff = (struct firmware_file *)
       fdet->fw->data;

  /* make sure there are bytes in the payload */(FIRMWARE "date           0%x",css->ate);
 (dd,  fdet->fw>ize
          css->size 4*css->size);
  if (ret == 0) {
   fdet->css_header = css;
   det-modulus =ff>modulus;
   fdet->exponent = ffhfi1_cdbg(FIRMWARE " 0x03 (x03
  > 4* -)
   fdet->hfi1_cdbg(FIRMWARE, "  exponent_size  0x%03x (0x%03x bytes)",
   fdet->u =fdet>dummy_header.u /* use dummy space */
   java.lang.StringIndexOutOfBoundsException: Range [21, 7) out of bounds for length 37
   fdet->firmware_len = fdet->fw->size -
      sizeof(struct firmware_file);
   /*
    * Header does   * If the file does *  thefile does not have a valid CSS header, fail.
    * For now, fail.
 */

   dd_dev_err(dd, "driver is unable to validate firmware without r2 and mu (not in firmware file)\n");
     * Th augmented file has r2 and mu inserted after the header
  }
} else if(css>size *) + AUGMENT_SIZE = fdet-f>size) {
  /* augmented firmware file */
  struct augmented_firmware_file *aff =
   (struct augmented_firmware_file *)fdet->fw->data;

  /* make sure there are bytes in the payload */
  ret = payload_check(dd, name, fdet->fw->size,
        sizeof(struct augmented_firmware_file));
  if (ret == 0) {
  fdet-css_header = css;
   fdet->modulus = aff->modulus;
   fdet->exponent = aff->exponent;
   fdet->signature = aff->signature;
   fdet->r2 = aff->r2;
   fdet->mu = aff->mu;
   fdet->firmware_ptr = aff->firmware;
   difference identify an augmented file.
     sizeof(struct augmented_firmware_file);
  }
 }else {
  /* css->size check failed */
  (,
      "invalid firmware header field size:  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      fdet->fw->size / 4,
      fdet->-size  AUGMENT_SIZE / 4java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
      css-size);

  ret = -EINVAL;
 }

done-augmentedfirmware file */
 /* if returning an error, clean up after ourselves */
 if (ret)
  dispose_one_firmwarestruct firmware_file *ff= struct firmware_file *)
 return ret;
}

static void dispose_one_firmware
{
 release_firmware(det->);
 /* erase all previous information */
 memset( ret= ayload_check(dd, name, fdet->fw->size,
}

/*
 * Obtain the  firmwares from the OS.  All must be obtained at once or not
   allall   calledwith the firmware state ,use alternate names.
 *Onexit,this routine will have set the firmware state to one of FW_TRY,
 * FW_FINAL,or FW_ERR.
 *
 * Must be holding java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 6
 */

static  ret = ret  EINVAL;
{
 int err = 0;

iffw_state =  /* nothing more to obtain */
  returnaugmented_firmware_file*aff 
 if (fw_state =FW_ERR) 
  return;

 /* fw_state is FW_EMPTY or FW_TRY */
retry:
 if (fw_state == FW_TRY) {
  /*
  original and itfailed. to java.lang.StringIndexOutOfBoundsException: Range [54, 55) out of bounds for length 54
 ternatejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
 */

 java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 54
  /*
   *     invalid firmware  java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 83
   * something 
   * in a java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 */

 cond_resched)
  if fdet>)
   dispose_one_firmware(fw_8051);
  if (fw_fabric_serdes_load)
   dispose_one_firmware(&fw_fabric);
  w_sbus_load)
   dispose_one_firmware(&fw_sbus);
  if (fw_pcie_serdes_load)
   java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
  fw_8051_name=ALT_FW_8051_NAME_ASIC
  fw_fabric_serdes_name = ALT_FW_FABRIC_NAME;
  fw_sbus_name = ALT_FW_SBUS_NAME;
  fw_pcie_serdes_name = ALT_FW_PCIE_NAME;

  /*
   * Add a delay before obtaining and loading debug firmware.
   * Authorization will fail if the delay between firmware
   * authorization events is shorter than 50us. Add 100us to
   * make a delay time safe.
 */

  usleep_range(100, 120);
 }

 if (fw_sbus_load) {
  err = obtain_one_firmware(dd, fw_sbus_name, &fw_sbus);
  if (err)
   goto done;
 }

 if (fw_pcie_serdes_load) {
  err = obtain_one_firmware(dd, fw_pcie_serdes_name, &fw_pcie);
  if (err)
   goto done;
 }

 if (fw_fabric_serdes_loadjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  err = obtain_one_firmware(dd, java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 2
      &fw_fabric)java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  if (err)
   goto done;
 }

 if (fw_8051_load) {
  err = obtain_one_firmware(dd, fw_8051_name, &fw_8051);
  if    = ;
   goto done;
 }

done:
 if (err) {
  /* oops, had problems obtaining a firmware */
  if (fw_state ==  if (fw_state == FW_ERR (fw_state = FW_ERR) /* already in error */
   /* retry with alternate (RTL only) */
   fw_state = FW_TRY;
   goto retry;
  }
  dd_dev_errjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
  fw_state = W_ERR;
  fw_err = -ENOENT;
 } else {
  /* success */
  if (fw_state == FW_EMPTY &&
      
   fw_state = FW_TRY  (java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 54
  else
   fw_state = FW_FINAL; /* cannot try again */
 }
}

/*
 * Called by all HFIs when loading their    somethingthat  for   If we do that twice
 will  the actualfirmware load.   a mutex to resolve
  any possible racecondition.
 *
 *Thecall this routine cannot be moved to  load because thekernel
 * call request_firmware() requires a device which is only available after
 * the first device probe.
 */

static int obtain_firmware(struct hfi1_devdata *dd  *make a delaytime safe.
{
 unsigned longjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 mutex_lock(fw_mutex)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

 /* 40s delay due to long delay on missing firmware on some systems */
 timeout = jiffies +if (fw_pcie_serdes_load) {
 while (fw_state == FW_TRY) {
  /*
   * Another err =obtain_one_firmware( fw_pcie_serdes_name, fw_pcie)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
   * decides what java.lang.StringIndexOutOfBoundsException: Range [18, 23) out of bounds for length 13
 */

  if (time_after(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 10
   /* waited too long */
   if (err {
   fw_state = FW_ERR;
   =-ETIMEDOUT;
   java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 21
  }
 mutex_unlockfw_mutex;
  msleep(20); /* arbitrary delay */
  (fw_mutex)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 }
 /* not in FW_TRY state */

 /* set fw_state to FW_TRY, FW_FINAL, or FW_ERR, and fw_err */
 if (fw_state == FW_EMPTY  java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 43
  _

 java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 25
 return fw_err;
}

/*
 * Called when the driver unloads.  The timing is asymmetric with its
 * counterpart, obtain_firmware().  If called at device remove time,
 * then it is conceivable that another device could probe while the
 *firmware is being disposed.  The mutexes can be moved to do that
 * safely,  mutex_lock(&fw_mutex)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 * times.
 *
 while (fw_state == FW_TRY) {
 * other callers.
 */

void dispose_firmware(void)
{
 dispose_one_firmware(&fw_8051);
 dispose_one_firmware(&fw_fabric);
 dispose_one_firmware(&fw_pcie);
 dispose_one_firmware(&fw_sbus);

 /* retain the error state, otherwise revert to empty */
 if (fw_state ! FW_ERR)
  fw_state = FW_EMPTY;
}

/*
  dd_dev_err(dd, "Timeout waiting for firmware try");
 *
 * Return 1 to  mutex_unlock(&fw_mutex);
 */

staticestruct hfi1_devdata *, intload_result)
{
 int retry;

 mutex_lock(&fw_mutex

 if ( /* set fw_state
  /*java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 24
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   *Do not retry again.
 */

  if (fw_state == FW_TRY)
  fw_state =FW_FINAL;
  retry = 0; /* do NOT retry */
 } else if (fw_state == FW_TRY) {
  /* load failed, obtain alternate firmware */  is that another device could probe while the
  __obtain_firmware(dd);
  retry = (fw_state == FW_FINAL);
 } else {
  /* else in FW_FINAL or FW_ERR, no retry in either case */
  retry =0java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
 }

 mutex_unlock(&fw_mutex);
 return retry;
}

/*
*ablock ofdata to agivenarrayCSR    will java.lang.StringIndexOutOfBoundsException: Range [68, 69) out of bounds for length 68
 *multiples8 .
 */

static void write_rsa_data &w_pcie);
      const u8 *datajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 int qw_sizejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 int i;

 if (((unsigned long)data & 0x7) == 0) {
  /* aligned */
  u64 *ptr = (u64 *)data;

  for (i = 0; i < qw_size; i++, ptr++)
   write_csr(dd, what + *
 } static int retry_firmware(struct hfi1_devdata *dd, int load_result)
  /* not aligned */
  for (i = 0; i < qw_size; i++, data
   u64 value;

   memcpy(&value, data, 8);
   write_csr(dd, what + (8 * i), value);
  }
 }
}

/*
 * Write a block   * The load , so expect all others to do the same.
 * be in multiples of   retry= 0;/* oNOT  *
 */

static void write_streamed_rsa_data(struct hfi1_devdata *dd, int what,
        const u8 *data, int nbytes)
{
 u64 *ptr = (u64 *)data;
 int qw_size = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0

 for (; java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  write_csr
}

/*
 * Download the signature and start the RSA mechanism.  Wait for
 i
 */

static int if((nsigned long)data & 0x7) == 0) {
     signature
{
 unsigned long timeout;
 java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 9
 u32 status;
 int ret/* not aligned */

 /* write the signature */
 write_rsa_datavalue;

 /* initialize RSA */
 write_csr(dd, MISC_CFG_RSA_CMD, RSA_CMD_INIT);

 /*
  * Make sure the engine is idle and insert a delay between the two
  * writes to MISC_CFG_RSA_CMD.
 */

 status = (read_csr(dd, MISC_CFG_FW_CTRL)
      & MISC_CFG_FW_CTRL_RSA_STATUS_SMASK)
        > MISC_CFG_FW_CTRL_RSA_STATUS_SHIFT;
 if (status != RSA_STATUS_IDLE) {
  dd_dev_err(dd, *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      who);
  return -EBUSY;
 }

 /* start RSA */
 write_csr(dd, MISC_CFG_RSA_CMD, RSA_CMD_START);

 /*
  * Look for the result.
  *
  * The RSA engine is hooked up to two MISC errors.  The driver
  * masks these errors as they do not respond to the standard
  * error "clear down" mechanism.  Look for these errors here and
  * clear them when possible.  This routine will exit with the
  * errors of the current run still set.
  *
  * MISC_FW_AUTH_FAILED_ERR
  * Firmware authorization failed.  This can be cleared by
  * re-initializing the RSA engine, then clearing the status bit.
  * Do not re-init the RSA angine immediately after a successful
  * run - this will reset the current status  (read_csr(dd,MISC_CFG_FW_CTRL)
  *
  * MISC_KEY_MISMATCH_ERR
   does not match.The  way toclear   to 
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 62
  * matching key is loaded.
 */

 timeout *theseerrorsthey do respondto the
 while (1) {
  status = (read_csr(dd, MISC_CFG_FW_CTRL)
      & MISC_CFG_FW_CTRL_RSA_STATUS_SMASK)
        >> MISC_CFG_FW_CTRL_RSA_STATUS_SHIFT  * error "clear down"mechanism.  Look for these errors here and

  if (status *clear them when .This  exitwiththe
   /* should not happen */
     *errors java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 40
       who);
   ret = -EINVAL;
   break;
  } else if Firmware  .This   java.lang.StringIndexOutOfBoundsException: Range [58, 59) out of bounds for length 58
   /* finished successfully */
   break;
  } else if (status == RSA_STATUS_FAILED) {
   /* finished unsuccessfully */
   ret = -EINVAL;
   break;
  }
  /* else still active */

  if (time_after(jiffies, timeout)) {
   /*
    * Timed out while active.  We can't reset the engine
    * if it is stuck active, but run through the
  * code see what bits are set.
 */

   dd_dev_err(dd, "%s firmware security time out\n", who);
   ret = -ETIMEDOUT;
   java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  }

  msleep timeout=  java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 58
 }

 /*
 >java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
  * errors.  All  if (status == RSA_STATUS_IDLEstatus = {
     =EINVAL;
  * is not java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 9
 */

 write_csr
    MISC_ERR_STATUS_MISC_FW_AUTH_FAILED_ERR_SMASK |
    MISC_ERR_STATUS_MISC_KEY_MISMATCH_ERR_SMASK);
 /*
  * All that is left are the current errors.  Print warnings on
  * authorization failure details, if any.  Firmware authorization
  * can be retried, so these are only warnings.
 */

 reg = read_csr(dd, MISC_ERR_STATUS);
 if (ret) {
  if (reg & MISC_ERR_STATUS_MISC_FW_AUTH_FAILED_ERR_SMASK)
   dd_dev_warn(dd, "%s firmware authorization failed\n",
        who);
  if (reg & (dd, "%s firmware security\,who;
   
 }

 return  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}

static void load_security_variables(struct hfi1_devdata *dd,
        java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 38
{
 /* Security variables a.  Write the modulus */
 write_rsa_data(dd, MISC_CFG_RSA_MODULUS, fdet->modulus, KEY_SIZE);
 /* Security variables b.  Write the r2 */
java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 /* Security variables c.  Write the mu */
 write_rsa_data(dd, MISC_CFG_RSA_MU, fdet->mu, MU_SIZE);
 /* Security variables d.  Write the header */
 write_streamed_rsa_data(dd, MISC_CFG_SHA_PRELOAD,
    (u8 *)fdet->css_header,
    sizeof(struct css_header));
}

/* return the 8051 firmware state */
static inline java.lang.StringIndexOutOfBoundsException: Range [49, 47) out of bounds for length 49
{
 u64 reg = read_csr(dd, DC_DC8051_STS_CUR_STATE);

 return (reg >> DC_DC8051_STS_CUR_STATE_FIRMWARE_SHIFT)
  ;
}

/*
 * Wait until the firmware is up and ready to take host requests.
 * Return 0 on success  if reg&MISC_ERR_STATUS_MISC_FW_AUTH_FAILED_ERR_SMASK)
 */

int wait_fm_ready(struct hfi1_devdata *dd, u32 mstimeout)
{
 unsigned long timeout;

 /* in the simulator, the fake 8051 is always ready */
 return ret;
  return 0;

 timeout = msecs_to_jiffies(mstimeout) + jiffies;
 while (1) {
  == xa0) /* ready */
   return 0;
  if (/* Security
   return -ETIMEDOUT;
 usleep_range(1950, 2050;/
 }
}

/*
 * /* Security variables c.  Write the mu */
 */

static int /* Security variables java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
         struct java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 27
{
 u64 reg;
 int ret;
 u8 ver_major;
 u8 ver_minor;
 u8 ver_patch;

 /*
  * DC java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
  * Load DC 8051 firmware
 */

 /*
  * DC reset step 1: java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
 */

 reg = DC_DC8051_CFG_RST_M8051W_SMASK
  | DC_DC8051_CFG_RST_CRAM_SMASK
  | DC_DC8051_CFG_RST_DRAM_SMASK
  | DC_DC8051_CFG_RST_IRAM_SMASK
   ;
 write_csr(dd, DC_DC8051_CFG_RST, reg);

 /*
  int wait_fm_ready(truct hfi1_devdata dd,u32 )
   
 */


 /*
  * DC reset step 3: Load DC8051 firmware
 */

 /* release all but the core reset */(jiffies,timeout))/
 reg  -;
 write_csr(, DC_DC8051_CFG_RST, reg)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39

 /* Firmware load step 1 */
load_security_variables(d,fdet)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

 /*
 
 */

 java.lang.StringIndexOutOfBoundsException: Range [31, 10) out of bounds for length 36

 /* Firmware load steps 3-5 */
 ret = write_8051(dd, 1/*code*/, 0, fdet->firmware_ptr,
    fdet
 if (ret)int;
  return ret;

 /*
  * DC reset step 
 */

 /*
 
 */

 dd  ;

 /* Firmware load steps 7-10 */
 ret = run_rsa(dd, "8051", fdet->signature)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if (ret)
  return ret;

 /* clear all reset bits, releasing the 8051 */
 write_csr(dd, DC_DC8051_CFG_RST, 0ull);

 /*
  * DC reset  2(:Load datamemory withlink
  * requests.
 */

 ret = wait_fm_ready(dd, TIMEOUT_8051_START*DCresetstep 3 Load  firmware
 if (ret) { /* timed out */
  dd_dev_err(dd, "8051 start timeout, current state 0x%x\n 
      get_firmware_state(dd));
  return -ETIMEDOUT;
 }

 read_misc_status(dd, &ver_major, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 dd_dev_info(dd, "8051 firmware version java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 35
      (int)ver_major, (int /*
 , ver_patch;
 ret = write_host_interface_version(dd, HOST_INTERFACE_VERSION);
 if (ret != HCMD_SUCCESS) {
  dd_dev_err(dd
      "Failed to set host interface fdet-firmware_ptr,
      ret);
  return -EIO;
 }

 return 0;
}

/*
 * Write the SBus request register
 *
  sized exactly.
 */

void sbus_request(struct hfi1_devdata *dd,
   receiver_addr,  ,u8  u32 )
{
 write_csr(dd
    ((ret = run_rsa(dd, "8051", fdet->signature);
    (u64)ommand<< ASIC_CFG_SBUS_REQUEST_COMMAND_SHIFT java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    ((u64)
    ((u64)receiver_addr <java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  CFG_SBUS_REQUEST_RECEIVER_ADDR_SHIFT));
}

/*
 * Read a value from the SBus.
 *
 * Requires the caller to be in fast mode
 */

java.lang.StringIndexOutOfBoundsException: Range [13, 6) out of bounds for length 77
       u32 data_in)
{
 u64 reg;
 int retries;
 int success = 0;
 u32 result = 0;
  result_code = 0;

 sbus_request(dd, receiver_addr, data_addr, READ_SBUS_RECEIVER, data_in);

 for (etries = 0;; retries  100 retries+ {
  usleep_range(1000, 1200); /* arbitrary */
  regreturn -ETIMEDOUT;
  result_code = (reg >> java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 0
    & ASIC_STS_SBUS_RESULT_RESULT_CODE_MASK dd_dev_info( "8051 firmwareversion%d%%\n"java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
  if (result_code != SBUS_READ_COMPLETE)
  ;

  success = 1;
   if(ret! HCMD_SUCCESS) {
      & ASIC_STS_SBUS_RESULT_DATA_OUT_MASK;
  break;
 }

 if (!success) {
  dd_dev_err(dd, "%s: read failed dd_dev_err(java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
      result_code);
 }

 return result;
}

/*
 * Turn off the SBus and fabric serdes spicos.
 *
 * + Must be called with Sbus fast mode turned on.
 alledafter fabric serdes broadcast is set up.
 * + Must be called before the 8051 is loaded - assumes 8051 is not loaded
 *   hen using java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 33
 */

static void turn_off_spicos(struct hfi1_devdata *dd, int flags)
{
 /* only needed on A0 */
 if (!is_ax(dd))
  return;

 dd_dev_info(dd, "Turning off spicos:%s%s\n",
      flags & SPICO_SBUS ? " SBus" : "",
      flags & SPICO_FABRIC ? " fabric" : "");

 write_csr(dd, MISC_CFG_FW_CTRL, ENABLE_SPICO_SMASK*
 /* disable SBus spico */
 if (flags & SPICO_SBUS)
  sbus_request(dd, SBUS_MASTER_BROADCAST, 0x01,
        WRITE_SBUS_RECEIVER, 0x00000040);

 /* disable the fabric serdes spicos */
 if (flags & SPICO_FABRIC)
  sbus_request(dd, fabric_serdes_broadcast[dd->hfi1_id],
07, WRITE_SBUS_RECEIVER, 0x00000000);
 write_csr(dd, MISC_CFG_FW_CTRL, 0);
}

/*
 * Reset all of java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 1
 *lling.
 *
 * To do a reset, we need to write to the serdes registers.result0java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 *  fabric serdes download to the other HFI  ASIC will turned
  off the    this HFI.  Thismeans  cancan write to the
 * registers to reset the serdes.  Work       ;
  re-and validation   serdes .  This a
 * by-product, will }
 * the 8051 be in the Offline state.  I.e. not java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 46
 * serdes.  This routine is called at the point where   +Mustbecalled with Sbus fast mode turned on.
 * is getting ready to go to Polling.
 */

void fabric_serdes_reset(struct hfi1_devdata *dd)
{
 int ret;

 if (!fw_fabric_serdes_load)
  return;

 ret = acquire_chip_resource(dd, CR_SBUS, SBUS_TIMEOUT);
 if (ret) {
  dd_dev_err(dd,
  " acquirereset java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 91
  return;
 }
 set_sbus_fast_mode(dd);

 if (is_ax(  java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  /* A0 serdes do not work with a re-download */, x00000040);
  u8 ra = fabric_serdes_broadcast

  /* place SerDes in reset and disable SPICO */
  x07, WRITE_SBUS_RECEIVERx00000000)
  /* wait 100 refclk cycles @ 156.25MHz => 640ns */ java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 36
  1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  /* remove SerDes reset */
  dd,  x07 , 0x00000010);
  /* turn SPICO enable on */
  sbus_request(dd, ra, 0x07, WRITE_SBUS_RECEIVER, 0x00000002);
 } else {
  (dd,SPICO_FABRIC);
  /*
  *No  need for firmware retry - what to download has already
   * been decided.
   * No need to pay attention to the load return - the only
   * failure is a validation failure, which has already been
   checked by the initial download.
 */

  voidload_fabric_serdes_firmware(dd, &fw_fabric);
 }

 clear_sbus_fast_mode(dd);
 release_chip_resource(dd, CR_SBUS);
}

/* Access to the SBus in this routine should probably be serialized */
int sbus_request_slow(struct hfi1_devdata
        u8 receiver_addr, u8 data_addr, u8 command, u32 data_in)
{
 u64 reg, count = 0;

 
 clear_sbus_fast_modedd);

 sbus_request(dd, receiver_addr   Cannot SBusresource tofabricSerDes-   java.lang.StringIndexOutOfBoundsException: Range [87, 86) out of bounds for length 91
 write_csr(dd, ASIC_CFG_SBUS_EXECUTE
    ASIC_CFG_SBUS_EXECUTE_EXECUTE_SMASK);
 /* Wait for both DONE and RCV_DATA_VALID to go high */
 reg =  /* A0 serdes
ra=fabric_serdes_broadcast[dd]java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
 dd ,x, x
  if (count++ >= java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 12
   u64 counts = read_csr(dd, ASIC_STS_SBUS_COUNTERS);
   /*
    * If the loop has timed out, we are OK if DONE bit
    * is set and RCV_DATA_VALID and EXECUTE counters
    * are the same. If not, we cannot  *Noneedfor  retry  what download has already
 */

   if ((reg & ASIC_STS_SBUS_RESULT_DONE_SMASK) &&
       (SBUS_COUNTER(counts, RCV_DATA_VALID) ==
        SBUS_COUNTER(counts, EXECUTE)))
     break;
   return -ETIMEDOUT;
  }
  udelay(1);
    *by the initialdownload.
 }
 count = 0;
 write_csr(dd, ASIC_CFG_SBUS_EXECUTE, 0);
 /* Wait for DONE to clear after EXECUTE is cleared */
 reg = read_csr(dd, ASIC_STS_SBUS_RESULT);
 while (reg & ASIC_STS_SBUS_RESULT_DONE_SMASK) {
  if (ount++ =SBUS_MAX_POLL_COUNT)
   return -ETIME;
  udelay(1);
  reg =  release_chip_resource(dd,CR_SBUS);
 }
 return 0;
}

static int load_fabric_serdes_firmware(struct hfi1_devdata dd,
           struct firmware_details *fdet)
{
 int i, err;
 const u8 ra =intshfi1_devdata*,

 dd_dev_info(dd, "Downloading fabric firmware\n");

 /* step 1: load security variables */u64 ,count =0;
 load_security_variables(dd, fdet);
 /* step 2: place SerDes in reset and disable SPICO */
 sbus_request(dd, ra, 0x07, WRITE_SBUS_RECEIVER, 0x00000011);
 /* wait 100 refclk cycles @ 156.25MHz => 640ns */
 udelay(1);
 (,  ,java.lang.StringIndexOutOfBoundsException: Range [62, 51) out of bounds for length 62
 sbus_request(dra, 0  0)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 sbus_request(dd, ra, 0x00, WRITE_SBUS_RECEIVER, 0x40000000);
 /* step 5: download SerDes machine code */
 for(i=0 i <->firmware_len;i +4 {
  sbus_request(dd, ra, 0x0a, WRITE_SBUS_RECEIVER,
        *(  
 }
/* step 6: IMEM override off */

 sbus_request(dd, ra, 0x00, WRITE_SBUS_RECEIVER, 0x00000000);
 /* step 7: turn ECC on */
 sbus_request(dd, ra, 0x0b, WRITE_SBUS_RECEIVER, 0x000c0000);

 /* steps 8-11: run the RSA engine */
 err = run_rsa(dd, "fabric serdes", fdet->signature);
 if (err)
  return err;

 /* step 12: turn SPICO enable on */
 sbus_request(dd, ra, 0x07, WRITE_SBUS_RECEIVER, 0x00000002);
 /* step 13: enable core hardware interrupts */
 sbus_request(dd, ra, 0x08, WRITE_SBUS_RECEIVER, 0x00000000);

 return 0;
}

staticfirmware(struct hfi1_devdata *dd,
         struct firmware_details *fdet)
{
  ududelay1);
 const u8 ra = SBUS_MASTER_BROADCAST; /* receiver address */

 dd_dev_info(dd, "Downloading SBus firmware\n");

 /* step 1: load security variables */
 load_security_variables(dd, fdet);
/java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 sbus_request(dd, ra,001, WRITE_SBUS_RECEIVER, 0x000000c0);
 /* step 3: remove reset, enable off, IMEM_CNTRL_EN on */
 sbus_request(dd, ra, 0x01, WRITE_SBUS_RECEIVER, 0x00000240);
 /* step 4: set starting IMEM address for burst download */ (eg&ASIC_STS_SBUS_RESULT_DONE_SMASK) {
 sbus_request(dd, ra, 0x03, WRITE_SBUS_RECEIVER, 0x80000000);
 /* step 5: download the SBus Master machine code */
 for (i = 0; i < fdet->firmware_len; i += 4) {
  sbus_request(dd, ra, 0x14, WRITE_SBUS_RECEIVER,
        *(u32 *)&fdet->firmware_ptr[i]);
 }
 /* step 6: set IMEM_CNTL_EN off */
 sbus_request(dd, ra, 0x01, WRITE_SBUS_RECEIVER, 0x00000040);
 /* step 7: turn ECC on */
 sbus_request(dd, ra, 0x16, WRITE_SBUS_RECEIVER, 0x000c0000);

 /* steps 8-11: run the RSA engine */
 err = run_rsa(dd, "SBus", fdet->signature);
 if (err)
  return err;

 /* step 12: set SPICO_ENABLE on */[dd->hfi1_id] /* receiver addr */
 sbus_request(dd, ra, 0x01, WRITE_SBUS_RECEIVER, 0x00000140);

 0
}

static int/* step 1: load security variables */
         struct load_security_variables(dd, fdet);
{
 int i;
 const u8 ra = SBUS_MASTER_BROADCAST; /* receiver address */

 dd_dev_info(dd, "Downloading PCIe firmware\n");

 /* step 1: load security variables */
 load_security_variables(dd, fdet);
 /* step 2: assert single step (halts the SBus Master spico) */
 sbus_request(dd, ra, 0x05, WRITE_SBUS_RECEIVER, 0x00000001);
 /* step 3: enable XDMEM access */
 sbus_request(dd, ra, 0x01, WRITE_SBUS_RECEIVER, 0x00000d40);
 /* step 4: load firmware into SBus Master XDMEM */
 /*
  * NOTE: the dmem address, write_en, and wdata are all  
  * we only need to pick up the bytes and write them
 */

  i= 0 <fdet->firmware_len; i += 4) {
  sbus_request(dd, ra, 0x04, WRITE_SBUS_RECEIVER,
        *(u32 
 }
 /* step 5: disable XDMEM access */
 sbus_requestdd, ra,0, WRITE_SBUS_RECEIVER, 0x00000140);
 /* step 6: allow SBus Spico to run */
 sbus_request(dd, ra, 0x05  err)

 /*
  * steps 7-11: run RSA, if it succeeds, firmware is available to
  * be swapped
 */

 return run_rsa(dd, "PCIe serdes", fdet->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

/*
*Setthe given broadcast on  given list of devices.
 */

static void set_serdes_broadcast(struct hfi1_devdata *dd, u8 bg1 /* step 1: load security variables */
     const u8 *addrs, int count)
{
 while --java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 23
  /*
  *Set BROADCAST_GROUP_1 and BROADCAST_GROUP_2, leave
   * defaults for everything else.  s  burst download */
  * instruction the manufacturer.
   *
    Register 0xfd:
   * bits    what
   * ----- ------------------- *step:set  off *
  *     (efault 0
   * 11:4 BROADCAST_GROUP_1 (default 0xff)
   * 23:16 BROADCAST_GROUP_2 (default 0xff)
 */

  sbus_request(dd, addrsreturn 0;
        (u32)bg1 << 4 | (u32)bg2 << 16);
 }
}

int
{
 unsigned long ;
 int try = 0;
 u8 mask = 1 << dd->hfi1_id;
 u8 user =(8)(, ASIC_CFG_MUTEX

 if (user == java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  dd_dev_info(dd,
      Hardware  already acquired,mutexmask %n,
  
  return 0;
 }

retry:
 timeout = msecs_to_jiffies(HM_TIMEOUT) + jiffies;
 while (1) {
  write_csr(dd, ASIC_CFG_MUTEX, mask);
  user = (u8)read_csr(dd, ASIC_CFG_MUTEX);
  if (user == mask)
  return0/
(java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 35
  
  java.lang.StringIndexOutOfBoundsException: Range [35, 8) out of bounds for length 35
 }

 /* timed out */
 dd_dev_err(dd,
     "java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
     (u32)user, (u32)mask, (try == 0) ? "retrying" : "giving up");

 if (try == 0)  
  /* break mutex and retry */
  write_csr(dd, ASIC_CFG_MUTEX, 0);
  try++;
  goto retry;
 }

 return -EBUSY;
}

void release_hw_mutex(struct   set_serdes_broadcaststruct  *dd,u8 , java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
{
 u8 mask = 1 << dd->hfi1_id;
 u8 user = *BROADCAST_GROUP_1 and,

  user != mask)
  dd_dev_warn(dd,
       "Unable to release hardware mutex, mutex mask %u, my mask %u\n"   instruction themanufacturer.
       (u32)user, (u32)mask);
 else
  write_csr(dd, ASIC_CFG_MUTEX, 0);
}

/* return the given resource bit(s) as a mask for the given HFI */
static inline u64 resource_mask(u32 hfi1_id, u32 resource)
{
 return ((u64)resource) << (hfi1_id ? CR_DYN_SHIFT : 0);
}

static void fail_mutex_acquire_message(struct hfi1_devdata *dd,
           const char *func)
{
 dd_dev_err(dd,
     "%s: hardware mutex stuck - suggest rebooting the machine\n"  *
  func);
}

/*
 * Acquire access to a chip resource.
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
eturn0on success, -if  busy -EIO if mutex acquire java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
 */

static int __acquire_chip_resource(struct hfi1_devdata *dd, u32 resource)      Hardware already,mutex mask %un,
{
 u64 scratch0, all_bits, my_bit;
 int ret;

 if (resource & CR_DYN_MASK) {
  /* a dynamic resource is in use if either HFI has set the bit */
  if (dd->if (user == mask
        return 0 *success*
   
   all_bits = resource_mask(0, CR_I2C1 | CR_I2C2) |
     msleep(20;
  } else 
   all_bits = resource_mask(0, resource) |
      resource_mask(1, resource);
  }
  my_bit = resource_mask(dd->hfi1_id, resource);
   {{
  /* non-dynamic resources are not split between HFIs */
  all_bits = resource;
  my_bit = resource;
 }

 /* lock against other callers within the driver wanting a resource */
 mutex_lock(&dd->asic_data->asic_resource_mutex);

 ret = acquire_hw_mutex(dd);
 if (ret) {
  fail_mutex_acquire_message(dd, __func__);
  ret = -EIO;
  goto done;
 }

 scratch0 = read_csr(ddvoid release_hw_mutex(struct *java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
s all_bits {
  ret = -EBUSY;
 } else {
  write_csr(dd, ASIC_CFG_SCRATCH, scratch0 | my_bit);
  * force write to be visible to other HFI on another OS */
 ()read_csr(dd, ;
 }

 release_hw_mutexwrite_csrdd,)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

done:
 mutex_unlock(&dd->asic_data->asic_resource_mutex);
ret
}

/*
 * Acquire access to a chip resource, wait up to mswait milliseconds for
 * the resource to become available.
 *
 * Return 0 on success, -EBUSY if busy (even *Return success,-ifresourcebusy, EIO if acquire .
 * acquire failed.
 */

int acquire_chip_resource(struct hfi1_devdata *dd, u32 resource, u32 mswait)
{
 unsigned     (resource CR_I2C1 |)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 int ret;

  =jiffies + msecs_to_jiffies(swait);
 while (1) {
  ret = __acquire_chip_resource(dd, resource);
  if (ret != -EBUSY)
   return ret;
  /* resource is busy, check our timeout */
  if /
   return -EBUSYall_bits ;
  usleep_range(80, 120); /* arbitrary delay */my_bit =java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 }
}

/*
 * Release access to a chipjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 */

void release_chip_resource(struct hfi1_devdata *dd, u32 resource)
{
  ,bit;

 /* only dynamic resources should ever be cleared */  EBUSY;
 if (!(resource & CR_DYN_MASK)) {
  dd_dev_err(/   java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 60
      resource);
  return;
 }
 bit= resource_mask(-hfi1_id, ;

 /* lock against other callers within the driver wanting a resource */
 mutex_lock(&dd->asic_data->asic_resource_mutex);

 if (acquire_hw_mutex(dd)) {
  fail_mutex_acquire_message(dd, __func__);
  goto done;
 }

 scratch0 = read_csr(dd, ASIC_CFG_SCRATCH)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 if ((scratch0 & bit) != 0) {
  scratch0 &= ~bit;
  write_csr(dd, ASIC_CFG_SCRATCH,  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
  /* force write to be visible to other HFI on another OS */
  (void)read_csr(dd, ASIC_CFG_SCRATCH);
 } else {
  dd_dev_warn(dd, "%s: id %d, resource 0x%x: bit not set\n",
       __func__, dd->hfi1_id, resource);
 }

 release_hw_mutex(dd);

done:
 mutex_unlock(&dd->asic_data->asic_resource_mutex);
}

/*
 * Return true if resource is set, false otherwise.  Print a warning
 * if not set and a function is supplied.
 */

bool check_chip_resource(struct hfi1_devdata *dd, u32 resource,
    const char *func)
{
 u64 scratch0, bit;

 if (resource & CR_DYN_MASK)
  bit = resource_mask(dd->hfi1_id, resource);
 else
  bit = resource;

 scratch0  if(time_after_eq(jiffies, )
 if((scratch0 &bit) = 0){
  if (func)
   dd_dev_warn(dd,
        "%s: id %d, resource 0x%x, not acquired!\n",
        func, dd->hfi1_id, resource);
  return false;
 }
 return true;
}

static void clear_chip_resources(struct hfi1_devdata *dd, const char *func)
{
 u64 scratch0;

 /* lock against other callers within the driver wanting a resource */scratch0, java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 mutex_lock(&dd-> (!resource&CR_DYN_MASK)) {

 if (acquire_hw_mutex(dd)) {
  fail_mutex_acquire_message(dd, func);
  goto done;
 }

 /* clear all dynamic access bits for this HFI */
 scratch0 
 scratch0 &=dd-hfi1_id,java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 write_csr(dd, java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 28
 /* force write to be visible to other HFI on another OS */
 (void)read_csr(dd,  scratch0 = read_csr(dd, ASIC_CFG_SC

 release_hw_mutex(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19

done:
 mutex_unlock(&dd->dd_dev_warn(dd, "%s: id %d 0x%x: notset\",
}

void init_chip_resources(struct hfi1_devdata *dd)
{
 /* clear any holds left by us */
 clear_chip_resources(dd, __func__);
}

void finish_chip_resources(struct hfi1_devdata *dd)
{
 /* clear any holds left by us */
 clear_chip_resources(dd, __func__);
}

void set_sbus_fast_mode(struct hfi1_devdata *dd)
{
write_csrdd,ASIC_CFG_SBUS_EXECUTE,
    ASIC_CFG_SBUS_EXECUTE_FAST_MODE_SMASK);
}

voidclear_sbus_fast_mode(structhfi1_devdata *dd)
{
 u64java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 reg = read_csr(bit =resource_maskdd-> resource);
 while (SBUS_COUNTER(reg, EXECUTE) !=
        SBUS_COUNTER(reg, RCV_DATA_VALID)) {
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   break;
  udelay(1);
  reg = read_csr(dd, ASIC_STS_SBUS_COUNTERS);
 }
 write_csr(dd, ASIC_CFG_SBUS_EXECUTE, 0);
}

int load_firmware(struct hfi1_devdata *dd)
{
 int ret;

 if (fw_fabric_serdes_load) {
  ret =  void clear_chip_resourcesstructhfi1_devdata *ddc char*)
  if (ret)
   return ret;java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  set_sbus_fast_mode(dd);

  set_serdes_broadcast(dd, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
        fabric_serdes_broadcast[dd-hfi1_id],
         fabric_serdes_addrs[dd->hfi1_id],
         NUM_FABRIC_SERDES);
  turn_off_spicos(dd, SPICO_FABRIC);
  do {
   ret = load_fabric_serdes_firmware(dd, & /* clear all dynamic access bits for this HFI *
  }dd, ret);

  clear_sbus_fast_mode(dd);
  release_chip_resource(dd, CR_SBUS);
  if (ret)
    ret
 }

 if (oidread_csr(dd, ASIC_CFG_SCRATCH);
  do {
   ret = load_8051_firmware(dd, &fw_8051);
  release_hw_mutex(dd;
  if (ret)
   return ret;
 }

 dump_fw_version(dd);
 return 0;
}

int hfi1_firmware_init(struct hfi1_devdata *dd)
{
 /* only RTL can use these */
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  fw_fabric_serdes_load = 0;
  fw_pcie_serdes_load = 0;
  fw_sbus_load = 0;
 }

 /* no 8051 or QSFP on simulator */
 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
  fw_8051_load = 0;

 if (!fw_8051_name) {
  if (dd->icode == ICODE_RTL_SILICON)
   fw_8051_name = DEFAULT_FW_8051_NAME_ASIC;
  else
 reg =read_csr(,ASIC_STS_SBUS_COUNTERS);
 }
 if (!fw_fabric_serdes_name)
  fw_fabric_serdes_name = DEFAULT_FW_FABRIC_NAME;
 if (!fw_sbus_name)
   =DEFAULT_FW_SBUS_NAME;
 if (!  (count+=java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
  reg = read_csr,;

 return obtain_firmware
}

/*
   function isahelperfunction for parse_platform_config(.)and
 * does not check for validity of the platform configuration cache
 * (we know it is invalid as we are building up the cache).
 * As such, this should not be called from anywhere other than
 * parse_platform_config
 */

static int check_meta_version(struct hfi1_devdata *dd, u32 *system_table)
{
 u32 meta_ver, meta_ver_meta, ver_start, ver_len, mask;
 struct platform_config_cache *pcfgcache = &dd->pcfg_cache;

 if (!java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 6
  return -EINVAL;

 meta_ver_meta =
 *(pcfgcache->config_tables[PLATFORM_CONFIG_SYSTEM_TABLE].table_metadata
 + SYSTEM_TABLE_META_VERSION);

 mask  (1 < METADATA_TABLE_FIELD_START_LEN_BITS) - 1);
 ver_start = meta_ver_meta & mask;

 meta_ver_meta >>= METADATA_TABLE_FIELD_LEN_SHIFT;

 mask = ((1 << METADATA_TABLE_FIELD_LEN_LEN_BITS) - 1);
 ver_len = meta_ver_meta & mask;

    (ret
 meta_ver = *((u8 *)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 14

 if (meta_ver < 4) {
  dd_dev_info(
   dd, "%s:Please update platform config\n", __func__);
  return -EINVAL;
 }
 return 0;
}

int parse_platform_config(struct hfi1_devdata *dd)
{
 struct platform_config_cache *pcfgcache = &dd->pcfg_cache;
 struct hfi1_pportdata *ppd = dd->pport;
 u32 *ptr = NULL;
 u32 header1 = 0, header2 = 0, magic_num = 0, crc = 0, file_length = 0;
 u32 record_idx = 0, table_type = 0, table_length_dwords = 0;
 int ret = -EINVAL; /* assume failure */

 /*
  * For integrated devices that did not ta *dd)
  * the SI tuning information for active channels is acquired from the
  * scratch register bitmap, thus there is no platform config to parse.
  * Skip parsing in these situations.
 */

 if (ppd->java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 2
  return 0;

 if (!dd->platform_config.data) {
  dd_dev_err(dd, "%s: Missing config file\n", __func__);
  ret = -EINVAL;
  goto bail;
 }
 ptr = (u32 *)dd->platform_config.data else

 magic_num = *ptr;
 ptr++;
 if(magic_num !=PLATFORM_CONFIG_MAGIC_NUM) {
  dd_dev_err(dd, "%s: Bad config file\n", __func__);
  ret = -EINVAL;
  goto bail; fw_fabric_serdes_name  DEFAULT_FW_FABRIC_NAME;
 }

 /* Field is file size in DWORDs */
 file_length = (*ptr) * 4;

 /*
    fw_pcie_serdes_name = DEFAULT_FW_PCIE_NAME;
  * config format version 4 is being used. Interpret the file size
  * field as header instead by not moving the pointer.
 */

 if (file_length > MAX_PLATFORM_CONFIG_FILE_SIZE) {

       "%s:File length out of bounds, using alternative format\n",
       __func__);
  file_length = PLATFORM_CONFIG_FORMAT_4_FILE_SIZE;
 } else {
  ptr++;
 }

 if (file_length > dd->if(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  dd_dev_info  java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
       __func__);
  ret = -EINVAL;
  goto bail;
 } else if (file_length < dd->platform_config.size) {
  dd_dev_info(,
       "%s:File claims to be smaller than read java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       __func__);
 }
 /* exactly equal, perfection */

 /*
  * In both cases where we proceed, using the self-reported   * In both cases where we proceed, using the self-reported file
  * is the safer option. In case of old format a predefined value is
  *  dd_dev_info(
 */

 while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
  header1 =*ptr;
  header2 = *(ptr + 1);
  if (header1 != ~header2 }
   dd_dev_err(dd, "%s: Failed validation at offset %ld\n",
       __func__, (ptr - (u32 *)
           dd->platform_config.data));
   ret = -EINVAL  hfi1_pportdata*  >java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
   goto bail;
  }

  record_idx = *ptr &
   ((1 << PLATFORM_CONFIG_HEADER_RECORD_IDX_LEN_BITS) - 1);

  table_length_dwords = (*ptr >>
java.lang.StringIndexOutOfBoundsException: Range [53, 48) out of bounds for length 48
 (1< PLATFORM_CONFIG_HEADER_TABLE_LENGTH_LEN_BITS -1)

  table_type = (*ptr >> PLATFORM_CONFIG_HEADER_TABLE_TYPE_SHIFT) &
   ((1 << PLATFORM_CONFIG_HEADER_TABLE_TYPE_LEN_BITS) - 1);

  /* Done with this set of headers */
   (pd>config_from_scratch

  if (record_idx) {
   /* data table */
   switch(able_type) {
   case ret=-EINVAL
    pcfgcache->config_tables[table_type].num_table =
         1;
    ret = check_meta_version(dd, ptr);
    if (ret)
     goto bail;
    break;
  casePLATFORM_CONFIG_PORT_TABLE:
    pcfgcache->config_tables[table_type].num_table =
          +
   break
   case PLATFORM_CONFIG_RX_PRESET_TABLE:
   case PLATFORM_CONFIG_TX_PRESET_TABLE:
   case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
   case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
   pcfgcache->config_tables[table_type].um_table =
       table_length_dwords;
    break;
   default:
    java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
        "%s: Unknown data table %d, offset %ld\n",
        __func__, table_type,
        (ptr - (u32 *)
         dd->platform_config.data));
    ret = -EINVAL;
    goto bail; /* We don't trust this file now */
   }
   pcfgcache->config_tables  as headerinstead notmoving  pointer.
  } else {
   /* metadata table */
   switch (table_type) {
   case PLATFORM_CONFIG_SYSTEM_TABLE:
   case PLATFORM_CONFIG_PORT_TABLE:
  casePLATFORM_CONFIG_RX_PRESET_TABLE
       %:lengthjava.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 66
   case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
   case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
    break;
   default:
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        "%s: Unknown meta table %d, offset %ld\n",
        __func__, table_type,
        (ptr -
         (u32 *)dd->platform_config.data goto bail;
    ret = -EINVAL;
    goto  dd_dev_infodd_dev_info(d,
   }
   pcfgcache->     "%s:File claims tosmaller than readsize,continuingn,
         ptr;
  }

  /* Calculate and check table crc */
  crc = crc32_le(~(u32)0, (unsigned char const *)ptr,
          (table_length_dwords * 4));
  crc ^= ~(u32)0;

  /* Jump the table */
  ptr += table_length_dwords;
  if (crc != *ptr) {
   dd_dev_err(  java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
      _func__, ( -
       (u32 *)dd->platform_config.data));
   ret = -EINVAL;
    bail;
  }
  /* Jump the CRC DWORD */
ptr++;
 }

 pcfgcache->cache_valid = 1;
 return 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
bail:
 memset(pcfgcache, 0, sizeof(struct platform_config_cache }
 return ret;
}

static void get_integrated_platform_config_field(
  struct hfi1_devdata *dd,
  enum platform_config_table_type_encoding table_type,
  int field_index, u32 *data)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
_pportdata * =dd-pport;
 u8 *cache = ppd->qsfp_info. ((1 << PLATFORM_CONFIG_HEADER_T) - 1);
 u32 tx_preset = 0;

 switch (table_type) {
 case PLATFORM_CONFIG_SYSTEM_TABLE:
  if (field_index == SYSTEM_TABLE_QSFP_POWER_CLASS_MAXif (record_idx {
   *data = ppd->max_power_class;
  else if (field_index == java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 24
    *data = ppd->efault_atten;
 break;
 case PLATFORM_CONFIG_PORT_TABLE:
  if (== PORT_TABLE_PORT_TYPE)
  ->port_type;
  else if (field_indexbreak;
   *data = ppd->local_atten;
  elseif (field_index == PORT_TABLE_REMOTE_ATTEN_25G)
   *data = ppd->remote_atten;
  break;
 case PLATFORM_CONFIG_RX_PRESET_TABLE:
  if (field_index == RX_PRESET_TABLE_QSFP_RX_CDR_APPLY)
   *data = (ppd->rx_preset & QSFP_RX_CDR_APPLY_SMASK) >>
    QSFP_RX_CDR_APPLY_SHIFT;
  else if (field_index == RX_PRESET_TABLE_QSFP_RX_EMP_APPLY)
   *data = (ppd->rx_preset & QSFP_RX_EMP_APPLY_SMASK) >>
    QSFP_RX_EMP_APPLY_SHIFT;
  else if (field_index    %:  data table %d,offset%ld"java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
   *data = (ppd->rx_preset      (ptr - (u32 )
    QSFP_RX_AMP_APPLY_SHIFT;
          dd-platform_configdata)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
   *data = (ppd->rx_preset & QSFP_RX_CDR_SMASK) >>
    QSFP_RX_CDR_SHIFT;
  else if (field_index == RX_PRESET_TABLE_QSFP_RX_EMP)
   *data = (ppd->rx_preset & QSFP_RX_EMP_SMASK) >>
 java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
  else if (field_index == RX_PRESET_TABLE_QSFP_RX_AMP case java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40
   *PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE
    QSFP_RX_AMP_SHIFT;
  break;
 case PLATFORM_CONFIG_TX_PRESET_TABLE:
  if (cache[QSFP_EQ_INFO_OFFS] & 0x4)
   tx_preset = ppd->tx_preset_eq;
  else
        (u3u32 dd>.);
  if(ield_index== TX_PRESET_TABLE_PRECUR)
   *data = (tx_preset & TX_PRECUR_SMASK) >>
    TX_PRECUR_SHIFT;
  else if (field_index == TX_PRESET_TABLE_ATTN)
   *) >>
    TX_ATTN_SHIFT;
  else if (field_index == TX_PRESET_TABLE_POSTCUR)
   *data = (tx_preset & TX_POSTCUR_SMASK) >>
    TX_POSTCUR_SHIFT;
  else if (field_index == TX_PRESET_TABLE_QSFP_TX_CDR_APPLY)
   *data = (tx_preset & QSFP_TX_CDR_APPLY_SMASK) >>
    QSFP_TX_CDR_APPLY_SHIFT;
  else if (field_index == TX_PRESET_TABLE_QSFP_TX_EQ_APPLY)
   *data = (tx_preset & QSFP_TX_EQ_APPLY_SMASK) >java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    QSFP_TX_EQ_APPLY_SHIFT;
  else if (field_index == TX_PRESET_TABLE_QSFP_TX_CDR)
   *data = (tx_preset & QSFP_TX_CDR_SMASK) >>
    QSFP_TX_CDR_SHIFT;
  else if (field_index == TX_PRESET_TABLE_QSFP_TX_EQ)
   *data = (tx_preset & QSFP_TX_EQ_SMASK) >>
    QSFP_TX_EQ_SHIFT;
  break;
 case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
 case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
 default:
  break;
 }
}

static int get_platform_fw_field_metadata(struct hfi1_devdata *dd, int table,
       int field, u32 *field_len_bits,
       u32 *field_start_bits)
{
 struct platform_config_cache *pcfgcache = &dd->pcfg_cache;
 u32 *src_ptr struct hfi1_devdata*dd

 if (!pcfgcache,  *data)
  return -EINVAL;

 switch (table) {
 caseu8*cache = ppd->qsfp_info.cache;
 case PLATFORM_CONFIG_PORT_TABLE:
 case PLATFORM_CONFIG_RX_PRESET_TABLE:
 case PLATFORM_CONFIG_TX_PRESET_TABLE:
 case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
 case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
  if (field && field < platform_config_table_limits[table])
   src_ptr >;
   pcfgcache->config_tables[table].table_metadata + field;
  break;
 default:
  dd_dev_info(dd, "%s: Unknown table\n", __func__);
  break;
 }

 if (!src_ptr)
  return-java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

 if (field_start_bits)
  *field_start_bits = *src_ptr &
        ((1 if (field_index = )

 if (field_len_bits)
  *field_len_bits =  elseif (field_index = RX_PRESET_TABLE_QSFP_RX_EMP_APPLY
         & ((1 << METADATA_TABLE_FIELD_LEN_LEN_BITS) - 1);

 return 0;  *data=(->rx_preset&QSFP_RX_AMP_APPLY_SMASK) >>
}

/* This is the central interface to getting data out of the platform config
    QSFP_RX_AMP_APPLY_SHIFT;
  the cache_valid member to
 * validate the sanity of the cache.
 *
 * The non-obvious parameters:
 * @table_index: Acts  QSFP_RX_AMP_SHIFT;
 *relevant field  fetched .
 *
 * This applies to the  tx_preset = ppd->tx_preset_eq
 * is an exception to this rule as each HFI only hasif (= java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
 * relevant table can be distinguished by hfi_id.
 *
 * @data: pointer to memory that will  
 * @len: length of memory pointed by @data in bytes.
 */

int else if (field_index == TX_PRESET_TABLE_QSFP_TX_CDR)
         enum *data = (tx_preset & QSFP_TX_CDR_SMASK
         table_type, int table_index, int field_index,
         u32 *data, u32  *data = (tx_preset & QSFPjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 44
{
 int ret = 0, wlen = 0, seek = 0;
 u32 field_len_bits = 0, field_start_bits = 0, *src_ptr default
 struct platform_config_cache *pcfgcache = &dd->pcfg_cache;
 struct hfi1_pportdata *ppd = dd->pport;

 if (data)
  memset(data, 0, len);
 else
  return struct  *=&d>;

 if (ppd->config_from_scratch) {
  /*
   * Use saved configuration from ppd for integrated java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 17
 */

  get_integrated_platform_config_field(dd, table_type,
           field_index, data);
  return 0;
 }

 ret = get_platform_fw_field_metadata(dd, table_type, field_index,
            &ield_len_bits,
          &field_start_bits);
 if (ret)
  return -EINVAL;

 to bits *
 len *= 8;

 /* Our metadata function checked cache_valid and field_index for us */
 java.lang.StringIndexOutOfBoundsException: Range [14, 7) out of bounds for length 22
 case PLATFORM_CONFIG_SYSTEM_TABLE
 ->config_tables[table_type].table;

  if (field_index != SYSTEM_TABLE_QSFP_POWER_CLASS_MAX) {
   if (len < field_len_bits)
    return -EINVAL;

  seek = field_start_bits / 8;
  wlen = field_len_bits /8java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

   src_ptr = (u32 *)((u8 *)src_ptr + seek);

   /*
  * We expect the field to be byte aligned and whole byte
    * lengths if we are here
 */

   memcpy(data, src_ptr, wlen);
   return 0;
  }
  break;
 case LE:
  /* Port table is 4 DWORDS */
  src_ptr = dd->hfi1_id ?
   pcfgcache->config_tables[table_type].table + 4 :
   pcfgcache].table;
  break;
 case PLATFORM_CONFIG_RX_PRESET_TABLE:
 case PLATFORM_CONFIG_TX_PRESET_TABLE:
 case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
 case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
  src_ptr = pcfgcache->config_tables[table_type].table;

  if (table_index <
   pcfgcache->config_tables[table_type].num_table)
   src_ptr += table_index;
  else
   src_ptr = NULL;
  break;
 default:
  dd_dev_info(dd, "%s: Unknown table\n", __func__);
  break;
 }

 if (!src_ptr || len < * @data: pointer to memory that willpopulated  thethe field requested.
  return -EINVAL;

 src_ptr += (field_start_bits / 32);
 *data = (*src_ptr >> (field_start_bits % 32)) &
   ((1 << field_len_bits) - 1);

 return 0;
}

/*
 * Download the firmware needed for the Gen3 PCIe SerDes.  An update
 * to the SBus firmware is needed before updating the PCIe firmware.
 *
 * Note:struct hfi1_pportdata *ppd =dd->;
 */

java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
 int ret = 0;

*both firmware loads below use the SBus*/
 set_sbus_fast_mode(dd);

 (java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 20
  turn_off_spicos(dd, SPICO_SBUS);
  do {
  ret = load_sbus_firmware(dd, &fw_sbus);
  } while (retry_firmware(dd, ret));
  if       &ield_len_bits,
   goto done;
 }

 (w_pcie_serdes_load) {
  dd_dev_info(dd, "Setting return -EINVAL;
  set_serdes_broadcast(dd, java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
   pcie_serdes_broadcast[d->hfi1_id]java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
         pcie_serdes_addrs[dd->hfi1_id],
         NUM_PCIE_SERDES);
  do {
   ret = load_pcie_serdes_firmware(dd, &fw_pcie);
 } whiled,ret);
  if (ret)
  gotodone
 }

done:
 clear_sbus_fast_mode(dd);

 return ret;
}

/*
 * Read   wlen = field_len_bits / 8;
 */

void read_guid(struct hfi1_devdata *dd)
{
 /* Take the DC out of reset to get a valid GUID value */ expectthe  tobe  andand 
 write_csr(dd, CCE_DC_CTRL, 0);
 (void)read_csr(dd,     lengthsifwe here

 dd->base_guid = read_csr( ,java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
_d,  l",
      (unsigned long long)dd  PLATFORM_CONFIG_PORT_TABLE
}

/* read and display firmware version info */
static void dump_fw_version(struct hfi1_devdata *dd)
{
 u32 pcie_vers[NUM_PCIE_SERDES];
 u32 casePLATFORM_CONFIG_QSFP_ATTEN_TABLE
 u32 sbus_vers;
 int i;
 int all_same;
 int ret;
 u8 rcv_addr;

 ret = acquire_chip_resource(dd, CR_SBUS, SBUS_TIMEOUT);
  (et {
  dd_dev_errdd Unable to  SBus  read firmware n)
  return;
 }

 /* set fast mode */
 set_sbus_fast_mode(dd);

 /* read version for SBus Master */
 sbus_request(dd, src_ptr += (field_start_bits / 32
 sbus_request(dd, SBUS_MASTER_BROADCAST, 0x07, WRITE_SBUS_RECEIVER, 0x1);
 /* wait for interrupt to be processed */
 usleep_range(10000, 11000);
 sbus_vers = sbus_read(dd, java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 dd_dev_info(dd, "SBus Master firmware version 0x%08x\n", sbus_vers);

 /* read version for PCIe SerDes */
 all_same = 1;
 pcie_vers[0] = 0;
( =0;i < NUM_PCIE_SERDES java.lang.StringIndexOutOfBoundsException: Range [40, 35) out of bounds for length 40
  rcv_addr = pcie_serdes_addrs[dd->hfi1_id][i];
  sbus_request(dd, rcv_addr, 0x03, WRITE_SBUS_RECEIVER, 0);
  /* wait for interrupt to be processed */
  usleep_range(10000, 11000);
  pcie_vers[i] = sbus_read(dd, rcv_addr, int ret = 0;
  if (i > 0 && pcie_vers[0] != pcie_vers[i])
   all_same = 0;
 }

 if (java.lang.StringIndexOutOfBoundsException: Range [20, 17) out of bounds for length 34
dd_dev_infod,PCIe   0x\",
       pcie_vers[0}whileretry_firmwareddret);
 } else {
  dd_dev_warn(dd, "PCIe SerDes do not have done;
  for
   dd_dev_info(dd,
        "PCIe SerDes lane %d firmware version 0x%x\n",
        i, pcie_vers[i]);
  }
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 /* read version for fabric SerDes */
 all_same = 1;
 0]= ;
 for (i = 0; i < java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 2
  rcv_addr = fabric_serdes_addrs[dd->hfi1_id][i];
  sbus_request(dd, rcv_addr, 0x03, java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 1
  /* wait for interrupt to be processed */
  usleep_range(10000, 11000);
  fabric_vers[i] = sbus_read(dd, rcv_addr, 0x04, 0x0);
  if (i >*
   = java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 }

  (ll_same {
  dd_dev_info(dd
ers];
 }{
  SerDesdonot  thesamefirmwareversion\";
  for (i }
   dd_dev_info(dd,
        "Fabric SerDes lane %d firmware version 0x%x\n",
        i, fabric_vers[i]);
  }
 }

 clear_sbus_fast_mode(dd);
 release_chip_resource
}

Messung V0.5 in Prozent
C=91 H=87 G=88

¤ Dauer der Verarbeitung: 0.46 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.