Blame src/cntrl.h

Packit 7e09eb
/*
Packit 7e09eb
 * Intel(R) Enclosure LED Utilities
Packit 7e09eb
 * Copyright (C) 2009-2020 Intel Corporation.
Packit 7e09eb
 *
Packit 7e09eb
 * This program is free software; you can redistribute it and/or modify it
Packit 7e09eb
 * under the terms and conditions of the GNU General Public License,
Packit 7e09eb
 * version 2, as published by the Free Software Foundation.
Packit 7e09eb
 *
Packit 7e09eb
 * This program is distributed in the hope it will be useful, but WITHOUT
Packit 7e09eb
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Packit 7e09eb
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
Packit 7e09eb
 * more details.
Packit 7e09eb
 *
Packit 7e09eb
 * You should have received a copy of the GNU General Public License along with
Packit 7e09eb
 * this program; if not, write to the Free Software Foundation, Inc.,
Packit 7e09eb
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
Packit 7e09eb
 *
Packit 7e09eb
 */
Packit 7e09eb
Packit 7e09eb
#ifndef _CNTRL_H_INCLUDED_
Packit 7e09eb
#define _CNTRL_H_INCLUDED_
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * This enumeration type lists all supported storage controller types.
Packit 7e09eb
 */
Packit 7e09eb
enum cntrl_type {
Packit 7e09eb
	CNTRL_TYPE_UNKNOWN = 0,
Packit 7e09eb
	CNTRL_TYPE_DELLSSD,
Packit 7e09eb
	CNTRL_TYPE_VMD,
Packit 7e09eb
	CNTRL_TYPE_SCSI,
Packit 7e09eb
	CNTRL_TYPE_AHCI,
Packit 7e09eb
	CNTRL_TYPE_NPEM,
Packit 7e09eb
	CNTRL_TYPE_AMD,
Packit 7e09eb
};
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Storage controller device structure.
Packit 7e09eb
 *
Packit 7e09eb
 * This structure describes a storage controller device existing in the system.
Packit 7e09eb
 */
Packit 7e09eb
struct cntrl_device {
Packit 7e09eb
	/**
Packit 7e09eb
	* Path to the device in sysfs tree.
Packit 7e09eb
	*/
Packit 7e09eb
	char *sysfs_path;
Packit 7e09eb
Packit 7e09eb
	/**
Packit 7e09eb
	 * Type of storage controller device.
Packit 7e09eb
	 */
Packit 7e09eb
	enum cntrl_type cntrl_type;
Packit 7e09eb
Packit 7e09eb
	/**
Packit 7e09eb
	 * Flag if scsi controller driver is "isci"
Packit 7e09eb
	 */
Packit 7e09eb
	int isci_present;
Packit 7e09eb
Packit 7e09eb
	struct _host_type {
Packit 7e09eb
		/**
Packit 7e09eb
		 * ibpi state buffer for directly attached devices
Packit 7e09eb
		 */
Packit 7e09eb
		struct gpio_tx_register_byte *ibpi_state_buffer;
Packit 7e09eb
		/**
Packit 7e09eb
		 * outbound raw byte stream
Packit 7e09eb
		 */
Packit 7e09eb
		unsigned char bitstream[4];
Packit 7e09eb
		/**
Packit 7e09eb
		 * bitstream's flush flag
Packit 7e09eb
		 */
Packit 7e09eb
		int flush;
Packit 7e09eb
		/**
Packit 7e09eb
		 * host identifier for different hba instances
Packit 7e09eb
		 */
Packit 7e09eb
		int host_id;
Packit 7e09eb
		/**
Packit 7e09eb
		 * number of total phy ports
Packit 7e09eb
		 */
Packit 7e09eb
		int ports;
Packit 7e09eb
		/**
Packit 7e09eb
		 * pointer to next structure
Packit 7e09eb
		 */
Packit 7e09eb
		struct _host_type *next;
Packit 7e09eb
	} *hosts;
Packit 7e09eb
};
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Allocates a new controller device structure.
Packit 7e09eb
 *
Packit 7e09eb
 * This function allocates memory for a new structure of storage controller
Packit 7e09eb
 * device. It reads the sysfs entries and populates structure fields.
Packit 7e09eb
 * The function registers only supported storage controllers.
Packit 7e09eb
 *
Packit 7e09eb
 * @param[in]      path           path to storage controller in sysfs tree.
Packit 7e09eb
 *
Packit 7e09eb
 * @return Pointer to storage controller structure if successful, otherwise the
Packit 7e09eb
 *         function returns NULL pointer. The NULL pointer means that controller
Packit 7e09eb
 *         device is not supported.
Packit 7e09eb
 */
Packit 7e09eb
struct cntrl_device *cntrl_device_init(const char *path);
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Releases a controller device structure.
Packit 7e09eb
 *
Packit 7e09eb
 * This function releases memory allocated for controller device structure.
Packit 7e09eb
 *
Packit 7e09eb
 * @param[in]     device         pointer to controller device structure.
Packit 7e09eb
 *
Packit 7e09eb
 * @return The function does not return a value.
Packit 7e09eb
 */
Packit 7e09eb
void cntrl_device_fini(struct cntrl_device *device);
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Prints given controller to stdout.
Packit 7e09eb
 *
Packit 7e09eb
 * This function prints the path and type of controller device given as
Packit 7e09eb
 * argument.
Packit 7e09eb
 *
Packit 7e09eb
 * @param[in]      ctrl_dev            address to element from a
Packit 7e09eb
 *                                     controller list.
Packit 7e09eb
 *
Packit 7e09eb
 * @return The function does not return a value.
Packit 7e09eb
 */
Packit 7e09eb
void print_cntrl(struct cntrl_device *ctrl_dev);
Packit 7e09eb
Packit 7e09eb
#endif				/* _CNTRL_H_INCLUDED_ */