Either one.  If a case presents a federal question – or – if the parties are diverse then a federal court can assert subject matter jurisdiction.  For example, if plaintiff and defendant are citizens of New York but the case presents a federal question, a federal court may assert subject matter jurisdiction.  The parties are not diverse but the case is still appropriate for the federal court.