Exemple #1
0
int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle)
{
	unsigned int ae_reset_csr;
	unsigned char ae;
	unsigned int clk_csr;
	unsigned int times = 100;
	unsigned int csr;

	/* write to the reset csr */
	ae_reset_csr = GET_GLB_CSR(handle, ICP_RESET);
	ae_reset_csr &= ~(handle->hal_handle->ae_mask << RST_CSR_AE_LSB);
	ae_reset_csr &= ~(handle->hal_handle->slice_mask << RST_CSR_QAT_LSB);
	do {
		SET_GLB_CSR(handle, ICP_RESET, ae_reset_csr);
		if (!(times--))
			goto out_err;
		csr = GET_GLB_CSR(handle, ICP_RESET);
	} while ((handle->hal_handle->ae_mask |
		 (handle->hal_handle->slice_mask << RST_CSR_QAT_LSB)) & csr);
	/* enable clock */
	clk_csr = GET_GLB_CSR(handle, ICP_GLOBAL_CLK_ENABLE);
	clk_csr |= handle->hal_handle->ae_mask << 0;
	clk_csr |= handle->hal_handle->slice_mask << 20;
	SET_GLB_CSR(handle, ICP_GLOBAL_CLK_ENABLE, clk_csr);
	if (qat_hal_check_ae_alive(handle))
		goto out_err;

	/* Set undefined power-up/reset states to reasonable default values */
	for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
		if (!(handle->hal_handle->ae_mask & (1 << ae)))
			continue;
		qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES,
				  INIT_CTX_ENABLE_VALUE);
		qat_hal_wr_indr_csr(handle, ae, ICP_QAT_UCLO_AE_ALL_CTX,
				    CTX_STS_INDIRECT,
				    handle->hal_handle->upc_mask &
				    INIT_PC_VALUE);
		qat_hal_wr_ae_csr(handle, ae, CTX_ARB_CNTL, INIT_CTX_ARB_VALUE);
		qat_hal_wr_ae_csr(handle, ae, CC_ENABLE, INIT_CCENABLE_VALUE);
		qat_hal_put_wakeup_event(handle, ae,
					 ICP_QAT_UCLO_AE_ALL_CTX,
					 INIT_WAKEUP_EVENTS_VALUE);
		qat_hal_put_sig_event(handle, ae,
				      ICP_QAT_UCLO_AE_ALL_CTX,
				      INIT_SIG_EVENTS_VALUE);
	}
	if (qat_hal_init_esram(handle))
		goto out_err;
	if (qat_hal_wait_cycles(handle, 0, SHRAM_INIT_CYCLES, 0))
		goto out_err;
	qat_hal_reset_timestamp(handle);

	return 0;
