17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5febcb4aSScott Carter, SD IOSW * Common Development and Distribution License (the "License"). 6*5febcb4aSScott Carter, SD IOSW * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5febcb4aSScott Carter, SD IOSW * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_PX_MSI_H 277c478bd9Sstevel@tonic-gate #define _SYS_PX_MSI_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * MSI data structure. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate typedef struct px_msi { 377c478bd9Sstevel@tonic-gate dev_info_t *msi_dip; /* MSI consumer dip */ 387c478bd9Sstevel@tonic-gate int msi_inum; /* INUM for this device */ 397c478bd9Sstevel@tonic-gate uint_t msi_state; /* MSI alloc state */ 407c478bd9Sstevel@tonic-gate msinum_t msi_msinum; /* MSI number */ 417c478bd9Sstevel@tonic-gate msiqid_t msi_msiq_id; /* MSIQ used */ 427c478bd9Sstevel@tonic-gate } px_msi_t; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define MSI_STATE_FREE 0x1 457c478bd9Sstevel@tonic-gate #define MSI_STATE_INUSE 0x2 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * MSI soft state structure. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate typedef struct px_msi_state { 517c478bd9Sstevel@tonic-gate uint_t msi_cnt; /* No of MSIs */ 527c478bd9Sstevel@tonic-gate msinum_t msi_1st_msinum; /* First MSI number */ 537c478bd9Sstevel@tonic-gate uint_t msi_data_mask; /* MSI data mask */ 547c478bd9Sstevel@tonic-gate uint_t msi_data_width; /* MSI data width */ 557c478bd9Sstevel@tonic-gate uint64_t msi_addr32; /* MSI 32 address */ 567c478bd9Sstevel@tonic-gate uint64_t msi_addr32_len; /* MSI 32 length */ 577c478bd9Sstevel@tonic-gate uint64_t msi_addr64; /* MSI 64 address */ 587c478bd9Sstevel@tonic-gate uint64_t msi_addr64_len; /* MSI 64 length */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate px_msi_t *msi_p; /* Pointer to MSIs array */ 617c478bd9Sstevel@tonic-gate kmutex_t msi_mutex; /* Mutex for MSI alloc/free */ 627c478bd9Sstevel@tonic-gate uint_t msi_type; /* MSI or MSI-X */ 637c478bd9Sstevel@tonic-gate boolean_t msi_mem_flg; /* TRUE if driver allocates memory */ 64*5febcb4aSScott Carter, SD IOSW 65*5febcb4aSScott Carter, SD IOSW ddi_irm_pool_t *msi_pool_p; /* IRM Pool */ 667c478bd9Sstevel@tonic-gate } px_msi_state_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * px_msi_ranges 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate typedef struct px_msi_ranges { 727c478bd9Sstevel@tonic-gate int msi_no; 737c478bd9Sstevel@tonic-gate int no_msis; 747c478bd9Sstevel@tonic-gate } px_msi_ranges_t; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * px_msi_address_ranges 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate typedef struct px_msi_address_ranges { 807c478bd9Sstevel@tonic-gate uint32_t msi_addr32_hi; 817c478bd9Sstevel@tonic-gate uint32_t msi_addr32_lo; 827c478bd9Sstevel@tonic-gate uint32_t msi_addr32_len; 837c478bd9Sstevel@tonic-gate uint32_t msi_addr64_hi; 847c478bd9Sstevel@tonic-gate uint32_t msi_addr64_lo; 857c478bd9Sstevel@tonic-gate uint32_t msi_addr64_len; 867c478bd9Sstevel@tonic-gate } px_msi_address_ranges_t; 877c478bd9Sstevel@tonic-gate 88a195726fSgovinda #define PX_MSI_WIDTH 16 89a195726fSgovinda #define PX_MSIX_WIDTH 32 90a195726fSgovinda 917c478bd9Sstevel@tonic-gate extern int px_msi_attach(px_t *px_p); 927c478bd9Sstevel@tonic-gate extern void px_msi_detach(px_t *px_p); 937c478bd9Sstevel@tonic-gate 94*5febcb4aSScott Carter, SD IOSW extern int px_msi_alloc(px_t *px_p, dev_info_t *rdip, int type, int inum, 95*5febcb4aSScott Carter, SD IOSW int msi_count, int flag, int *actual_msi_count_p); 967c478bd9Sstevel@tonic-gate extern int px_msi_free(px_t *px_p, dev_info_t *rdip, int inum, 977c478bd9Sstevel@tonic-gate int msi_count); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate extern int px_msi_get_msinum(px_t *px_p, dev_info_t *rdip, 1007c478bd9Sstevel@tonic-gate int inum, msinum_t *msi_num_p); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1037c478bd9Sstevel@tonic-gate } 1047c478bd9Sstevel@tonic-gate #endif 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate #endif /* _SYS_PX_MSI_H */ 107