Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/smartpqi/smartpqi_cmd.c
/*- | /*- | ||||
* Copyright (c) 2018 Microsemi Corporation. | * Copyright 2016-2021 Microchip Technology, Inc. and/or its subsidiaries. | ||||
* All rights reserved. | |||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
Show All 15 Lines | |||||
/* $FreeBSD$ */ | /* $FreeBSD$ */ | ||||
#include "smartpqi_includes.h" | #include "smartpqi_includes.h" | ||||
/* | /* | ||||
* Function to submit the request to the adapter. | * Function to submit the request to the adapter. | ||||
*/ | */ | ||||
int pqisrc_submit_cmnd(pqisrc_softstate_t *softs, | int | ||||
ib_queue_t *ib_q, void *req) | pqisrc_submit_cmnd(pqisrc_softstate_t *softs, ib_queue_t *ib_q, void *req) | ||||
{ | { | ||||
char *slot = NULL; | char *slot = NULL; | ||||
uint32_t offset; | uint32_t offset; | ||||
iu_header_t *hdr = (iu_header_t *)req; | iu_header_t *hdr = (iu_header_t *)req; | ||||
uint32_t iu_len = hdr->iu_length + 4 ; /* header size */ | uint32_t iu_len = hdr->iu_length + 4 ; /* header size */ | ||||
int i = 0; | int i = 0; | ||||
DBG_FUNC("IN\n"); | DBG_FUNC("IN\n"); | ||||
PQI_LOCK(&ib_q->lock); | PQI_LOCK(&ib_q->lock); | ||||
/* Check queue full */ | /* Check queue full */ | ||||
if ((ib_q->pi_local + 1) % ib_q->num_elem == *(ib_q->ci_virt_addr)) { | if ((ib_q->pi_local + 1) % ib_q->num_elem == *(ib_q->ci_virt_addr)) { | ||||
DBG_WARN("OUT Q full\n"); | DBG_WARN("OUT Q full\n"); | ||||
PQI_UNLOCK(&ib_q->lock); | PQI_UNLOCK(&ib_q->lock); | ||||
return PQI_STATUS_QFULL; | return PQI_STATUS_QFULL; | ||||
} | } | ||||
/* Get the slot */ | /* Get the slot */ | ||||
offset = ib_q->pi_local * ib_q->elem_size; | offset = ib_q->pi_local * ib_q->elem_size; | ||||
slot = ib_q->array_virt_addr + offset; | slot = ib_q->array_virt_addr + offset; | ||||
/* Copy the IU */ | /* Copy the IU */ | ||||
memcpy(slot, req, iu_len); | memcpy(slot, req, iu_len); | ||||
DBG_INFO("IU : \n"); | DBG_INFO("IU : \n"); | ||||
for(i = 0; i< iu_len; i++) | for(i = 0; i< iu_len; i++) | ||||
DBG_INFO(" IU [ %d ] : %x\n", i, *((unsigned char *)(slot + i))); | DBG_INFO(" IU [ %d ] : %x\n", i, *((unsigned char *)(slot + i))); | ||||
/* Update the local PI */ | /* Update the local PI */ | ||||
ib_q->pi_local = (ib_q->pi_local + 1) % ib_q->num_elem; | ib_q->pi_local = (ib_q->pi_local + 1) % ib_q->num_elem; | ||||
DBG_INFO("ib_q->pi_local : %x IU size : %d\n", | DBG_INFO("ib_q->pi_local : %x IU size : %d\n", | ||||
ib_q->pi_local, hdr->iu_length); | ib_q->pi_local, hdr->iu_length); | ||||
DBG_INFO("*ib_q->ci_virt_addr: %x\n", | DBG_INFO("*ib_q->ci_virt_addr: %x\n", | ||||
*(ib_q->ci_virt_addr)); | *(ib_q->ci_virt_addr)); | ||||
/* Inform the fw about the new IU */ | /* Inform the fw about the new IU */ | ||||
PCI_MEM_PUT32(softs, ib_q->pi_register_abs, ib_q->pi_register_offset, ib_q->pi_local); | PCI_MEM_PUT32(softs, ib_q->pi_register_abs, ib_q->pi_register_offset, ib_q->pi_local); | ||||
PQI_UNLOCK(&ib_q->lock); | PQI_UNLOCK(&ib_q->lock); | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
return PQI_STATUS_SUCCESS; | return PQI_STATUS_SUCCESS; | ||||
} | } |