All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Alexander Graf <agraf@suse.de>
Cc: paulus@samba.org, qemu-devel@nongnu.org, anton@samba.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] Re: [PATCH 24/26] Implement PAPR virtual SCSI interface (ibmvscsi)
Date: Wed, 16 Mar 2011 11:51:56 -0500	[thread overview]
Message-ID: <4D80EAAC.1090009@codemonkey.ws> (raw)
In-Reply-To: <4D80E852.5020109@suse.de>

On 03/16/2011 11:41 AM, Alexander Graf wrote:
>> new file mode 100644
>> index 0000000..9d55fc4
>> --- /dev/null
>> +++ b/hw/srp.h
>> @@ -0,0 +1,241 @@
>> +/*
>> + * Copyright (c) 2005 Cisco Systems.  All rights reserved.
>> + *
>> + * This software is available to you under a choice of one of two
>> + * licenses.  You may choose to be licensed under the terms of the GNU
>> + * General Public License (GPL) Version 2, available from the file
>> + * COPYING in the main directory of this source tree, or the
>> + * OpenIB.org BSD license below:
>> + *
>> + *     Redistribution and use in source and binary forms, with or
>> + *     without modification, are permitted provided that the following
>> + *     conditions are met:
>> + *
>> + *      - Redistributions of source code must retain the above
>> + *        copyright notice, this list of conditions and the following
>> + *        disclaimer.
>> + *
>> + *      - Redistributions in binary form must reproduce the above
>> + *        copyright notice, this list of conditions and the following
>> + *        disclaimer in the documentation and/or other materials
>> + *        provided with the distribution.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
>> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
>> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
>> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>> + * SOFTWARE.
>> + *
>> + * $Id$
>> + */
>> +
>> +#ifndef SCSI_SRP_H
>> +#define SCSI_SRP_H
>> +
>> +/*
>> + * Structures and constants for the SCSI RDMA Protocol (SRP) as
>> + * defined by the INCITS T10 committee.  This file was written using
>> + * draft Revision 16a of the SRP standard.
>> + */
>> +
>> +enum {
>> +
>> +    SRP_LOGIN_REQ = 0x00,
>> +    SRP_TSK_MGMT  = 0x01,
>> +    SRP_CMD       = 0x02,
>> +    SRP_I_LOGOUT  = 0x03,
>> +    SRP_LOGIN_RSP = 0xc0,
>> +    SRP_RSP       = 0xc1,
>> +    SRP_LOGIN_REJ = 0xc2,
>> +    SRP_T_LOGOUT  = 0x80,
>> +    SRP_CRED_REQ  = 0x81,
>> +    SRP_AER_REQ   = 0x82,
>> +    SRP_CRED_RSP  = 0x41,
>> +    SRP_AER_RSP   = 0x42
>> +};
>> +
>> +enum {
>> +    SRP_BUF_FORMAT_DIRECT   = 1<<  1,
>> +    SRP_BUF_FORMAT_INDIRECT = 1<<  2
>> +};
>> +
>> +enum {
>> +    SRP_NO_DATA_DESC       = 0,
>> +    SRP_DATA_DESC_DIRECT   = 1,
>> +    SRP_DATA_DESC_INDIRECT = 2
>> +};
>> +
>> +enum {
>> +    SRP_TSK_ABORT_TASK     = 0x01,
>> +    SRP_TSK_ABORT_TASK_SET = 0x02,
>> +    SRP_TSK_CLEAR_TASK_SET = 0x04,
>> +    SRP_TSK_LUN_RESET      = 0x08,
>> +    SRP_TSK_CLEAR_ACA      = 0x40
>> +};
>> +
>> +enum srp_login_rej_reason {
>> +    SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL   = 0x00010000,
>> +    SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES     = 0x00010001,
>> +    SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
>> +    SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL   = 0x00010003,
>> +    SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
>> +    SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED  = 0x00010005,
>> +    SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED      = 0x00010006
>> +};
>> +
>> +enum {
>> +    SRP_REV10_IB_IO_CLASS  = 0xff00,
>> +    SRP_REV16A_IB_IO_CLASS = 0x0100
>> +};
>> +
>> +struct srp_direct_buf {
>> +    uint64_t    va;
>> +    uint32_t    key;
>> +    uint32_t    len;
>> +};
>> +
>> +/*
>> + * We need the packed attribute because the SRP spec puts the list of
>> + * descriptors at an offset of 20, which is not aligned to the size of
>> + * struct srp_direct_buf.  The whole structure must be packed to avoid
>> + * having the 20-byte structure padded to 24 bytes on 64-bit 
>> architectures.
>> + */
>> +struct srp_indirect_buf {
>> +    struct srp_direct_buf    table_desc;
>> +    uint32_t                 len;
>> +    struct srp_direct_buf    desc_list[0];
>> +} __attribute__((packed));
>> +
>> +enum {
>> +    SRP_MULTICHAN_SINGLE = 0,
>> +    SRP_MULTICHAN_MULTI  = 1
>> +};
>> +
>> +struct srp_login_req {
>> +    uint8_t    opcode;
>> +    uint8_t    reserved1[7];
>> +    uint64_t   tag;
>> +    uint32_t   req_it_iu_len;
>> +    uint8_t    reserved2[4];
>> +    uint16_t   req_buf_fmt;
>> +    uint8_t    req_flags;
>> +    uint8_t    reserved3[5];
>> +    uint8_t    initiator_port_id[16];
>> +    uint8_t    target_port_id[16];
>> +};
>> +
>> +/*
>> + * The SRP spec defines the size of the LOGIN_RSP structure to be 52
>> + * bytes, so it needs to be packed to avoid having it padded to 56
>> + * bytes on 64-bit architectures.
>> + */
>> +struct srp_login_rsp {
>> +    uint8_t    opcode;
>> +    uint8_t    reserved1[3];
>> +    uint32_t   req_lim_delta;
>> +    uint64_t   tag;
>> +    uint32_t   max_it_iu_len;
>> +    uint32_t   max_ti_iu_len;
>> +    uint16_t   buf_fmt;
>> +    uint8_t    rsp_flags;
>> +    uint8_t    reserved2[25];
>> +} __attribute__((packed));
>> +
>> +struct srp_login_rej {
>> +    uint8_t    opcode;
>> +    uint8_t    reserved1[3];
>> +    uint32_t   reason;
>> +    uint64_t   tag;
>> +    uint8_t    reserved2[8];
>> +    uint16_t   buf_fmt;
>> +    uint8_t    reserved3[6];
>> +};
> diff --git a/hw/srp.h b/hw/srp.h
>
> Why isn't this one packed? And the ones below?

