qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, lmr@redhat.com, etmartin@cisco.com,
	wexu2@cisco.com, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: [Qemu-devel] Re: [PATCH v6 07/12] pcie/hotplug: introduce pushing attention button command
Date: Wed, 20 Oct 2010 12:00:11 +0200	[thread overview]
Message-ID: <20101020100011.GE10783@redhat.com> (raw)
In-Reply-To: <2f5cb93039ab90a7b267334dd5e2e94b7a550b9f.1287562197.git.yamahata@valinux.co.jp>

On Wed, Oct 20, 2010 at 05:18:56PM +0900, Isaku Yamahata wrote:
> glue pcie_push_attention_button command.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

So as a high level command, I think we need to
think about how to tie this into pci_add/pci_del.
Right?
As a low level command, this is not really useful unless
there is an event on LED status change and a way
to get info on LED status.
Right?

> ---
>  hw/pcie_port.c  |   82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  qemu-monitor.hx |   14 +++++++++
>  sysemu.h        |    4 +++
>  3 files changed, 100 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/pcie_port.c b/hw/pcie_port.c
> index 117de61..f43a1c7 100644
> --- a/hw/pcie_port.c
> +++ b/hw/pcie_port.c
> @@ -18,6 +18,10 @@
>   * with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include "qemu-objects.h"
> +#include "sysemu.h"
> +#include "monitor.h"
> +#include "pcie.h"
>  #include "pcie_port.h"
>  
>  void pcie_port_init_reg(PCIDevice *d)
> @@ -114,3 +118,81 @@ void pcie_chassis_del_slot(PCIESlot *s)
>  {
>      QLIST_REMOVE(s, next);
>  }
> +
> +/**************************************************************************
> + * glue for qemu monitor
> + */
> +
> +/* Parse [<chassis>.]<slot>, return -1 on error */
> +static int pcie_parse_slot_addr(const char* slot_addr,
> +                                uint8_t *chassisp, uint16_t *slotp)
> +{
> +    const char *p;
> +    char *e;
> +    unsigned long val;
> +    unsigned long chassis = 0;
> +    unsigned long slot;
> +
> +    p = slot_addr;
> +    val = strtoul(p, &e, 0);
> +    if (e == p) {
> +        return -1;
> +    }
> +    if (*e == '.') {
> +        chassis = val;
> +        p = e + 1;
> +        val = strtoul(p, &e, 0);
> +        if (e == p) {
> +            return -1;
> +        }
> +    }
> +    slot = val;
> +
> +    if (*e) {
> +        return -1;
> +    }
> +
> +    if (chassis > 0xff || slot > 0xffff) {
> +        return -1;
> +    }
> +
> +    *chassisp = chassis;
> +    *slotp = slot;
> +    return 0;
> +}
> +
> +void pcie_attention_button_push_print(Monitor *mon, const QObject *data)
> +{
> +    QDict *qdict;
> +
> +    assert(qobject_type(data) == QTYPE_QDICT);
> +    qdict = qobject_to_qdict(data);
> +
> +    monitor_printf(mon, "OK chassis %d, slot %d\n",
> +                   (int) qdict_get_int(qdict, "chassis"),
> +                   (int) qdict_get_int(qdict, "slot"));
> +}
> +
> +int pcie_attention_button_push(Monitor *mon, const QDict *qdict,
> +                               QObject **ret_data)
> +{
> +    const char* pcie_slot = qdict_get_str(qdict, "pcie_slot");
> +    uint8_t chassis;
> +    uint16_t slot;
> +    PCIESlot *s;
> +
> +    if (pcie_parse_slot_addr(pcie_slot, &chassis, &slot) < 0) {
> +        monitor_printf(mon, "invalid pcie slot address %s\n", pcie_slot);
> +        return -1;
> +    }
> +    s = pcie_chassis_find_slot(chassis, slot);
> +    if (!s) {
> +        monitor_printf(mon, "slot is not found. %s\n", pcie_slot);
> +        return -1;
> +    }
> +    pcie_cap_slot_push_attention_button(&s->port.br.dev);
> +    *ret_data = qobject_from_jsonf("{ 'chassis': %d, 'slot': %d}",
> +                                   chassis, slot);
> +    assert(*ret_data);
> +    return 0;
> +}
> diff --git a/qemu-monitor.hx b/qemu-monitor.hx
> index 2af3de6..965c754 100644
> --- a/qemu-monitor.hx
> +++ b/qemu-monitor.hx
> @@ -1154,6 +1154,20 @@ Hot remove PCI device.
>  ETEXI
>  
>      {
> +        .name       = "pcie_push_attention_button",
> +        .args_type  = "pcie_slot:s",
> +        .params     = "[<chassis>.]<slot>",
> +        .help       = "push pci express attention button",
> +        .user_print  = pcie_attention_button_push_print,
> +        .mhandler.cmd_new = pcie_attention_button_push,
> +    },
> +
> +STEXI
> +@item pcie_abp
> +Push PCI express attention button
> +ETEXI
> +
> +    {
>          .name       = "host_net_add",
>          .args_type  = "device:s,opts:s?",
>          .params     = "tap|user|socket|vde|dump [options]",
> diff --git a/sysemu.h b/sysemu.h
> index 9c988bb..cca411d 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -150,6 +150,10 @@ extern unsigned int nb_prom_envs;
>  void pci_device_hot_add(Monitor *mon, const QDict *qdict);
>  void drive_hot_add(Monitor *mon, const QDict *qdict);
>  void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
> +/* pcie hotplug */
> +void pcie_attention_button_push_print(Monitor *mon, const QObject *data);
> +int pcie_attention_button_push(Monitor *mon, const QDict *qdict,
> +                               QObject **ret_data);
>  
>  /* serial ports */
>  
> -- 
> 1.7.1.1

  reply	other threads:[~2010-10-20 10:06 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20  8:18 [Qemu-devel] [PATCH v6 00/12] pcie port switch emulators Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 01/12] pcie: comment on hpev_intx Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 02/12] pci/bridge: fix pci_bridge_reset() Isaku Yamahata