out_err:
	pr_err("QAT: failed to get device out of reset\n");
	return -EFAULT;
}
Exemple #2
0
void qat_hal_reset(struct icp_qat_fw_loader_handle *handle)
{
	unsigned int ae_reset_csr;

	ae_reset_csr = GET_GLB_CSR(handle, ICP_RESET);
	ae_reset_csr |= handle->hal_handle->ae_mask << RST_CSR_AE_LSB;
	ae_reset_csr |= handle->hal_handle->slice_mask << RST_CSR_QAT_LSB;
	SET_GLB_CSR(handle, ICP_RESET, ae_reset_csr);
}
Exemple #3
0
static void qat_hal_reset_timestamp(struct icp_qat_fw_loader_handle *handle)
{
	unsigned int misc_ctl;
	unsigned char ae;

	/* stop the timestamp timers */
	misc_ctl = GET_GLB_CSR(handle, MISC_CONTROL);
	if (misc_ctl & MC_TIMESTAMP_ENABLE)
		SET_GLB_CSR(handle, MISC_CONTROL, misc_ctl &
			    (~MC_TIMESTAMP_ENABLE));

	for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
		if (!(handle->hal_handle->ae_mask & (1 << ae)))
			continue;
		qat_hal_wr_ae_csr(handle, ae, TIMESTAMP_LOW, 0);
		qat_hal_wr_ae_csr(handle, ae, TIMESTAMP_HIGH, 0);
	}
	/* start timestamp timers */
	SET_GLB_CSR(handle, MISC_CONTROL, misc_ctl | MC_TIMESTAMP_ENABLE);
}
Exemple #4
0
int main(int argc, char **argv)
{
  char input[10];
  
  int status;

  std::string plugin_uof;
  void *plugin_handle;
  unsigned int plugin_me;
  unsigned int plugin_me_mask;
  unsigned int me;
  unsigned int ctx_mask = ME_ALL_CTX;

  static struct option longopts[] =
  {{"help",   0, NULL, 'h'},
   {"plugin", 1, NULL, 'p'},
   {"me",     1, NULL, 'm'},
   {NULL,     0, NULL,  0}
  };

  int c;
  while ((c = getopt_long(argc, argv, "hp:m:", longopts, NULL)) != -1) {
    switch (c) {
      case 'p':
        plugin_uof = optarg;
        break;
      case 'm':
        plugin_me = atoi(optarg);
        break;
      case 'h':
      default:
        print_usage(argv[0]);
        exit(1);
    }
  }

  std::cout << "Calling UcLo_InitLib...";
  UcLo_InitLib();
  std::cout << "done.\n";

  std::cout << "Calling halMe_Init...";
  if((status = halMe_Init(0x0)) != HALME_SUCCESS)
  {
    std::cout << "failed with status " + int2str(status) + "!\n";
    exit(1);
  }
  std::cout << "done.\n";

  std::string ver = "2800";
  unsigned int prodId = GET_GLB_CSR(PRODUCT_ID);
  unsigned int majRev = (prodId & PID_MAJOR_REV) >> PID_MAJOR_REV_BITPOS;
  if(majRev >= 3) { ver = "2805"; }

  std::string full_plugin_path = plugin_uof + "_" + int2str(plugin_me) + "_" + ver;

  std::cout << "Calling UcLo_LoadObjFile for the plugin " << full_plugin_path << "...";
  if((status = UcLo_LoadObjFile(&plugin_handle, (char *)full_plugin_path.c_str())) != UCLO_SUCCESS)
  {
    std::cout << "failed with status " + int2str(status) + "!\n";
    exit(1);
  }
  std::cout << "done.\n";

  plugin_me_mask = UcLo_GetAssignedMEs(plugin_handle);
  
  std::cout << "Calling UcLo_WriteUimageAll for plugin...";
  if((status = UcLo_WriteUimageAll(plugin_handle)) != UCLO_SUCCESS)
  {
    std::cout << "failed with status " + int2str(status) + "!\n";
    exit(1);
  }
  std::cout << "done.\n";

  unsigned int mask = 0xf0007f;

  std::cout << "Calling halMe_Stop for router base microengines...";
  for(me=0; me < 0x18; me++)
  {
    if(!(mask & (1<<me))) continue;

    if(halMe_Stop(me, ctx_mask) != HALME_SUCCESS)
    {
      std::cout << "failed for me: " + int2str(me) + "\n";
      exit(1);
    }
  }
  std::cout << "done.\n";

  mask = mask | plugin_me_mask;

  std::cout << "Calling halMe_Start for router base and plugin microengines...";
  for(me=0; me < 0x18; me++)
  {
    if(!(mask & (1<<me))) continue;

    if(halMe_Start(me, ctx_mask) != HALME_SUCCESS)
    {
      std::cout << "failed for me: " + int2str(me) + "\n";
      exit(1);
    }
  }
  std::cout << "done.\n";

  std::cout << "Press enter when you want to stop and remove the plugin.\n";
  std::cin.getline(input,10);

  std::cout << "Calling halMe_Stop for plugin microengine...";
  for(me=0; me < 0x18; me++)
  {
    if(!(plugin_me_mask & (1<<me))) continue;
    if(halMe_Stop(me, ctx_mask) != HALME_SUCCESS)
    {
      std::cout << "failed for me: " + int2str(me) + "\n";
      exit(1);
    }
  }
  std::cout << "done.\n";

  std::cout << "Calling UcLo_DeleObj for the plugin...";
  if((status = UcLo_DeleObj(plugin_handle)) != UCLO_SUCCESS)
  {
    std::cout << "failed!\n";
    exit(1);
  } 
  std::cout << "done.\n";

/*
  std::cout << "Calling halMe_DelLib...";
  halMe_DelLib();
  std::cout << "done.\n";
*/

  return 0;
}