It's naturally aligned.  There's no need to pack things that are 
naturally aligned (structure size is a multiple of 8 and each type 
starts at an offset that's a multiple of it's size).

Regards,

Anthony Liguori

  reply	other threads:[~2011-03-16 16:58 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16  4:56 [Qemu-devel] Implement emulation of pSeries logical partitions (v3) David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 01/26] Clean up PowerPC SLB handling code David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 02/26] Allow qemu_devtree_setprop() to take arbitrary values David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 03/26] Add a hook to allow hypercalls to be emulated on PowerPC David Gibson
2011-03-16 13:46   ` [Qemu-devel] " Alexander Graf
2011-03-16 16:58     ` Stefan Hajnoczi
2011-03-17  2:26       ` David Gibson
2011-03-16 20:44   ` [Qemu-devel] " Anthony Liguori
2011-03-17  4:55     ` David Gibson
2011-03-17 13:20       ` Anthony Liguori
2011-03-18  4:03         ` David Gibson
2011-03-18  6:57           ` Alexander Graf
2011-03-16  4:56 ` [Qemu-devel] [PATCH 04/26] Implement PowerPC slbmfee and slbmfev instructions David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 05/26] Implement missing parts of the logic for the POWER PURR David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 06/26] Correct ppc popcntb logic, implement popcntw and popcntd David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 07/26] Clean up slb_lookup() function David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 08/26] Parse SDR1 on mtspr instead of at translate time David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 09/26] Use "hash" more consistently in ppc mmu code David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 10/26] Better factor the ppc hash translation path David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 11/26] Support 1T segments on ppc David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 12/26] Add POWER7 support for ppc David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 13/26] Start implementing pSeries logical partition machine David Gibson
2011-03-16 14:30   ` [Qemu-devel] " Alexander Graf
2011-03-16 21:59   ` [Qemu-devel] " Anthony Liguori
2011-03-16 23:46     ` Alexander Graf
2011-03-17  3:08     ` David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 14/26] Implement the bus structure for PAPR virtual IO David Gibson
2011-03-16 14:43   ` [Qemu-devel] " Alexander Graf
2011-03-16 22:04   ` [Qemu-devel] " Anthony Liguori
2011-03-17  3:19     ` David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 15/26] Virtual hash page table handling on pSeries machine David Gibson
2011-03-16 15:03   ` [Qemu-devel] " Alexander Graf
2011-03-17  1:03     ` [Qemu-devel] Re: [PATCH 15/26] Virtual hash page table handling on pSeries machine' David Gibson
2011-03-17  7:35       ` Alexander Graf
2011-03-16  4:56 ` [Qemu-devel] [PATCH 16/26] Implement hcall based RTAS for pSeries machines David Gibson
2011-03-16 15:08   ` [Qemu-devel] " Alexander Graf
2011-03-17  1:22     ` David Gibson
2011-03-17  7:36       ` Alexander Graf
2011-03-16 22:08   ` [Qemu-devel] " Anthony Liguori
2011-03-16  4:56 ` [Qemu-devel] [PATCH 17/26] Implement assorted pSeries hcalls and RTAS methods David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 18/26] Implement the PAPR (pSeries) virtualized interrupt controller (xics) David Gibson
2011-03-16 15:47   ` [Qemu-devel] " Alexander Graf
2011-03-17  1:29     ` David Gibson
2011-03-17  7:37       ` Alexander Graf
2011-03-16 22:16   ` [Qemu-devel] " Anthony Liguori
2011-03-17  1:34     ` David Gibson
2011-03-17 13:13       ` Anthony Liguori
2011-03-23  3:48         ` David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 19/26] Add PAPR H_VIO_SIGNAL hypercall and infrastructure for VIO interrupts David Gibson
2011-03-16 15:49   ` [Qemu-devel] " Alexander Graf
2011-03-17  1:38     ` David Gibson
2011-03-17  7:38       ` Alexander Graf
2011-03-16  4:56 ` [Qemu-devel] [PATCH 20/26] Add (virtual) interrupt to PAPR virtual tty device David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 21/26] Implement TCE translation for sPAPR VIO David Gibson
2011-03-16 16:03   ` [Qemu-devel] " Alexander Graf
2011-03-16 20:05     ` Benjamin Herrenschmidt
2011-03-16 20:21       ` Anthony Liguori
2011-03-16 20:22       ` Anthony Liguori
2011-03-16 20:36         ` Benjamin Herrenschmidt
2011-03-17  1:43     ` David Gibson
2011-03-16 22:20   ` [Qemu-devel] " Anthony Liguori
2011-03-18  1:58     ` David Gibson
2011-03-16  4:56 ` [Qemu-devel] [PATCH 22/26] Implement sPAPR Virtual LAN (ibmveth) David Gibson
2011-03-16 16:12   ` [Qemu-devel] " Alexander Graf
2011-03-17  2:04     ` David Gibson
2011-03-16 22:29   ` [Qemu-devel] " Anthony Liguori
2011-03-17  2:09     ` David Gibson
2011-03-16  4:57 ` [Qemu-devel] [PATCH 23/26] Implement PAPR CRQ hypercalls David Gibson
2011-03-16 16:15   ` [Qemu-devel] " Alexander Graf
2011-03-16  4:57 ` [Qemu-devel] [PATCH 24/26] Implement PAPR virtual SCSI interface (ibmvscsi) David Gibson
2011-03-16 16:41   ` [Qemu-devel] " Alexander Graf
2011-03-16 16:51     ` Anthony Liguori [this message]
2011-03-16 20:08     ` Benjamin Herrenschmidt
2011-03-16 20:19       ` Anthony Liguori
2011-03-16  4:57 ` [Qemu-devel] [PATCH 25/26] Add a PAPR TCE-bypass mechanism for the pSeries machine David Gibson
2011-03-16 16:43   ` [Qemu-devel] " Alexander Graf
2011-03-17  2:21     ` David Gibson
2011-03-17  3:25       ` Benjamin Herrenschmidt
2011-03-17  7:44         ` Alexander Graf
2011-03-17  8:44           ` Benjamin Herrenschmidt
2011-03-17  9:37             ` Alexander Graf
2011-03-16  4:57 ` [Qemu-devel] [PATCH 26/26] Implement PAPR VPA functions for pSeries shared processor partitions David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D80EAAC.1090009@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=agraf@suse.de \
    --cc=anton@samba.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=paulus@samba.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.