Path: blob/master/drivers/misc/sgi-gru/grukservices.h
15111 views
1/*2* Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17*/18#ifndef __GRU_KSERVICES_H_19#define __GRU_KSERVICES_H_202122/*23* Message queues using the GRU to send/receive messages.24*25* These function allow the user to create a message queue for26* sending/receiving 1 or 2 cacheline messages using the GRU.27*28* Processes SENDING messages will use a kernel CBR/DSR to send29* the message. This is transparent to the caller.30*31* The receiver does not use any GRU resources.32*33* The functions support:34* - single receiver35* - multiple senders36* - cross partition message37*38* Missing features ZZZ:39* - user options for dealing with timeouts, queue full, etc.40* - gru_create_message_queue() needs interrupt vector info41*/4243struct gru_message_queue_desc {44void *mq; /* message queue vaddress */45unsigned long mq_gpa; /* global address of mq */46int qlines; /* queue size in CL */47int interrupt_vector; /* interrupt vector */48int interrupt_pnode; /* pnode for interrupt */49int interrupt_apicid; /* lapicid for interrupt */50};5152/*53* Initialize a user allocated chunk of memory to be used as54* a message queue. The caller must ensure that the queue is55* in contiguous physical memory and is cacheline aligned.56*57* Message queue size is the total number of bytes allocated58* to the queue including a 2 cacheline header that is used59* to manage the queue.60*61* Input:62* mqd pointer to message queue descriptor63* p pointer to user allocated mesq memory.64* bytes size of message queue in bytes65* vector interrupt vector (zero if no interrupts)66* nasid nasid of blade where interrupt is delivered67* apicid apicid of cpu for interrupt68*69* Errors:70* 0 OK71* >0 error72*/73extern int gru_create_message_queue(struct gru_message_queue_desc *mqd,74void *p, unsigned int bytes, int nasid, int vector, int apicid);7576/*77* Send a message to a message queue.78*79* Note: The message queue transport mechanism uses the first 3280* bits of the message. Users should avoid using these bits.81*82*83* Input:84* mqd pointer to message queue descriptor85* mesg pointer to message. Must be 64-bit aligned86* bytes size of message in bytes87*88* Output:89* 0 message sent90* >0 Send failure - see error codes below91*92*/93extern int gru_send_message_gpa(struct gru_message_queue_desc *mqd,94void *mesg, unsigned int bytes);9596/* Status values for gru_send_message() */97#define MQE_OK 0 /* message sent successfully */98#define MQE_CONGESTION 1 /* temporary congestion, try again */99#define MQE_QUEUE_FULL 2 /* queue is full */100#define MQE_UNEXPECTED_CB_ERR 3 /* unexpected CB error */101#define MQE_PAGE_OVERFLOW 10 /* BUG - queue overflowed a page */102#define MQE_BUG_NO_RESOURCES 11 /* BUG - could not alloc GRU cb/dsr */103104/*105* Advance the receive pointer for the message queue to the next message.106* Note: current API requires messages to be gotten & freed in order. Future107* API extensions may allow for out-of-order freeing.108*109* Input110* mqd pointer to message queue descriptor111* mesq message being freed112*/113extern void gru_free_message(struct gru_message_queue_desc *mqd,114void *mesq);115116/*117* Get next message from message queue. Returns pointer to118* message OR NULL if no message present.119* User must call gru_free_message() after message is processed120* in order to move the queue pointers to next message.121*122* Input123* mqd pointer to message queue descriptor124*125* Output:126* p pointer to message127* NULL no message available128*/129extern void *gru_get_next_message(struct gru_message_queue_desc *mqd);130131132/*133* Read a GRU global GPA. Source can be located in a remote partition.134*135* Input:136* value memory address where MMR value is returned137* gpa source numalink physical address of GPA138*139* Output:140* 0 OK141* >0 error142*/143int gru_read_gpa(unsigned long *value, unsigned long gpa);144145146/*147* Copy data using the GRU. Source or destination can be located in a remote148* partition.149*150* Input:151* dest_gpa destination global physical address152* src_gpa source global physical address153* bytes number of bytes to copy154*155* Output:156* 0 OK157* >0 error158*/159extern int gru_copy_gpa(unsigned long dest_gpa, unsigned long src_gpa,160unsigned int bytes);161162/*163* Reserve GRU resources to be used asynchronously.164*165* input:166* blade_id - blade on which resources should be reserved167* cbrs - number of CBRs168* dsr_bytes - number of DSR bytes needed169* cmp - completion structure for waiting for170* async completions171* output:172* handle to identify resource173* (0 = no resources)174*/175extern unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes,176struct completion *cmp);177178/*179* Release async resources previously reserved.180*181* input:182* han - handle to identify resources183*/184extern void gru_release_async_resources(unsigned long han);185186/*187* Wait for async GRU instructions to complete.188*189* input:190* han - handle to identify resources191*/192extern void gru_wait_async_cbr(unsigned long han);193194/*195* Lock previous reserved async GRU resources196*197* input:198* han - handle to identify resources199* output:200* cb - pointer to first CBR201* dsr - pointer to first DSR202*/203extern void gru_lock_async_resource(unsigned long han, void **cb, void **dsr);204205/*206* Unlock previous reserved async GRU resources207*208* input:209* han - handle to identify resources210*/211extern void gru_unlock_async_resource(unsigned long han);212213#endif /* __GRU_KSERVICES_H_ */214215216