pcie: Support PCIe Gen5/Gen6 link speeds
PATCH 1/1 pcie: Support PCIe Gen5/Gen6 link speeds
This patch extends the PCIe link speed option so that slots can be configured as supporting 32GT/s (Gen5) or 64GT/s (Gen5) speeds. This is as simple as setting the appropriate bit in LnkCap2 and the appropriate value in LnkCap and LnkCtl2.
--- hw/core/qdev-properties-system.c | 16 ++++++++++++++-- hw/pci/pcie.c | 8 ++++++++ include/hw/pci/pcie_regs.h | 2 ++ qapi/common.json | 6 +++++- 4 files changed, 29 insertions(+), 3 deletions(-)
hw/core/qdev-properties-system.c +14 -2
@@ -941,7 +941,7 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { .set_default_value = qdev_propinfo_set_default_value_enum, }; -/* --- PCIELinkSpeed 2_5/5/8/16 -- */ +/* --- PCIELinkSpeed 2_5/5/8/16/32/64 -- */ static void get_prop_pcielinkspeed (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp)
@@ -963,6 +963,12 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,case QEMU_PCI_EXP_LNK_16GT : speed =PCIE_LINK_SPEED_16 ;break ; +case QEMU_PCI_EXP_LNK_32GT : + speed =PCIE_LINK_SPEED_32 ; +break ; +case QEMU_PCI_EXP_LNK_64GT : + speed =PCIE_LINK_SPEED_64 ; +break ;default :/* Unreachable */ abort ();
@@ -996,6 +1002,12 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,case PCIE_LINK_SPEED_16 : *p =QEMU_PCI_EXP_LNK_16GT ;break ; +case PCIE_LINK_SPEED_32 : + *p =QEMU_PCI_EXP_LNK_32GT ; +break ; +case PCIE_LINK_SPEED_64 : + *p =QEMU_PCI_EXP_LNK_64GT ; +break ;default :/* Unreachable */ abort ();
@@ -1004,7 +1016,7 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,const PropertyInfo qdev_prop_pcie_link_speed = { .name ="PCIELinkSpeed" , - .description ="2_5/5/8/16" , + .description ="2_5/5/8/16/32/64" , .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed,
hw/pci/pcie.c +8 -0
@@ -153,6 +153,14 @@ static void pcie_cap_fill_slot_lnk(PCIDevice *dev)pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 ,PCI_EXP_LNKCAP2_SLS_16_0GB ); } +if (s->speed >QEMU_PCI_EXP_LNK_16GT ) { +pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 , +PCI_EXP_LNKCAP2_SLS_32_0GB ); + } +if (s->speed >QEMU_PCI_EXP_LNK_32GT ) { +pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 , +PCI_EXP_LNKCAP2_SLS_64_0GB ); + } } }
include/hw/pci/pcie_regs.h +2 -0
@@ -39,6 +39,8 @@ typedef enum PCIExpLinkSpeed {QEMU_PCI_EXP_LNK_5GT ,QEMU_PCI_EXP_LNK_8GT ,QEMU_PCI_EXP_LNK_16GT , +QEMU_PCI_EXP_LNK_32GT , +QEMU_PCI_EXP_LNK_64GT , } PCIExpLinkSpeed;#define QEMU_PCI_EXP_LNKCAP_MLS (speed) (speed)
qapi/common.json +5 -1
@@ -107,10 +107,14 @@ # # @16: 16.0GT/s # +# @32: 32.0GT/s +# +# @64: 64.0GT/s +# # Since: 4.0 ## { 'enum': 'PCIELinkSpeed', - 'data': [ '2_5', '5', '8', '16' ] } + 'data': [ '2_5', '5', '8', '16', '32', '64' ] } ## # @PCIELinkWidth:
Signature · 1 line
2.43.1
Quoted 117 lines · Lukas Stockner
This patch extends the PCIe link speed option so that slots can be configured as supporting 32GT/s (Gen5) or 64GT/s (Gen5) speeds. This is as simple as setting the appropriate bit in LnkCap2 and the appropriate value in LnkCap and LnkCtl2.
Signed-off-by Lukas Stockner <[email protected]>---
hw/core/qdev-properties-system.c | 16 ++++++++++++++-- hw/pci/pcie.c | 8 ++++++++ include/hw/pci/pcie_regs.h | 2 ++ qapi/common.json | 6 +++++- 4 files changed, 29 insertions(+), 3 deletions(-)hw/core/qdev-properties-system.c +14
-2@@ -941,7 +941,7 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { .set_default_value = qdev_propinfo_set_default_value_enum, }; -/* --- PCIELinkSpeed 2_5/5/8/16 -- */ +/* --- PCIELinkSpeed 2_5/5/8/16/32/64 -- */ static void get_prop_pcielinkspeed (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp)@@ -963,6 +963,12 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,case QEMU_PCI_EXP_LNK_16GT : speed =PCIE_LINK_SPEED_16 ;break ; +case QEMU_PCI_EXP_LNK_32GT : + speed =PCIE_LINK_SPEED_32 ; +break ; +case QEMU_PCI_EXP_LNK_64GT : + speed =PCIE_LINK_SPEED_64 ; +break ;default :/* Unreachable */ abort ();@@ -996,6 +1002,12 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,case PCIE_LINK_SPEED_16 : *p =QEMU_PCI_EXP_LNK_16GT ;break ; +case PCIE_LINK_SPEED_32 : + *p =QEMU_PCI_EXP_LNK_32GT ; +break ; +case PCIE_LINK_SPEED_64 : + *p =QEMU_PCI_EXP_LNK_64GT ; +break ;default :/* Unreachable */ abort ();@@ -1004,7 +1016,7 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,const PropertyInfo qdev_prop_pcie_link_speed = { .name ="PCIELinkSpeed" , - .description ="2_5/5/8/16" , + .description ="2_5/5/8/16/32/64" , .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed,hw/pci/pcie.c +8
-0@@ -153,6 +153,14 @@ static void pcie_cap_fill_slot_lnk(PCIDevice *dev)pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 ,PCI_EXP_LNKCAP2_SLS_16_0GB ); } +if (s->speed >QEMU_PCI_EXP_LNK_16GT ) { +pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 , +PCI_EXP_LNKCAP2_SLS_32_0GB ); + } +if (s->speed >QEMU_PCI_EXP_LNK_32GT ) { +pci_long_test_and_set_mask (exp_cap +PCI_EXP_LNKCAP2 , +PCI_EXP_LNKCAP2_SLS_64_0GB ); + } } }include/hw/pci/pcie_regs.h +2
-0@@ -39,6 +39,8 @@ typedef enum PCIExpLinkSpeed {QEMU_PCI_EXP_LNK_5GT ,QEMU_PCI_EXP_LNK_8GT ,QEMU_PCI_EXP_LNK_16GT , +QEMU_PCI_EXP_LNK_32GT , +QEMU_PCI_EXP_LNK_64GT , } PCIExpLinkSpeed;#define QEMU_PCI_EXP_LNKCAP_MLS (speed) (speed)qapi/common.json +5
-1@@ -107,10 +107,14 @@ # # @16: 16.0GT/s # +# @32: 32.0GT/s +# +# @64: 64.0GT/s +# # Since: 4.0 ## { 'enum': 'PCIELinkSpeed', - 'data': [ '2_5', '5', '8', '16' ] } + 'data': [ '2_5', '5', '8', '16', '32', '64' ] } ## # @PCIELinkWidth:Signature · 1 line
2.43.1
Quoted 11 lines · Lukas Stockner
qapi/common.json +2
-0@@ -107,10 +107,14 @@ # # @16: 16.0GT/s # +# @32: 32.0GT/s +#
qapi/common.json line 120
Quoted 10 lines
qapi/common.json +3
-1+# @64: 64.0GT/s +# # Since: 4.0 ## { 'enum': 'PCIELinkSpeed', - 'data': [ '2_5', '5', '8', '16' ] } + 'data': [ '2_5', '5', '8', '16', '32', '64' ] } ## # @PCIELinkWidth:
I'll merge this but I really don't know how one documents that some enum options have been added since some version of qemu.
Quoted 1 line
2.43.1
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Lukas Stockner
qapi/common.json +5
-1@@ -107,10 +107,14 @@ # # @16: 16.0GT/s # +# @32: 32.0GT/s +# +# @64: 64.0GT/s +# # Since: 4.0 ## { 'enum': 'PCIELinkSpeed', - 'data': [ '2_5', '5', '8', '16' ] } + 'data': [ '2_5', '5', '8', '16', '32', '64' ] }
Quoted 8 lines
qapi/common.json line 120
Quoted 3 lines
qapi/common.json +0
-0## # @PCIELinkWidth:I'll merge this but I really don't know how one documents that some enum options have been added since some version of qemu.
Common style:
#
# @16: 16.0GT/s
#
# @32: 32.0GT/s (since 9.0)
#
# @64: 64.0GT/s (since 9.0)
#
# Since: 4.0
##Please add that for the merge.