Add a public declaration for gb_interface_destroy(), matching
gb_interface_create().
It's not yet used outside "interface.c" but I suppose it
could be, and its scope is currently public.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Its not referenced by svc or any other code anymore, lets stop exposing
it to rest of the files.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Its not updated/used anymore, remove it. Also move back the struct
gb_svc to svc.c as its not referenced by external users anymore.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
SVC connection is required before the AP knows its position on the endo
and type of endo. To enable message processing between the AP and SVC at
this time, we need a partially initialized connection which can handle
these messages.
Once the AP receives more information from the SVC, it can discard this
partially initialized connection and create a proper one, tied to a
bundle and interface.
Destroying the partially initialized connection is a bit tricky, as it
is required to send a response to svc-hello. That part will be properly
fixed separately.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We need to create bundle/connection for svc cport after the endo layout
and interface id is known to the AP. gb_create_control_connection() can
be reused for this, but it should be renamed to something more
appropriate, as its not about control-connection anymore.
Lets name it gb_create_bundle_connection().
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Its another special protocol (just like control protocol) and is
required to be accessed from other files, lets save a pointer to it in
interface structure.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
While introducing bundles, the device_id also got moved to the bundle,
whereas it identifies an interface block to the AP.
Move it back to interface instead of bundle.
Calls to gb_bundle(s)_init() are dropped as connections will be
initialized while they are created now, as device_id will be valid.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Control protocol is ready to be used for fetching manifest. Lets do it.
This changes few things:
- Creates/initializes bundle/connection for control protocol initially
and skips doing the same later.
- Manifest is parsed at link-up now, instead of hotplug which was the
case earlier. This is because we need device_id (provided during
link-up) for registering bundle.
- Manifest is fetched using control protocol.
So the sequence of events is:
Event Previously Now
----- ---------- ---
Interface Hotplug create intf create intf
parse mfst
Interface Link Up init bundles create control conn
get mfst size
get mfst
parse mfst
init bundles
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add control protocol driver that is responsible for handling operations
on control CPort. The AP also needs to support incoming requests on its
control port. Features not implemented yet are marked as TODO for now.
NOTE: This also fixes cport-bundle-id to 0 and cport-id to 2 for control
protocol.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
A Greybus driver will bind to a bundle, not an interface. Lets follow
this rule in code.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
A module can have more than one interfaces and we get hotplug events or
manifests for interfaces, not modules. Details like version, vendor,
product id, etc. can be different for different interfaces within the
same module and so shall be fetched from interface descriptor instead of
module descriptor.
So what we have been doing for module descriptors until now must be done
for interface descriptors. There can only be one interface descriptor in
the manifest. Module descriptor isn't used anymore and probably most of
its fields can be removed now.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
There can be more than one interface on a module and we need to know the
interface for which the event has occurred.
But at the same time we may not need the module id at all. During initial phase
when AP is probed, the AP will receive the unique Endo id which shall be enough
to draw relationships between interface and module ids.
Code for that isn't available today and so lets create another routine to get
module id (which needs to be fixed separately), which will simply return
interface id passed to it.
Now that we have interface id, update rest of the code to use it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The list was global and had no locking. It's not like we were ever
parsing more than one manifest at the same time right now, but we might
in the future. And we really want this to be local to the interface
itself, for future work redoing how to bind protocols to bundles, so
move the list to the interface structure.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Modules in the greybus system sit above the interface, so insert them
early in the sysfs tree. We dynamically create them when we have an
interface that references a module, as we don't get a "module create"
message directly. They also dynamically go away when the last interface
associated with a module is removed.
Naming scheme for modules/interfaces/bundles/connections is bumped up by
one ':', and now looks like the following:
/sys/bus/greybus $ tree
.
├── devices
│ ├── 7 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7
│ ├── 7:7 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7
│ ├── 7:7:0 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7/7:7:0
│ └── 7:7:0:1 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7/7:7:0/7:7:0:1
├── drivers
├── drivers_autoprobe
├── drivers_probe
└── uevent
6 directories, 3 files
/sys/bus/greybus $ grep . devices/*/uevent
devices/7/uevent:DEVTYPE=greybus_module
devices/7:7/uevent:DEVTYPE=greybus_interface
devices/7:7:0/uevent:DEVTYPE=greybus_bundle
devices/7:7:0:1/uevent:DEVTYPE=greybus_connection
We still have some "confusion" about interface ids and module ids, which
will be cleaned up later when the svc control protocol changes die down,
right now we just name a module after the interface as we don't have any
modules that have multiple interfaces in our systems.
This has been tested with gbsim.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This is really a list of interfaces, not modules, so rename it so that
we don't get confused when we really do add modules to the whole system
later on.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
rename gb_add_module -> gb_add_interface
rename gb_remove_modules -> gb_remove_interfaces
rename gb_remove_module -> gb_remove_interface
And move the function prototypes to interface.h, where they belong.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
MAX_CPORTS_PER_MODULE and MAX_STRINGS_PER_MODULE are not used anywhere
anymore, so remove them lest someone thing we have limits.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
This moves the id structure name to not have "block" in it, as that
doesn't make sense anymore with the renaming of the gb_interface
structure.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Rename struct gb_interface_block to struct gb_interface
Lots of renaming, and variable renames as well (gb_ib->intf), but all
should be sane with regards to the new naming scheme we are using.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Interface_block is being renamed to interface, so move the file first.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We are renameing the "interface" term to "bundle" so rename the files
before we start changing structure names to make it easier for people to
see what really is happening in the changes.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
I was asked to add a Linaro copyright to all Greybus source files
that anyone at Linaro has modified. This patch does that.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Rename struct gb_module to struct gb_interface_block
It's a complex rename, some functions got their name changed where
needed, but primarily this change is focused on the structure and where
it is used. Future changes will clean up the remaining usages of the
term "module" in individual changes, this one spanned the whole
subsystem so do it all at once.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
That's where it belong to. Also rename it in a similar way to:
gb_interface_create() and gb_interface_destroy().
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This patch hooks up modules, interfaces, and connections to the driver
model. Now we have a correct hierarchy, and drivers can be correctly
bound to the proper portions in the future. Devices are correctly
reference counted and torn down in the proper order on removal of a
module.
Some basic sysfs attributes have been created for interfaces and
connections. Module attributes are not working properly, but that will
be fixed in future changes.
This has been tested on Alex's machine, with multiple hotplug and unplug
operations of a module working correctly.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add support for getting a struct gb_interface from an
Interface ID.
Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
When a module gets destroyed all of its state and the state of its
interfaces and connections (etc.) need to be torn down. This is
not now being done properly. Add this teardown code.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Set up the infrastructure for initializing connections based on
their protocol.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Fix some omissions found in the code.
- initialize and use the host device connections list
- rename the interface connections list (was "functions")
- use the interface connections list
- define a spinlock protecting the connections lists
- declare gb_operation_submit() in "operation.h"
And the cport id map lock is per-host device, it's shared across all
host devices. There's no need for one in struct greybus_host_device.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Update the definitions in "greybus_manifest.h" to reflect the
changes to the Greybus specification made on October 1.
They are:
- renaming "device" to be "interface"
- renumbering greybus descriptor type
- eliminating the notion of a "function"
- defining a CPort's protocol in the CPort descriptor
- having a "class" take on the types previously used for "function"
- renaming "serial number" to be "unique id" (for now)
- relying on an interface's maximum cport id to determine how
much device+cport address space the interface consumes
- adding a simple class descriptor
- renaming gb_interface->interface_id to be gb_interface->id
This also reorders some things to match ordering in the document,
and adds some commentary for the various structures.
Since greybus_function_type is gone, we eliminate the "type" field
from a function structure. (Functions are going away, next.)
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Define new source files "function.h" and "function.c" to contain the
definitions of the Greybus function abstraction. A Greybus function
represents an active entity connected to a CPort implemented by a
Greybus interface. A Greybus function has a type, which defines the
protocol to be used to interact with the function. A Greybus
interface normally has at least two functions, but potentially many
more.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Define new source files "interface.h" and "interface.c" to contain
the definitions of the Greybus interface abstraction. A Greybus
interface represents a UniPro device present in a UniPro module.
For Project Ara, each interface block on a module implements a
UniPro interface.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>