2010-10-20  8:49   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-20  9:04     ` Isaku Yamahata
2010-10-20 10:00       ` Michael S. Tsirkin
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 03/12] pcie port: define struct PCIEPort/PCIESlot and helper functions Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 04/12] ioh3420: pcie root port in X58 ioh Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 05/12] x3130: pcie upstream port Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 06/12] x3130: pcie downstream port Isaku Yamahata
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 07/12] pcie/hotplug: introduce pushing attention button command Isaku Yamahata
2010-10-20 10:00   ` Michael S. Tsirkin [this message]
2010-10-21  3:46     ` [Qemu-devel] " Isaku Yamahata
2010-10-21  8:02       ` Michael S. Tsirkin
2010-10-21  9:41         ` Isaku Yamahata
2010-10-22 11:35     ` Markus Armbruster
2010-10-22 14:38       ` Michael S. Tsirkin
2010-10-22 14:52         ` Anthony Liguori
2010-10-25  4:16           ` Michael S. Tsirkin
2010-10-25  3:29         ` Isaku Yamahata
2010-10-25  4:15           ` Michael S. Tsirkin
2010-10-25  5:53             ` Isaku Yamahata
2010-10-25  5:55               ` Michael S. Tsirkin
2010-10-25  7:02                 ` Isaku Yamahata
2010-10-25  7:27                   ` Michael S. Tsirkin
2010-10-27  1:47                   ` Isaku Yamahata
2010-10-27 13:31                     ` Michael S. Tsirkin
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 08/12] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-10-20  9:56   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-21  5:15     ` Isaku Yamahata
2010-10-21  8:07       ` Michael S. Tsirkin
2010-10-21 23:53         ` Isaku Yamahata
2010-10-22  9:27           ` Michael S. Tsirkin
2010-10-22 11:28     ` Markus Armbruster
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 09/12] pcie/aer: glue aer error injection into qemu monitor Isaku Yamahata
2010-10-20  9:44   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-20  8:18 ` [Qemu-devel] [PATCH v6 10/12] ioh3420: support aer Isaku Yamahata
2010-10-20  8:19 ` [Qemu-devel] [PATCH v6 11/12] x3130/upstream: " Isaku Yamahata
2010-10-20  8:19 ` [Qemu-devel] [PATCH v6 12/12] x3130/downstream: " Isaku Yamahata
2010-10-20 10:09 ` [Qemu-devel] Re: [PATCH v6 00/12] pcie port switch emulators Michael S. Tsirkin

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=20101020100011.GE10783@redhat.com \
    --to=mst@redhat.com \
    --cc=etmartin@cisco.com \
    --cc=kraxel@redhat.com \
    --cc=lmr@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=skandasa@cisco.com \
    --cc=wexu2@cisco.com \
    --cc=yamahata@valinux.co.jp \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).